[SciPy-User] Scipy fitting

josef.pktd@gmai... josef.pktd@gmai...
Thu Mar 1 10:55:54 CST 2012


On Thu, Mar 1, 2012 at 10:54 AM, Pierre Barthelemy <barthpi@gmail.com> wrote:
> Dear all,
>
> i am writing a program for data analysis. One of the functions of this
> program gives the possibility to fit the functions. I therefore use the
> recipe described in : http://www.scipy.org/Cookbook/FittingData under the
> section "Simplifying the syntax". This recipe make use of the
> function: scipy.optimize.leastsq.
>
>
> One thing that i would like to know is how can i get the error on the
> parameters ? From what i understood from the "Cookbook" page, and from the
> scipy manual
> (http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.leastsq.html#scipy.optimize.leastsq),
> the second argument returned by the leastsq function gives access to these
> errors.
> std_error=std(y-function(x))
> param_error=sqrt(diagonal(out[1])*std_error)

you are taking the sqrt twice numpy.std takes the sqrt of the variance
and then you take it again.

once is enough if I read the snippet correctly, you might also add a
ddof correction to std
(y - function(x)) should have also mean zero if a constant is included

?

Josef

>
> The param_errors that i get in this case are extremely small. Much smaller
> than what i expected, and much smaller than what i can get fitting the
> function with matlab. So i guess i made an error here.
>
> Can someone tell me how i should do to retrieve the parameter errors ?
>
> Bests,
>
> Pierre
>
>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list