Hi lmfit
In many cases we might want to extract parameters and standard error estimates programmatically rather than by reading the fit report (e.g., if the fit will be used to produce a data point on another plot, then the standard error can be used for computing error bars).
**********************************
from scipy.optimize import least_squares
from matplotlib.pylab import plt
import numpy as np
from numpy import exp, linspace, random
from lmfit import Model
def gaussian(x, amp, cen, wid):
return amp * np.exp(-(x-cen)**2 / wid)
x = linspace(-10, 10, 101)
y = gaussian(x, 2.33, 0.21, 1.51) + random.normal(0, 0.2, len(x))
gmodel = Model(gaussian)
params = gmodel.make_params()
# print('parameter names: {}'.format(gmodel.param_names))
# print('independent variables: {}'.format(gmodel.independent_vars))
result = gmodel.fit(y, params, x=x, amp=5, cen=5, wid=1)
print(result.fit_report())
lst = []
for name, param in out.params.items():
lst.append(param.value)
lst.append(param.stderr)
*****************************************
I got this erroer:
NameError: name 'out' is not defined
****************************************
What should I do??