SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Wolfgang K. <wke...@go...> - 2007年08月30日 08:35:13
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: Peter I. H. <pe...@gm...> - 2007年08月30日 11:21:42
On 8/30/07, Wolfgang Kerzendorf <wke...@go...> 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.
gnuplot can do that in a relatively painless way.
From: Steve S. <el...@gm...> - 2007年08月30日 13:48:41
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.
From: Christian M. <mee...@un...> - 2007年08月31日 07:29:12
Hoi,
There is still MPL's polyfit function and I have to admit that Steve
Schmerler's solution looks better that mine, but I've pasted a quick &
dirty solution here:
http://www.python-forum.de/topic-8363.html
It shows the use of polyfit as well as (almost) Steve's approach.
Further examples on linear regression and polynomal regression can be
found in http://matplotlib.sourceforge.net/users_guide_0.90.0.pdf
Also, you might want to have a closer look on the scipy web page:
http://www.scipy.org/ .
Cheers
Christian
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /