Wolfgang Kerzendorf wrote: > I know this is not completely matplotlib related but perhaps you can > help me none the less: > I want to fit a curve to a set of data. It's a very easy curve: y=ax+b. > But I want errors for a and b and not only the rms. Is that possible. > What tasks do you recommend for doing that. > Thanks in advance > Wolfgang >
from http://mathworld.wolfram.com/LeastSquaresFitting.html: (but here: y = a*x+b, so a <-> b)! For the standard errors on a and b: n = float(len(x)) xm = mean(x) ym = mean(y) SSxx = dot(x,x) - n*xm**2.0 SSyy = dot(y,y) - n*ym**2.0 SSxy = dot(x,y) - n*xm*ym r = sqrt(SSxy**2.0 / (SSxx*SSyy)) s = sqrt((SSyy - (SSxy**2.0 / SSxx)) / (n-2.0)) sea = s / sqrt(SSxx) seb = s * sqrt(1.0/n + (xm**2.0 / SSxx)) The values of sea, seb agree with gnuplot's "Asymptotic Standard Error". -- cheers, steve Random number generation is the art of producing pure gibberish as quickly as possible. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users