Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
전산물리학:선형_회귀_분석_linear_regression_analysis [2022/01/16 18:08] – jonghoon | 전산물리학:선형_회귀_분석_linear_regression_analysis [2023/09/05 15:46] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 14: | Line 14: | ||
scipy를 쓸 때는 표준오차가 포함되어 있는 경우에는 absolute_sigma 옵션을 True로 줘야 한다. | scipy를 쓸 때는 표준오차가 포함되어 있는 경우에는 absolute_sigma 옵션을 True로 줘야 한다. | ||
+ | ====== 실습 ======= | ||
다음의 데이터를 예로 각 언어로 적합(fitting)해보자. | 다음의 데이터를 예로 각 언어로 적합(fitting)해보자. | ||
Line 39: | Line 39: | ||
| 4.75 | 10.519384785632700 | 0.47616567472190800 | | | 4.75 | 10.519384785632700 | 0.47616567472190800 | | ||
+ | ===== Python ===== | ||
먼저 Python 코드는 아래와 같다. | 먼저 Python 코드는 아래와 같다. | ||
- | <Code:Python> | + | <code: |
import numpy as np | import numpy as np | ||
from scipy.optimize import curve_fit | from scipy.optimize import curve_fit | ||
Line 64: | Line 65: | ||
print(" | print(" | ||
- | </Code> | + | </code> |
+ | ===== C++ ===== | ||
다음은 C++에서 gsl을 이용한 코드이다. | 다음은 C++에서 gsl을 이용한 코드이다. | ||
- | <Code:C++> | + | <code:C++ | curve_fit.cpp> |
#include < | #include < | ||
#include < | #include < | ||
Line 146: | Line 148: | ||
cout << "y = " << a << "x + "<< | cout << "y = " << a << "x + "<< | ||
} | } | ||
- | </Code> | + | </code> |
+ | ===== 결과 ===== | ||
각각의 결과는 다음과 같다 | 각각의 결과는 다음과 같다 | ||
$$\text{Python: | $$\text{Python: | ||
- | $$\text{C++: | + | $$\text{C++: |
- | 유효숫자는 c++의 기본 자릿수인 6자리에 맞췄다. | + | 유효숫자는 c++ cout의 기본 자릿수인 6자리에 맞췄다. |