Comparison¶
Here are some notes on spline functionality provided by other software.
In Python, SciPy’s interpolate module provides:
A number of wrappers around the fortran
fitpack
library by P. Dierckx:
splrep
andsplev
, which are thin wrappers around fortran functions by the same name. These functions construct the knot and coefficient sequence given a sequence of 1-D data and evaluate the B-splines given the knot and coefficient sequence. The fortran supports only a single set of coefficients, but the python wrapper will recursively call itself to evaluate using multiple coefficients. There are a number of other functional wrappers around univariate spline functions fromfitpack
.- There are also class-based wrappers for
fitpack
’s univariate splines:UnivariateSpline
,InterpolatedUnivariateSpline
, andLSQUnivariateSpline
.- Functional interface to
bisplrep
andbisplev
. Note thatbisplrep
can construct a B-spline that interpolates data on an unstructured grid.- Class-based interfaces for
fitpack
’s bivariate splines,RectBivariateSpline
,RectSphereBivariateSpline
,SmoothBivariateSpline
,SmoothSphereBivariateSpline
,LSQBivariateSpline
,LSQSphereBivariateSpline
.- An interface to
fitpack
’s bivariate splines is also provided ininterp2d
.
BSpline
, which is a new implementation using Cython and C for 1-D splines. This supports a Cython-loop over sets of coefficients. This is also wrapped byinterp1d
.
BPoly
is a pure Python implementation for 1-D splines.A number of interfaces for N-D unevenly spaced data limited to
k=0
(nearest neighbor) ork=1
(piecewise linear) interpolation:
RegularGridInterpolator
has a pure python implementation for linear and nearest-neighbor interpolationgriddata
which wraps Cython implmentationsLinearNDInterpolator
andNearestNDInterpolator
interpn
which usesRegularGridInterpolator
for N-D orRectBivariateSpline
for 2-D interpolation.
ndimage
, which provides N-D interpolation of any order if the spacing in each dimension is uniform.
There are also other interpolation methods using other basis functions.
- In Matlab, these spline interpolations are implemented in:
- Spline Toolbox, which also includes regression using splines
interpn
,interp{1|2|3}
, andspline
(an alias for interp1) which together may be a replacement for the spline toolbox.
Spline Toolbox was written by Carl de Boor, who wrote many seminal articles and books on splines. Many commonly used algorithms for evaluating the basis functions and computing the coefficients and knots from data were developed by de Boor.