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@gmail.com>
To: scipy-user@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@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________
SciPy-User mailing list
SciPy-User@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user