Skip to main content
`Ctrl`+`K`

# Interpolation (`scipy.interpolate`)

Sub-package for functions and objects used in interpolation.

See the user guide for recommendations on choosing a routine, and other usage details.

## Univariate interpolation

`make_interp_spline`(x, y[, k, t, bc_type, ...]) | Create an interpolating B-spline with specified degree and boundary conditions.
`CubicSpline`(x, y[, axis, bc_type, extrapolate]) | Piecewise cubic interpolator to fit values (C2 smooth).
`PchipInterpolator`(x, y[, axis, extrapolate]) | PCHIP shape-preserving interpolator (C1 smooth).
`Akima1DInterpolator`(x, y[, axis, method, ...]) | Akima "visually pleasing" interpolator (C1 smooth).
`FloaterHormannInterpolator`(points, values, *) | Floater-Hormann barycentric rational interpolator (C∞ smooth on real axis).
`BarycentricInterpolator`(xi[, yi, axis, wi, ...]) | Barycentric (Lagrange with improved stability) interpolator (C∞ smooth).
`KroghInterpolator`(xi, yi[, axis]) | Krogh interpolator (C∞ smooth).
`CubicHermiteSpline`(x, y, dydx[, axis, ...]) | Piecewise cubic interpolator to fit values and first derivatives (C1 smooth).

Low-level data structures for univariate interpolation:

`PPoly`(c, x[, extrapolate, axis]) | Piecewise polynomial in the power basis.
`BPoly`(c, x[, extrapolate, axis]) | Piecewise polynomial in the Bernstein basis.
`BSpline`(t, c, k[, extrapolate, axis]) | Univariate spline in the B-spline basis.

## Multivariate interpolation

Unstructured data

`LinearNDInterpolator`(points, values[, ...]) | Piecewise linear interpolator in N > 1 dimensions.
`NearestNDInterpolator`(x, y[, rescale, ...]) | Nearest-neighbor interpolator in N > 1 dimensions.
`CloughTocher2DInterpolator`(points, values[, ...]) | Piecewise cubic, C1 smooth, curvature-minimizing interpolator in N=2 dimensions.
`RBFInterpolator`(y, d[, neighbors, ...]) | Radial basis function interpolator in N ≥ 1 dimensions.

For data on a grid:

`RegularGridInterpolator`(points, values[, ...]) | Interpolator of specified order on a rectilinear grid in N ≥ 1 dimensions.

See also

`scipy.ndimage.map_coordinates`, An example wrapper for map_coordinates

Low-level data structures for tensor product polynomials and splines:

`NdPPoly`(c, x[, extrapolate]) | Piecewise tensor product polynomial
`NdBSpline`(t, c, k, *[, extrapolate]) | Tensor product spline object.

## 1-D spline smoothing and approximation

`make_lsq_spline`(x, y, t[, k, w, axis, ...]) | Create a smoothing B-spline satisfying the Least SQuares (LSQ) criterion.
`make_smoothing_spline`(x, y[, w, lam, axis]) | Create a smoothing B-spline satisfying the Generalized Cross Validation (GCV) criterion.
`make_splrep`(x, y, *[, w, xb, xe, k, s, t, nest]) | Create a smoothing B-spline function with bounded error, minimizing derivative jumps.
`make_splprep`(x, *[, w, u, ub, ue, k, s, t, nest]) | Create a smoothing parametric B-spline curve with bounded error, minimizing derivative jumps.
`generate_knots`(x, y, *[, w, xb, xe, k, s, nest]) | Generate knot vectors until the Least SQuares (LSQ) criterion is satified.

## Rational Approximation

`AAA`(x, y, *[, rtol, max_terms, clean_up, ...]) | AAA real or complex rational approximation.

## Interfaces to FITPACK routines for 1D and 2D spline fitting

This section lists wrappers for FITPACK functionality for 1D and 2D smoothing splines. In most cases, users are better off using higher-level routines listed in previous sections.

### 1D FITPACK splines

This package provides two sets of functionally equivalent wrappers: object-oriented and functional.

Functional FITPACK interface:

`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 a B-spline and all its derivatives at one point (or set of points) up to order k (the degree of the spline), being 0 the spline itself.
`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.

### 2D FITPACK splines

For data on a grid:

`RectBivariateSpline`(x, y, z[, bbox, kx, ky, ...]) | 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 (OOP interface):

`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.

For unstructured data (functional interface):

`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.
`interpn`(points, values, xi[, method, ...]) | Multidimensional interpolation on regular or rectilinear grids.
`griddata`(points, values, xi[, method, ...]) | Convenience function for interpolating unstructured data in multiple dimensions.
`barycentric_interpolate`(xi, yi, x[, axis, ...]) | Convenience function for barycentric interpolation.
`krogh_interpolate`(xi, yi, x[, der, axis]) | Convenience function for Krogh interpolation.
`pchip_interpolate`(xi, yi, x[, der, axis]) | Convenience function for pchip interpolation.
`Rbf`(*args, **kwargs) | Class for radial basis function interpolation of functions from N-D scattered data to an M-D domain (legacy).
`interp1d`(x, y[, kind, axis, copy, ...]) | Interpolate a 1-D function (legacy).
`interp2d`(x, y, z[, kind, copy, ...]) | Class for 2D interpolation (deprecated and removed)

See also

`scipy.ndimage.map_coordinates`, `scipy.ndimage.spline_filter`,