[SciPy-User] is it possible to constrain the scipy.optimize.curve_fit function?
David Baddeley
david_baddeley at yahoo.com.au
Wed May 16 17:02:30 EDT 2012
The quick and dirty way is to do a variable substitution with the square of your parameter and fit, e.g. r + (a**2)*np.power(x, -b**2)
You can take the sqrt of the parameters later.
________________________________
From: servant mathieu <servant.mathieu at gmail.com>
To: scipy-user at scipy.org
Sent: Thursday, 17 May 2012 4:20 AM
Subject: [SciPy-User] is it possible to constrain the scipy.optimize.curve_fit function?
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,
Mathieu
_______________________________________________
SciPy-User mailing list
SciPy-User at scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120516/814eb04d/attachment.html>
More information about the SciPy-User
mailing list