You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, I read the instructions and I am sure this is a GitHub Issue.
Description
Using the simple example from the documentation and printing result.init_values (or result.init_vals) as in the MWE below reveals an incorrect initial value for amp. It should be 10 but it is 10.954451150103322.
A Minimal, Complete, and Verifiable example
importnumpyasnpfromlmfitimportMinimizer, Parameters, report_fit# create data to be fittedx=np.linspace(0, 15, 301)
np.random.seed(2021)
data= (5.0*np.sin(2.0*x-0.1) *np.exp(-x*x*0.025) +np.random.normal(size=x.size, scale=0.2))
# define objective function: returns the array to be minimizeddeffcn2min(params, x, data):
"""Model a decaying sine wave and subtract data."""amp=params['amp']
shift=params['shift']
omega=params['omega']
decay=params['decay']
model=amp*np.sin(x*omega+shift) *np.exp(-x*x*decay)
returnmodel-data# create a set of Parametersparams=Parameters()
params.add('amp', value=10, min=0)
params.add('decay', value=0.1)
params.add('shift', value=0.0, min=-np.pi/2., max=np.pi/2.)
params.add('omega', value=3.0)
# do fit, here with the default leastsq algorithmminner=Minimizer(fcn2min, params, fcn_args=(x, data))
result=minner.minimize()
# calculate final resultfinal=data+result.residual# write error reportreport_fit(result)
# now print the inital valuesprint(result.init_values)
First Time Issue Code
Yes, I read the instructions and I am sure this is a GitHub Issue.
Description
Using the simple example from the documentation and printing
result.init_values
(orresult.init_vals
) as in the MWE below reveals an incorrect initial value foramp
. It should be10
but it is10.954451150103322
.A Minimal, Complete, and Verifiable example
This gives the output
report_fit
correctly reports an initial value of10
foramp
butresult.init_values
does not.Version information
The text was updated successfully, but these errors were encountered: