Interpolation (scipy.interpolate)#

Sub-package for objects used in interpolation.

As listed below, this sub-package contains spline functions and classes, 1-D and multidimensional (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

KroghInterpolator(xi, yi[, axis])

Interpolating polynomial for a set of points.

barycentric_interpolate(xi, yi, x[, axis])

Convenience function for polynomial interpolation.

krogh_interpolate(xi, yi, x[, der, axis])

Convenience function for polynomial interpolation.

pchip_interpolate(xi, yi, x[, der, axis])

Convenience function for pchip interpolation.

CubicHermiteSpline(x, y, dydx[, axis, ...])

Piecewise-cubic interpolator matching values and first derivatives.

PchipInterpolator(x, y[, axis, extrapolate])

PCHIP 1-D monotonic cubic interpolation.

Akima1DInterpolator(x, y[, axis])

Akima interpolator

CubicSpline(x, y[, axis, bc_type, extrapolate])

Cubic spline data interpolator.

PPoly(c, x[, extrapolate, axis])

Piecewise polynomial in terms of coefficients and breakpoints

BPoly(c, x[, extrapolate, axis])

Piecewise polynomial in terms of coefficients and breakpoints.

Multivariate interpolation#

Unstructured data:

griddata(points, values, xi[, method, ...])

Interpolate unstructured D-D data.

LinearNDInterpolator(points, values[, ...])

Piecewise linear interpolant in N > 1 dimensions.

NearestNDInterpolator(x, y[, rescale, ...])

NearestNDInterpolator(x, y).

CloughTocher2DInterpolator(points, values[, ...])

CloughTocher2DInterpolator(points, values, tol=1e-6).

RBFInterpolator(y, d[, neighbors, ...])

Radial basis function (RBF) interpolation in N dimensions.

Rbf(*args, **kwargs)

A class for radial basis function interpolation of functions from N-D scattered data to an M-D domain.

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 or rectilinear grids.

RegularGridInterpolator(points, values[, ...])

Interpolation on a regular or rectilinear grid in arbitrary dimensions.

RectBivariateSpline(x, y, z[, bbox, kx, ky, s])

Bivariate spline approximation over a rectangular mesh.

Tensor product polynomials:

NdPPoly(c, x[, extrapolate])

Piecewise tensor product polynomial

1-D Splines#

BSpline(t, c, k[, extrapolate, axis])

Univariate spline in the B-spline basis.

make_interp_spline(x, y[, k, t, bc_type, ...])

Compute the (coefficients of) interpolating B-spline.

make_lsq_spline(x, y, t[, k, w, axis, ...])

Compute the (coefficients of) an LSQ B-spline.

Functional interface to FITPACK routines:

splrep(x, y[, w, xb, xe, k, task, s, t, ...])

Find the B-spline representation of a 1-D curve.

splprep(x[, w, u, ub, ue, k, task, s, t, ...])

Find the B-spline representation of an N-D 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 between two given points.

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

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.

Object-oriented FITPACK interface:

UnivariateSpline(x, y[, w, bbox, k, s, ext, ...])

1-D smoothing spline fit to a given set of data points.

InterpolatedUnivariateSpline(x, y[, w, ...])

1-D interpolating spline for a given set of data points.

LSQUnivariateSpline(x, y, t[, w, bbox, k, ...])

1-D spline with explicit internal knots.

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.

pade(an, m[, n])

Return Pade approximation to a polynomial as the ratio of two polynomials.

pchip is an alias of PchipInterpolator for backward compatibility (should not be used in new code).