Interpolation (scipy.interpolate)¶
Sub-package for objects used in interpolation.
As listed below, this sub-package contains spline functions and classes, one-dimensional and multi-dimensional (univariate and multivariate) interpolation classes, Lagrange and Taylor polynomial interpolators, and wrappers for FITPACK and DFITPACK functions.
Univariate interpolation¶
interp1d(x, y[, kind, axis, copy, ...]) | Interpolate a 1-D function. |
BarycentricInterpolator(xi[, yi, axis]) | The interpolating polynomial for a set of points Constructs a polynomial that passes through a given set of points. |
KroghInterpolator(xi, yi[, axis]) | Interpolating polynomial for a set of points. |
PiecewisePolynomial(xi, yi[, orders, ...]) | Piecewise polynomial curve specified by points and derivatives This class represents a curve that is a piecewise polynomial. |
PchipInterpolator(x, y[, axis, extrapolate]) | PCHIP 1-d monotonic cubic interpolation. |
barycentric_interpolate(xi, yi, x[, axis]) | Convenience function for polynomial interpolation. |
krogh_interpolate(xi, yi, x[, der, axis]) | Convenience function for polynomial interpolation. |
piecewise_polynomial_interpolate(xi, yi, x) | Convenience function for piecewise polynomial interpolation. |
pchip_interpolate(xi, yi, x[, der, axis]) | Convenience function for pchip interpolation. |
Akima1DInterpolator(x, y[, axis]) | Akima interpolator Fit piecewise cubic polynomials, given vectors x and y. |
PPoly(c, x[, extrapolate, axis]) | Piecewise polynomial in terms of coefficients and breakpoints The polynomial in the ith interval is x[i] <= xp < x[i+1]:: S = sum(c[m, i] * (xp - x[i])**(k-m) for m in range(k+1)) where k is the degree of the polynomial. |
BPoly(c, x[, extrapolate, axis]) | Piecewise polynomial in terms of coefficients and breakpoints The polynomial in the i-th interval x[i] <= xp < x[i+1] is written in the Bernstein polynomial basis:: S = sum(c[a, i] * b(a, k; x) for a in range(k+1)) where k is the degree of the polynomial, and:: b(a, k; x) = comb(k, a) * t**k * (1 - t)**(k - a) with t = (x - x[i]) / (x[i+1] - x[i]). |
Multivariate interpolation¶
Unstructured data:
griddata(points, values, xi[, method, ...]) | Interpolate unstructured D-dimensional data. |
LinearNDInterpolator(points, values[, ...]) | Piecewise linear interpolant in N dimensions. |
NearestNDInterpolator(points, values) | Nearest-neighbour interpolation in N dimensions. |
CloughTocher2DInterpolator(points, values[, tol]) | Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D. |
Rbf(*args) | A class for radial basis function approximation/interpolation of n-dimensional scattered data. |
interp2d(x, y, z[, kind, copy, ...]) | Interpolate over a 2-D grid. |
For data on a grid:
interpn(points, values, xi[, method, ...]) | Multidimensional interpolation on regular grids. |
RegularGridInterpolator(points, values[, ...]) | Interpolation on a regular grid in arbitrary dimensions The data must be defined on a regular grid; the grid spacing however may be uneven. |
RectBivariateSpline(x, y, z[, bbox, kx, ky, s]) | Bivariate spline approximation over a rectangular mesh. |
See also
scipy.ndimage.interpolation.map_coordinates
1-D Splines¶
UnivariateSpline(x, y[, w, bbox, k, s, ext, ...]) | One-dimensional smoothing spline fit to a given set of data points. |
InterpolatedUnivariateSpline(x, y[, w, ...]) | One-dimensional interpolating spline for a given set of data points. |
LSQUnivariateSpline(x, y, t[, w, bbox, k, ...]) | One-dimensional spline with explicit internal knots. |
Functional interface to FITPACK functions:
splrep(x, y[, w, xb, xe, k, task, s, t, ...]) | Find the B-spline representation of 1-D curve. |
splprep(x[, w, u, ub, ue, k, task, s, t, ...]) | Find the B-spline representation of an N-dimensional curve. |
splev(x, tck[, der, ext]) | Evaluate a B-spline or its derivatives. |
splint(a, b, tck[, full_output]) | Evaluate the definite integral of a B-spline. |
sproot(tck[, mest]) | Find the roots of a cubic B-spline. |
spalde(x, tck) | Evaluate all derivatives of a B-spline. |
splder(tck[, n]) | Compute the spline representation of the derivative of a given spline :Parameters: tck : tuple of (t, c, k) Spline whose derivative to compute n : int, optional Order of derivative to evaluate. |
splantider(tck[, n]) | Compute the spline for the antiderivative (integral) of a given spline. |
insert(x, tck[, m, per]) | Insert knots into a B-spline. |
2-D Splines¶
For data on a grid:
RectBivariateSpline(x, y, z[, bbox, kx, ky, s]) | Bivariate spline approximation over a rectangular mesh. |
RectSphereBivariateSpline(u, v, r[, s, ...]) | Bivariate spline approximation over a rectangular mesh on a sphere. |
For unstructured data:
BivariateSpline | Base class for bivariate splines. |
SmoothBivariateSpline(x, y, z[, w, bbox, ...]) | Smooth bivariate spline approximation. |
SmoothSphereBivariateSpline(theta, phi, r[, ...]) | Smooth bivariate spline approximation in spherical coordinates. |
LSQBivariateSpline(x, y, z, tx, ty[, w, ...]) | Weighted least-squares bivariate spline approximation. |
LSQSphereBivariateSpline(theta, phi, r, tt, tp) | Weighted least-squares bivariate spline approximation in spherical coordinates. |
Low-level interface to FITPACK functions:
bisplrep(x, y, z[, w, xb, xe, yb, ye, kx, ...]) | Find a bivariate B-spline representation of a surface. |
bisplev(x, y, tck[, dx, dy]) | Evaluate a bivariate B-spline and its derivatives. |
Additional tools¶
lagrange(x, w) | Return a Lagrange interpolating polynomial. |
approximate_taylor_polynomial(f, x, degree, ...) | Estimate the Taylor polynomial of f at x by polynomial fitting. |
See also
scipy.ndimage.interpolation.map_coordinates, scipy.ndimage.interpolation.spline_filter, scipy.signal.resample, scipy.signal.bspline, scipy.signal.gauss_spline, scipy.signal.qspline1d, scipy.signal.cspline1d, scipy.signal.qspline1d_eval, scipy.signal.cspline1d_eval, scipy.signal.qspline2d, scipy.signal.cspline2d.
Functions existing for backward compatibility (should not be used in new code):
ppform(coeffs, breaks[, fill, sort]) | Deprecated piecewise polynomial class. |
spleval(xck, xnew[, deriv]) | Evaluate a fixed spline represented by the given tuple at the new x-values The xj values are the interior knot points. |
spline(xk, yk, xnew[, order, kind, conds]) | Interpolate a curve at new points using a spline fit :Parameters: xk, yk : array_like The x and y values that define the curve. |
splmake(xk, yk[, order, kind, conds]) | Return a representation of a spline given data-points at internal knots :Parameters: xk : array_like The input array of x values of rank 1 yk : array_like The input array of y values of rank N. |
spltopp(xk, cvals, k) | Return a piece-wise polynomial object from a fixed-spline tuple. |
pchip | PCHIP 1-d monotonic cubic interpolation. |