【发布时间】:2022-01-11 05:11:37
【问题描述】:
我的 NIR 光谱 (x,y) 文件不提供错误信息。我正在做一个黑体加幂律拟合,代码如下;根据生成的参数值和相应的图,它似乎可以正常工作。然而,卡方值非常小,如下面的示例所示。文档说应该正确缩放残差。执行此操作的确切步骤是什么?感谢您的帮助。
def bb(x, T, const):
from scipy.constants import h,k,c
x = 1e-6 * x
return const*2*h*c**2 / (x**5 * (np.exp(h*c / (x*k*T)) - 1))
def powerlaw(x,A,p):
return A*x**p
mod= Model(bb) + Model(powerlaw)
pars = mod.make_params(T=2000,const=2*1e-21,A=2*np.average(y),p=-1.0)
result = mod.fit(y,pars,x=x)
print((result.fit_report()))
#Parameters
T= (result.params['T'].value)
const=(result.params['const'].value)
A= (result.params['A'].value)
p= (result.params['p'].value)
---------------------------------
T: 1403.30461 +/- 4.19860373 (0.30%)
line 67 [[Model]]
(Model(bb) + Model(powerlaw))
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 69
# data points = 5362
# variables = 4
chi-square = 5.6981e-29
reduced chi-square = 1.0635e-32
Akaike info crit = -394752.758
Bayesian info crit = -394726.409
[[Variables]]
T: 1403.30461 +/- 4.19860373 (0.30%) (init = 2000)
const: 6.9272e-26 +/- 8.9056e-28 (1.29%) (init = 2e-21)
A: 2.1975e-15 +/- 7.9268e-18 (0.36%) (init = 4.309166e-15)
p: -2.57314708 +/- 0.01807976 (0.70%) (init = -1)
【问题讨论】:
标签: python python-3.x chi-squared lmfit