Curve fitting

Tom Anderson twic at urchin.earth.li
Sun May 8 18:24:41 EDT 2005


On Sun, 8 May 2005, Grant Edwards wrote:

> On 2005-05-08, Tom Anderson <twic at 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.




More information about the Python-list mailing list