[SciPy-user] spline interpolation
robert.kern at gmail.com
Thu Nov 9 16:54:40 CST 2006
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.
In : from scipy import interpolate
In : interpolate?
Base Class: <type 'module'>
Wrappers around FITPACK functions:
splrep -- find smoothing spline given (x,y) points on curve.
splprep -- find smoothing spline given parametrically defined curve.
splev -- evaluate the spline or its derivatives.
splint -- compute definite integral of a spline.
sproot -- find the roots of a cubic spline.
spalde -- compute all derivatives of a spline at given points.
bisplrep -- find bivariate smoothing spline representation.
bisplev -- evaluate bivariate smoothing spline.
UnivariateSpline -- A more recent, object-oriented wrapper;
finds a (possibly smoothed) interpolating
BivariateSpline -- A more recent, object-oriented wrapper;
finds a interpolating spline for a
interp1d -- Create a class whose instances can linearly interpolate
to compute unknown values of a univariate function.
interp2d -- Create a class whose instances can interpolate
to compute unknown values of a bivariate function.
In : interpolate.UnivariateSpline?
Base Class: <type 'type'>
Univariate spline s(x) of degree k on the interval
[xb,xe] calculated from a given set of data points
Can include least-squares fitting.
splrep, splev, sproot, spint, spalde - an older wrapping of FITPACK
BivariateSpline - a similar class for bivariate spline interpolation
In : from numpy import *
In : x = linspace(0, 2, num=201)
In : x = linspace(0, 2, num=21)
In : y = sin(x*pi)
In : us = interpolate.UnivariateSpline(x, y, s=0.0)
In : x2 = linspace(0, 2, num=201)
In : y2 = us(x2)
"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