Hi there,
I am trying to find the best set of parameters for each of several decay experiments. Most importantly, I need those parameters to produce a model, that attains a prescribed value y_m at a given location x_m. Only as a second-most important requirement, I want a good fit.
The following image illustrates my current status: The fit is good, except at the maximum, where I need the fit to attain the same value as the data,
i.e. (x_m, y_m) = (1, 1).

I tried to achieve that by using an expression as in the following example:
def weibull(x, k, lam, amp, stat):
return (amp - stat) * k / lam * (x / lam) ** (k - 1) * np.exp(-(x / lam) ** k) + stat
mod = lmfit.Model(weibull)
pars = lmfit.Parameters()
pars.add('k', value=k0, vary=True, min=0.0)
pars.add('lam', value=1, vary=True, min=0.0)
pars.add('amp', value=1, vary=True)
pars.add('stat', value=0.08, vary=False)
pars._asteval.symtable['fct'] = weibull
pars.add('constraint', expr='fct(1.0, k, lam, amp, stat)', value=1.0, vary=False)
I don't get any error messages, but the returned value of the parameter 'constraint' differs largely from the prescribed value 1. In other words, the resulting fit does not change at all by including the constraint. I am guessing, that this usage is not supported. Is there an alternative approach to what I want to achieve within lmfit? If that requirement goes beyond what is possible with lmfit, do you have an idea about other available algorithms/approaches that could help me?
Any help is very appreciated!
Thank's so far and best wishes,
Florian