Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python lmfit未按预期执行_Python_Scipy_Curve Fitting_Lmfit - Fatal编程技术网

Python lmfit未按预期执行

Python lmfit未按预期执行,python,scipy,curve-fitting,lmfit,Python,Scipy,Curve Fitting,Lmfit,我正在编写一个脚本,用于将一些光致发光光谱与自定义模型进行拟合,在使用SciPy创建了一个脚本之后,我了解到,如果使用lmfit(cars9.uchicago.edu/software/python/lmfit/intro.html),那么设置拟合参数的边界会容易得多,所以我决定改用它。下面是我编写的一个脚本,用一个高斯函数拟合一个光谱(使用两个高斯函数更好,但我想从一个更简单的例子开始) 这将返回: [[Model]] Model(gauss) [[Fit Statistics]]

我正在编写一个脚本,用于将一些光致发光光谱与自定义模型进行拟合,在使用SciPy创建了一个脚本之后,我了解到,如果使用lmfit(cars9.uchicago.edu/software/python/lmfit/intro.html),那么设置拟合参数的边界会容易得多,所以我决定改用它。下面是我编写的一个脚本,用一个高斯函数拟合一个光谱(使用两个高斯函数更好,但我想从一个更简单的例子开始)

这将返回:

[[Model]]
    Model(gauss)
[[Fit Statistics]]
    # function evals   = 77
    # data points      = 1024
    # variables        = 3
    chi-square         = 28469283.530
    reduced chi-square = 27883.725
[[Variables]]
    a1:   561.593868 +/- 8.255604 (1.47%) (init= 590)
    b1:   100.129107 +/- 85.34384 (85.23%) (init= 500)
    c1:   1.3254e+06 +/- 7.23e+05 (54.52%) (init= 20)
[[Correlations]] (unreported correlations are <  0.100)
    C(b1, c1)                    = -0.892 
    C(a1, c1)                    = -0.763 
    C(a1, b1)                    =  0.685 
我明白了:

[[Model]]
    Model(gauss)
[[Fit Statistics]]
    # function evals   = 147
    # data points      = 1024
    # variables        = 3
    chi-square         = 304708538.428
    reduced chi-square = 298441.272
[[Variables]]
    a1:   629.999937 +/- 0        (0.00%) (init= 590)
    b1:   475.821359 +/- 0        (0.00%) (init= 500)
    c1:   70         +/- 0        (0.00%) (init= 30)
[[Correlations]] (unreported correlations are <  0.100)
[[Model]]
模型(高斯)
[[Fit统计数据]]
#函数evals=147
#数据点=1024
#变量=3
卡方=304708538.428
缩减卡方检验=298441.272
[[变量]]
a1:629.999937+/-0(0.00%)(初始值=590)
b1:475.821359+/-0(0.00%)(初始值=500)
c1:70+/-0(0.00%)(初始值=30)
[[相关性]](未报告的相关性<0.100)

帮助?

嗯,应该是吗

out  = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0])
也就是说,您希望拟合“y”,并传入“pars”和“x”数组,以帮助使用这些参数和自变量计算模型

[[Model]]
    Model(gauss)
[[Fit Statistics]]
    # function evals   = 147
    # data points      = 1024
    # variables        = 3
    chi-square         = 304708538.428
    reduced chi-square = 298441.272
[[Variables]]
    a1:   629.999937 +/- 0        (0.00%) (init= 590)
    b1:   475.821359 +/- 0        (0.00%) (init= 500)
    c1:   70         +/- 0        (0.00%) (init= 30)
[[Correlations]] (unreported correlations are <  0.100)
out  = mod1.fit(spectra_beBG[:,1], pars, x=spectra_beBG[:,0])