Hi,

I'm a little bit desperated. I googled for days to find an appropriate way

to calculate the absolute errors of parameters of non-linear fits. I found

different sites which suggest different, sometimes more or less similar

ways. But the results don't make sense. Here is a simple example:

from pylab import *

from scipy.optimize import curve_fit

def f(x,a,b):

return a*x+b

def fit(n=1000):

x,y=array([0,1,1]),array([1,2,4])

xf=[(min(x)+i*(max(x)-min(x))/float(n)) for i in range(0,int(n)+1)]

a,acov=curve_fit(f,x,y)

yf=[f(*tuple([i]+list(a))) for i in xf]

meansq=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)) for i in

range(0,len(x))])

redchi2=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)-len(a)) for i in

range(0,len(x))])

print 'standard dev:',sqrt(diag(acov))

print 'abs. meansq err.:',[acov[i][i]*sqrt(meansq) for i in

range(0,len(a))]

print 'abs. reduced meansq err.:',[acov[i][i]*sqrt(redchi2) for i in

range(0,len(a))]

fit()

I included 3 ways I found. The used arrays have 3 points, where for x=1 I

give 2 different y values. I would say,

a=2+/-1, b=1+/-0,

but no way yields to a similar result! How can I trust this function on more

complicated, really non-linear functions? Or is simply this example wrong?

Or are the methods not right?

I'm very thankful for any help!

Best regards,

André

## ···

--

View this message in context: http://old.nabble.com/absolute-error-of-curve-fit-parameters-tp32269685p32269685.html

Sent from the matplotlib - users mailing list archive at Nabble.com.