First, let me say, I don't know if there is code to do exactly what you want but here are my thoughts.

It sounds to me like you're asking for Lagrange polynomial fitting routines. Googling for "lagrange polynomial python" does return some code here: <http://www.stanford.edu/~sturdza/akimamod/akimamod.py>

Another possibility is the spline fitting routines in Scipy (scipy.interpolate). These may be appropriate if what you're really after is just a way to fit smooth functions through points. I've used the splrep and splev functions there successfully to fit spline functions through points. When I was looking for curve fitting routines recently, I also came across some more generalized curve fitting modules for Python but I can't recall where I think they were SWIG wrappers for a C library.

Also, look at this:

<http://www.scipy.org/site_content/remap?rmurl=http%3A//www.scipy.net/pipermail/scipy-user/2003-August/001864.html>

HTH,

regards,

Gary

## ···

----- Original Message -----

From: Jean-Baptiste Cazier <Jean-Baptiste.cazier@...15...>

Date: Fri, 19 Mar 2004 11:49:21 +0000

To: "Gary Ruben" <gazzar@...25...>, jdhunter@...8...

Subject: Re: [Matplotlib-users] Polyfit

Thanks to both of you. It worked just fine

I will push my luck and ask if any of you knows of a module to fit a piecewise polynomial to a list of (X,Y) points.

something like

p=piece-wiseFit([1,2,5,7,8],[3,4,2,5,5],2)

would return [[A0,B0,C0],[A1,B1,C1}[A2,B2,C2},[A3,B3,C3]}, coefficients for the 4 polynoms

A0+B0.X+C0.X.X

A1+B1.X+C1.X.X

A2+B2.X+C2.X.X

A3+B2.X+C3.X.XThis is a classic and I expect the code to be written somewhere, eventhough I could not find it even when I "Feel lucky" with Google.

<snip>

--

___________________________________________________________

Sign-up for Ads Free at Mail.com

http://promo.mail.com/adsfreejump.htm