{ } Raw JSON

bundles / scipy latest / scipy / interpolate / _cubic / PchipInterpolator

class

scipy.interpolate._cubic:PchipInterpolator

source: /scipy/interpolate/_cubic.py :172

Signature

class   PchipInterpolator ( x y axis = 0 extrapolate = None )

Members

Summary

PCHIP shape-preserving interpolator (C1 smooth).

Extended Summary

x and y are arrays of values used to approximate some function f, with y = f(x). The interpolant uses monotonic cubic splines to find the value of new points. (PCHIP stands for Piecewise Cubic Hermite Interpolating Polynomial).

Parameters

x : ndarray, shape (npoints, )

A 1-D array of monotonically increasing real values. x cannot include duplicate values (otherwise f is overspecified)

y : ndarray, shape (..., npoints, ...)

An N-D array of real values. y's length along the interpolation axis must be equal to the length of x. Use the axis parameter to select the interpolation axis.

axis : int, optional

Axis in the y array corresponding to the x-coordinate values. Defaults to axis=0.

extrapolate : bool, optional

Whether to extrapolate to out-of-bounds points based on first and last intervals, or to return NaNs.

Methods

__call__
derivative
antiderivative
integrate
solve
roots

Notes

The interpolator preserves monotonicity in the interpolation data and does not overshoot if the data is not smooth.

The first derivatives are guaranteed to be continuous, but the second derivatives may jump at .

Determines the derivatives at the points , , by using PCHIP algorithm [1].

Let , and are the slopes at internal points . If the signs of and are different or either of them equals zero, then . Otherwise, it is given by the weighted harmonic mean

where and .

The end slopes are set using a one-sided scheme [2].

Array API Standard Support

PchipInterpolator has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ⛔                   
PyTorch               ✅                     ⛔                   
JAX                   ⚠️ no JIT
Dask                  ⛔                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

See also

Akima1DInterpolator

Akima 1D interpolator.

CubicHermiteSpline

Piecewise-cubic interpolator.

CubicSpline

Cubic spline data interpolator.

PPoly

Piecewise polynomial in terms of coefficients and breakpoints.

Aliases

  • scipy.interpolate.PchipInterpolator

Referenced by