# [SciPy-user] Error in nonlinear least squares fit analysis

Roger Fearick Roger.Fearick@uct.ac...
Thu Sep 18 03:44:54 CDT 2008

```Hi all,

I'm an occasional user of scipy but this is one of the things I have
looked at, so I thought I'd better delurk and comment.

> This sounds like what I'm looking for -- just to make sure I'm looking
> at this right, the diagonal terms of the covariance matrix represent
> the variance in the parameters? I.e., for the error in a exponential
> fit y = coef[0]*e**(coef[1]*x), the error for coef[1] would be the
s> qrt of leastsq's cov_x[1][1], and I can return the best value of the
p> arameter as:

> coef[1] +/- sqrt(cov_x[1][1]) ?

> This may be a simple question, but I'm having great difficulty finding
> a source that explains the meaning of all of these various matricies
> :)

It's not a simple question, actually.
The gory details are in something like Numerical Recipes -- in latest (3rd) edition
Sect 15.6 (15.6.5).

There is a scipy example at www.phy.uct.ac.za/courses/python/examples/moreexamples.html
(Non-linear least squares fit) which shows how to process the output of leastsq.

Roger.

--
Roger Fearick
Department of Physics
University of Cape Town

```