> Programming Languages > Python
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on Python



Python - "Curve fitting" in Programming Languages


Old 05-08-2005   #1
..m ..ders..
 
Default Curve fitting

Hi,

I'd like to fit a curve (a rectangular hyperbola, in fact) to some data
points as part of a program i'm writing. Can anyone suggest a package
which would help me do this?

A bit of googling suggests that SciPy might be what i want. Does that
sound likely?

Thanks,
tom

--
OBEY GIANT

 
Old 05-08-2005   #2
..a.. ..war..
 
Default Re: Curve fitting

On 2005-05-08, Tom Anderson <twic@urchin.earth.li> wrote:

> I'd like to fit a curve (a rectangular hyperbola, in fact) to
> some data points as part of a program i'm writing. Can anyone
> suggest a package which would help me do this?


I use the LeastSquares function in Scientific Python:

http://starship.python.net/~hinsen/ScientificPython/

> A bit of googling suggests that SciPy might be what i want.
> Does that sound likely?


Sure.

--
Grant Edwards grante Yow! An air of FRENCH
at FRIES permeates my
visi.com nostrils!!
 
Old 05-09-2005   #3
..m ..ders..
 
Default Re: Curve fitting

On Sun, 8 May 2005, Grant Edwards wrote:

> On 2005-05-08, Tom Anderson <twic@urchin.earth.li> wrote:
>
> > I'd like to fit a curve (a rectangular hyperbola, in fact) to
> > some data points as part of a program i'm writing. Can anyone
> > suggest a package which would help me do this?

>
> I use the LeastSquares function in Scientific Python:
>
> http://starship.python.net/~hinsen/ScientificPython/


I'll check that out, cheers.

> > A bit of googling suggests that SciPy might be what i want. Does that
> > sound likely?

>
> Sure.


I ended up using scipy.optimize.minpack.leastsq, and it works brilliantly.
The interface is a bit awkward - it wants a function from a guess at the
parameters to a list of residuals; i'd rather give it a function from
parameters + x-coordinate to y-coordinate plus a set of points, and have
it work out the residuals for me - so i wrote a little wrapper to make it
suit me better, and now i'm cooking with gas. The only problem is that the
optimisation doesn't converge, but i think that's probably a bug in my
code!

tom

--
Punk's not ***ual, it's just aggression.

 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0