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<http://www.scipy.org/Cookbook/FittingData> under the section "Simplifying the syntax". The code looks like this: class Parameter: def __init__(self, value): self.value = value self.fixed=False def set(self, value): if not self.fixed: self.value = value def __call__(self): return self.value def fit(function, parameters, y, x = None): def f(params): i = 0 for p in parameters: p.set(params[i]) i += 1 return y - function(x) if x is None: x = arange(y.shape[0]) p = [param() for param in parameters] out=optimize.leastsq(f, p, full_output=1) 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.h...), 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) 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
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 followed the recipe described in : http://www.scipy.org/Cookbook/FittingData<http://www.scipy.org/Cookbook/FittingData> under the section "Simplifying the syntax". To fit, i use the function: out=optimize.leastsq(f, p, full_output=1) where f is my function and p a list of parameters. 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.h...), 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) 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 PS: i got the impression something went wrong with my previous message, sorry for that.
Sorry I can't help, but I'd just suggest to post this on the scipy mailing list as you may get more replies there. -=- Olivier Le 1 mars 2012 10:24, Pierre Barthelemy <barthpi@gmail.com> a écrit :
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 followed the recipe described in : h*MailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "www.scipy.org" *ttp://www.scipy.org/Cookbook/FittingData<http://www.scipy.org/Cookbook/FittingData> under the section "Simplifying the syntax".
To fit, i use the function:
out=optimize.leastsq(f, p, full_output=1)
where f is my function and p a list of parameters.
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.h...), 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)
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
PS: i got the impression something went wrong with my previous message, sorry for that.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Thu, Mar 1, 2012 at 10:39 AM, Olivier Delalleau <shish@keba.be> wrote:
Sorry I can't help, but I'd just suggest to post this on the scipy mailing list as you may get more replies there.
-=- Olivier
Le 1 mars 2012 10:24, Pierre Barthelemy <barthpi@gmail.com> a écrit :
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 followed the recipe described in : hMailScanner soupçonne le lien suivant d'être une tentative de fraude de la part de "www.scipy.org" ttp://www.scipy.org/Cookbook/FittingData under the section "Simplifying the syntax".
To fit, i use the function:
out=optimize.leastsq(f, p, full_output=1)
where f is my function and p a list of parameters.
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.h...), 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)
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
PS: i got the impression something went wrong with my previous message, sorry for that.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
josef.pktd@gmail.com -
Olivier Delalleau -
Pierre Barthelemy