[SciPy-User] Problem using curve_fit function

Gökhan Sever gokhansever@gmail....
Wed Apr 21 01:21:31 CDT 2010


On Wed, Apr 21, 2010 at 12:21 AM, Gökhan Sever <gokhansever@gmail.com>wrote:

> Hello,
>
> I want to fit a curve to my simple data using the scipy.optimize.curve_fit
> function. Here how I define my arrays and fit function:
>
>     tfit = np.array([463.8, 0.5])
>     weights = np.ones(16, dtype='float64')
>     popt, pcov = curve_fit(my_func, array([16 elements x]), array([16
> elements y]), p0=tfit, sigma=weights)
>
>    def my_func(x, a, b):
>        return a*x**b
>
> I am following the documentation and example from
> http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html
>
> When I run the script, this part of the code produces a RunTimeError as
> indicated below:
>
>   File "/usr/lib/python2.6/site-packages/scipy/optimize/minpack.py", line
> 430, in curve_fit
>     raise RuntimeError(msg)
> RuntimeError: Optimal parameters not found: The cosine of the angle between
> func(x) and any column of the
>   Jacobian is at most 0.000000 in absolute value
>
> Do you have any ideas how to fix this issue and estimate optimum parameters
> out of my data?
>
> Thank you.
>
> --
> Gökhan
>

Here comes a quick self-reply:

Converting x and y arrays using np.asarray to float64 resolved the problem.

-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100421/e6c3cb1d/attachment.html 


More information about the SciPy-User mailing list