[SciPy-User] is it possible to constrain the scipy.optimize.curve_fit function?
Thu May 17 04:51:05 CDT 2012
there was a big discussion about this a while ago, and the short answer is,
currently there is no 'automatic' way to do it. However, in your case,
it's pretty easy.
def func (x, a,b, r):
a = abs(a)
b = abs(b)
r = abs(r)
return r + a*np.power(x,-b)
And that will do the trick. If you need to more complex boundaries, you
can simply use a combination of period functions with a given amplitude or
what have you. Alternatively, there are *a lot* of optimization libraries
available for Python that are not a part of scipy that offer the
possibility to specify boundaries.
Date: Wed, 16 May 2012 18:20:27 +0200
> From: servant mathieu <firstname.lastname@example.org>
> Subject: [SciPy-User] is it possible to constrain the
> scipy.optimize.curve_fit function?
> To: email@example.com
> Content-Type: text/plain; charset="iso-8859-1"
> Dear scipy users,
> I'm trying to fit to data a power law of the form :
> def func (x, a,b, r):
> return r + a*np.power(x,-b)
> I would like to constrain the curve_fit routine to only allow
> positive parameter values. How is it possible to do so?
> Kind regards,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User