Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Curve fitting (http://www.velocityreviews.com/forums/t344656-curve-fitting.html)

Tom Anderson 05-08-2005 11:50 AM

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


Grant Edwards 05-08-2005 05:10 PM

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!!

Tom Anderson 05-08-2005 10:24 PM

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 sexual, it's just aggression.



All times are GMT. The time now is 01:43 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.