[SciPy-user] spline interpolation

Robert Kern robert.kern at gmail.com
Thu Nov 9 17:19:28 CST 2006

Jordan Dawe wrote:
> Robert Kern wrote:
>> Jordan Dawe wrote:
>>> I've been looking at scipy's interpolation routines and I can't make
>>> heads or tails of them.  I just want to do a spline interp1d like matlab
>>> does.  Is there any way to do this?
>> I don't know exactly what features you want from Matlab's interp1d, but you
>> probably want scipy.interpolate.UnivariateSpline.
> I want a cubic spline fit that passes through every point it is fit to. 
> I haven't been able to figure out how to make UnivariateSpline do this;
> it goes near the points, but is not constrained to satisfy the points
> exactly.  Matlab does this by a series of piecewise spline
> interpolations that are continuous in the first two derivatives at each
> data point.

Did you see the example that I gave you? Passing s=0 as the smoothing parameter
makes the interpolant pass through the given data points. Alternatively,
InterpolatedUnivariateSpline will do this for you.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the SciPy-user mailing list