简体   繁体   English

并非始终显示lmfit参数上的错误

[英]The errors on lmfit parameters are not always shown

I am trying to fit a curve to some data points using lmfit and I need the errors on the parameters. 我正在尝试使用lmfit将曲线拟合到某些数据点,并且我需要参数上的错误。 After I call: out = model.fit(y, pars, x, weights = 1/error) I do: print(out.fit_report()) . 在我打电话之后: out = model.fit(y, pars, x, weights = 1/error)我做了: print(out.fit_report()) Sometimes the output is like this (part of hit posted here): 有时输出是这样的(点击的部分结果发布在这里):

# fitting method   = leastsq
    # function evals   = 490
    # data points      = 380
    # variables        = 14
    chi-square         = 1035.65572
    reduced chi-square = 2.82966043
    Akaike info crit   = 408.995142
    Bayesian info crit = 464.157539
[[Variables]]
    line1_c:        49.2699229 +/- 0.17590656 (0.36%) (init = 60.38407)
    sv1_skew:      -6.04992639 +/- 0.50325827 (8.32%) (init = 0)
    sv1_center:     13284.8621 +/- 0.01423913 (0.00%) (init = 13284)
    sv1_sigma:      1.32758560 +/- 0.02864233 (2.16%) (init = 1)
    sv1_amplitude:  240.685241 +/- 3.80236837 (1.58%) (init = 1)
    sv1_gamma:      1.32758560 +/- 0.02864233 (2.16%) == 'sv1_sigma'

which is what I need (ie the parameters have errors associated with them). 这就是我需要的(即参数具有与之相关的错误)。 However other times it is like this: 但是其他时候是这样的:

    # fitting method   = leastsq
    # function evals   = 9509
    # data points      = 64
    # variables        = 14
    chi-square         = 3023.19802
    reduced chi-square = 60.4639605
    Akaike info crit   = 274.731995
    Bayesian info crit = 304.956358
##  Warning: uncertainties could not be estimated:
    sv3_center:     at initial value
    sv4_amplitude:  at boundary
[[Variables]]
    line1_c:        49.6633100 (init = 60.35763)
    sv1_skew:      -19.2947984 (init = 0)
    sv1_amplitude:  269.063100 (init = 1)
    sv1_center:     13285.0635 (init = 13284)
    sv1_sigma:      1.66532381 (init = 1)
    sv1_gamma:      1.66532381 == 'sv1_sigma'

Why can't the uncertainties be estimated in the second case. 为什么不能在第二种情况下估计不确定性。 Also, for the exactly same fit and data, sometimes I get the errors on parameters, sometimes I don't ie I just run python code.py twice in a row, without any modification, and sometimes I get the estimates of the error sometimes I don't. 另外,对于完全相同的拟合和数据,有时我会得到参数上的错误,有时我不会,即我只是python code.py两次运行python code.py ,没有进行任何修改,有时我会得到错误的估计值我不。 However in both cases the fit looks really good by eye. 但是,两种情况下的合身性在视觉上都非常好。 Can someone help me understand what is going on? 有人可以帮助我了解发生了什么吗? Thank you! 谢谢!

If one or more of the variables does not cause a change in the fit result, the uncertainties in the parameter values cannot be estimated. 如果一个或多个变量没有引起拟合结果的变化,则无法估计参数值的不确定性。 This most often means that one or more of the Parameters is stuck at an initial value (perhaps a very poor guess, or perhaps cause part of the model to be unresponsive) or stuck at a boundary. 这通常意味着一个或多个参数卡在一个初始值(可能是一个很差的猜测,或者可能导致模型的一部分无响应)或卡在某个边界。

The fit report tries to give some good hints about what is preventing the uncertainties from be estimated. 拟合度报告试图提供一些很好的提示,说明哪些因素阻止了不确定性的估计。 It says: 它说:

##  Warning: uncertainties could not be estimated:
    sv3_center:     at initial value
    sv4_amplitude:  at boundary

Among other things, this means you did not include the full error report, which would have listed all 14 variables. 除其他外,这意味着您没有包括完整的错误报告,该报告将列出所有14个变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM