[SciPy-User] curve_fit cannot accept a function with list or array as parameters?
Spark Liang
sparkliang at gmail.com
Thu Jun 9 10:39:07 EDT 2011
Hi, I'm using scipy.optimize.curve_fit to fit two sets of data (x, y). But I
found that curve_fit cannot accept a function with list or numpy.ndarray as
parameters.
For example, one of my function is :
def testfunc(x, beta)
a = beta[0]
b = beta[1]
c = beta[2]
d = beta[3]
return a+b*x+c*x**2+d*x**4
In my program, I create the parameters guess: c = [1, 2, 3]. When I using
curve_fit as: popt, pcov = curve_fit(testfunc, x, y, p0=c). It threw the
errors: TypeError: testfunc() takes exactly 2 arguments (4 given).
How to resolve the problems ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110609/097836e2/attachment.html>
More information about the SciPy-User
mailing list