params = model.make_params()
params['sigma'].set(value=-1)
result = model.fit(y, x=x, params=params)
result.plot_fit(ax=axs[0], show_init=True)
# It took me quite a while to realize that lmfit was forcing
+ve sigma # without this being documented.
# As you say, it is possible to fit like this
model = lmfit.models.StepModel(form='erf') + lmfit.models.ConstantModel()
params = model.make_params()
params['amplitude'].set(value=-1)
params['c'].set(value=1)
result = model.fit(y, x=x, params=params)
result.plot_fit(ax=axs[1], show_init=True)
# I think this is much more cumbersome and less natural
# as I have to both flip the step upside-down as
# well as offset it with a constant, rather than
# just recognizing that the step has been flipped in x.
# Regarding whether sigma should be allowed to change during a fit
# I think this should be up to the user.
# I would say that lmfit should allow all curve shapes that
# make mathematical sense, as it cannot reasonably
# hope to guess which shapes make physical sense
# . The default amplitude behavior allows sign switching
# even though most physical situations probably have
# either positive or negative amplitudes.