[SciPy-User] covariance mtrix returns inf

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Sat Feb 8 10:23:12 EST 2014


thank you guys!
the problem was that I mistake that b that should be a d!
but I am curious how do you discover it?it was the last thing at which I
was thinking about...

Gabriele


2014-02-07 23:42 GMT-05:00 Matt Newville <newville at cars.uchicago.edu>:

> Josef,
>
> On Fri, Feb 7, 2014 at 9:36 PM, <josef.pktd at gmail.com> wrote:
>
>>
>>
>> On Fri, Feb 7, 2014 at 9:58 PM, Gabriele Brambilla <
>> gb.gabrielebrambilla at gmail.com> wrote:
>>
>>> Hi,
>>> I am performing a fit with this code, and it fits well but at the end
>>> when I try to print the covariance matrix it returns to me inf:
>>>
>>
>> If you get an inf back, that means that the estimated covariance matrix
>> is singular or not (strictly) positive definite.
>> This can be because it's really singular, or because of numerical
>> problems, bad scaling or because the numerical derivatives are not very
>> good.
>>
>> If you have an analytical derivate it might help.
>>
>> Ecut looks much too large in scale compared to the other ones. Numerical
>> derivative might be useless if it doesn't scale correctly, which I think it
>> doesn't do.
>>
>> Josef
>>
>
>
> Since Gabriele is using (10**x0)/c  with x0 = log10(x) and x ~ 1e8 to 5e10
> (so that x0 is order 10),  I don't think the value of  Ecut (aka 'c') of
> order 1e8 is too large.  As Alex points out, the fact that 'd' is not
> actually used is a bigger problem for getting a finite covariance matrix,
> and a likely typo.
>
> But to be clear, curve_fit() uses leastsq() uses MINPACK's lmdif() which
> does scale the parameters to be of similar magnitude internally.  It is not
> uncommon to have parameter values differing by 10 orders of magnitude be
> fitted well and with best-fit values and covariance within machine
> precision of those when scaling the parameters by hand ahead of time.   In
> short, differences in scaling of parameters is not likely to cause a
> singular covariance matrix from leastsq()/curve_fit().
>
> --Matt
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140208/03aaf71c/attachment.html>


More information about the SciPy-User mailing list