[SciPy-user] Error estimates with leastsq?

josef.pktd@gmai... josef.pktd@gmai...
Wed Jun 3 21:43:52 CDT 2009


On Wed, Jun 3, 2009 at 10:12 PM, Joseph Smidt <josephsmidt@gmail.com> wrote:
> Hello,
>
>    I am trying to best fit data with theory using leastsq.  It works,
> in that the best fit curve fits the data fairly well.  I was wondering
> how I could find the error bars on the parameters.
>
>    Is this what cov_x is for that leastsq returns?  (See
> http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.leastsq.html#scipy.optimize.leastsq)
>  What is meant by "estimate of the jacobian around the solution"?  Is
> this related to the error bars?  It says "see curve_fit", but I
> couldn't find that page.
>
> For example, for output I get the best fit parameters are: [
> 10.8138327 ,  25.18203823] with cov_x = [[  773.42733539,
> -1791.83769517],
>       [-1791.83769517,  5203.77670479]]
>
>  Is this saying the best fit for parameter 1 is 10.81 +/- sqrt(773)
> and for parameter 2 = 25.18 +/- sqrt(5203)?   Thanks.


No, cov_x is not the correct covariance matrix for the parameter
estimates. It needs to be multiplied by the SSE.

curvefit source is here:
http://projects.scipy.org/scipy/browser/trunk/scipy/optimize/minpack.py#L331

or try
>>> from scipy import optimize
>>> help(optimize.curve_fit)

You can also look for the discussion 4 months ago (Feb 12 scipy-user)
when curve_fit got introduced and we were checking the correct
normalizations.

Josef


More information about the SciPy-user mailing list