[SciPy-user] incorrect variance in optimize.curvefit and leastsq

Travis E. Oliphant oliphant@enthought....
Thu Feb 12 22:09:19 CST 2009


josef.pktd@gmail.com wrote:
> I just saw the new optimize.curvefit which provides a wrapper around
> optimize.leastsq
>
> optimize.leastsq provides the raw covariance matrix (cov_x). As I
> mentioned once on the mailing list, this is not the covariance matrix
> of the parameter estimates. To get those, the raw covariance matrix
> has to be multiplied by the standard error of the residual. So, the
> docstring in optimize.curvefit doesn't correspond to the actual
> calculation.
>   
Thank you for the clarification.   I had forgotten your earlier valid 
concerns.   Help fixing the docstring is appreciated.    If you can 
figure out how to improve the code, that is even better.   I think it is 
good to at least report the cov, but the docstring should not mislead.
>
> The first parameter is not exactly high precision.
>
> The second problem is that, in weighted least squares, the calculation
> of the standard deviation of the parameter estimates has to take the
> weights into account. (But I don't have the formulas right now.)
>   
> I was looking at this to provide a general non-linear least squares
> class in stats. But for several calculation, the Jacobian would be
> necessary. optimize.leastsq only provides cov_x, but I was wondering
> whether the Jacobian can be calculated from the return of the minpack
> functions in optimize.leastsq, but I didn't have time to figure this
> out.
>   
I'm not sure, but it might be.    I would love to spend time on this, 
but don't have it.   If somebody else can pick up, that would be great. 

-Travis

-- 

Travis Oliphant
Enthought, Inc.
(512) 536-1057 (office)
(512) 536-1059 (fax)
http://www.enthought.com
oliphant@enthought.com



More information about the SciPy-user mailing list