[SciPy-user] cubic splines in scipy

Andrew Straw strawman at astraw.com
Sat Jan 28 16:53:49 CST 2006


(Warning: non math guru alert.)

I'm looking to do 1D interpolation using cubic splines:
http://mathworld.wolfram.com/CubicSpline.html That page has a 2D
picture, but the math is for 1D. The important bit for me is that
interpolated curve passes through the control points and the whole thing
is continuously differentiable.

I can see a few hints toward what I want to do in scipy:
scipy.signal.cspline1d and various spline routines in scipy.interpolate.
Unfortunately, cspline1d doesn't seem to be tied to anything I can use
to interpolate with and the things in scipy.interpolate don't seem to be
cubic splines -- I desire my interpolated trajectory to pass through the
control points. Can anyone point me to anything in scipy that allows
cubic spline interpolation, including the interpolated values passing
through the control points?

According to the MathWorld page cited above, I thought the attached code
would work (not optimized for speed, obviously), but it doesn't
interpolate well. I guess from this that scipy.signal.cspline1d isn't
doing exactly what I think it's doing. Or perhaps my code is wrong?

(For what it's worth, I need to interpolate discretely sampled data from
a discrete-time simulation that I then want to use as forcing functions
for use in a scipy ODE solver. So, my discretely sampled data contain no
noise and I don't want to smooth them, I'm just looking for intermediate
values that are continuously differentiable.)

Thanks in advance for any help,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_cubic.py
Type: text/x-python
Size: 1197 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20060128/dbecc5f0/test_cubic-0001.py

More information about the SciPy-user mailing list