python lmfit.minimizer not working
Priya Singh
sapna.intell at gmail.com
Wed Jun 13 03:02:40 EDT 2018
Dear All,
I am trying to fit a spectrum using a power law model. I am using lmfit.minimizer. But the problem is that the value of parameter I am getting is
same as the initial value. Means minimizer is not working. Here is the part of my code:
p = Parameters()
p.add('b', value=10)
p.add('x_0', value=0.007, vary=False)
p.add('a', value=0.2)
p.add('tv', value=3.0, min=0.0)
def residual(p):
v = p.valuesdict()
return (f_c_unmask - (v['b'] * (w_c_unmask/ v['x_0'] )**(-v['a']))*(np.exp(-v['tv']*kpa_smc)))
mi = minimize(residual, p, method='leastsq')
print(fit_report(mi))
The output I am getting:
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 48
# data points = 1304
# variables = 3
chi-square = 232448.935
reduced chi-square = 178.669435
Akaike info crit = 6764.93727
Bayesian info crit = 6780.45685
[[Variables]]
b: 10.0000000 +/- 0.00000000 (0.00%) (init = 10)
x_0: 0.007 (fixed)
a: 0.20000000 +/- 0.00000000 (0.00%) (init = 0.2)
tv: 4.8215e-12 +/- 0.00000000 (0.00%) (init = 3)
More information about the Python-list
mailing list