[SciPy-User] [SciPy-user] Covariance matrix
Charles R Harris
Sat Feb 11 20:47:26 CST 2012
On Fri, Feb 10, 2012 at 9:11 AM, suzana8447 <firstname.lastname@example.org> wrote:
> Hello every body,
> I am using least square fit to fit some function to a given data. The fit
> perfect with leastsq. Now, I need to calculate the covariance matrix
> the diagonal terms represent the variances for the parameters.
> I need to know, if possible, how to extract the covariance matrix from
> leastsq. If there is no way to extract it, Are there any good methods that
> can be used to calculate the covariance matrix with high precision?
If you pass the optional argument full_output=1 when calling leastsq the
(scaled) covariance matrix will be returned in the slot after the solution.
It needs to be multiplied by an estimated measurement variance determined
from the residuals or by some other method. The documentation isn't quite
right on that score, it says standard deviation. The computation of the
covariance probably isn't the best numerically as its triangular factors
are multiplied before inversion, rather than vice-verse. Patches welcome ;)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User