[SciPy-User] Revisit Unexpected covariance matrix from scipy.optimize.curve_fit
Pierre Barbier de Reuille
Fri Feb 22 10:04:43 CST 2013
As far as I understand the documentation, the `sigma` parameter is only
used as weights for the least-square problem. It only *supposed* to be the
variance of the data on each of the y data points, and not the variance of
ydata as a whole.
So in your example, the specification of `sigma` is incorrect (1 value
instead of a N-length sequence). You can try to input a ramp (i.e.
range(1,len(yn)+1) and you will see a big difference this time (but of
course, this would be incorrect).
Barbier de Reuille Pierre
On 22 February 2013 16:41, Tom Aldcroft <email@example.com>wrote:
> In Aug 2011 there was a thread [Unexpected covariance matrix from
> where Christoph Deil reported that "scipy.optimize.curve_fit returns
> parameter errors that don't scale with sigma, the standard deviation
> of ydata, as I expected." Today I independently came to the same
> This thread generated some discussion but seemingly no agreement that
> the covariance output of `curve_fit` is not what would be expected. I
> think the discussion wasn't as focused as possible because the example
> was too complicated. With that I provide here about the simplest
> possible example, which is fitting a constant to a constant dataset,
> aka computing the mean and error on the mean. Since we know the
> answers we can compare the output of `curve_fit`.
> To illustrate things more easily I put the examples into an IPython
> notebook which is available at:
> This was run using scipy 0.11.0 by the way. Any further discussion on
> this topic to come to an understanding of the covariance output from
> `curve_fit` would be appreciated.
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User