PCHIP 1-d monotonic cubic interpolation
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
y : ndarray
axis : int, optional
extrapolate : bool, optional
|
---|
Notes
The first derivatives are guaranteed to be continuous, but the second derivatives may jump at x_k.
Preserves monotonicity in the interpolation data and does not overshoot if the data is not smooth.
Determines the derivatives at the points x_k, d_k, by using PCHIP algorithm:
Let m_k be the slope of the kth segment (between k and k+1) If m_k=0 or m_{k-1}=0 or sgn(m_k) != sgn(m_{k-1}) then d_k == 0 else use weighted harmonic mean:
w_1 = 2h_k + h_{k-1}, w_2 = h_k + 2h_{k-1} 1/d_k = 1/(w_1 + w_2)*(w_1 / m_k + w_2 / m_{k-1})
where h_k is the spacing between x_k and x_{k+1}.
Methods
__call__(x[, der, extrapolate]) | Evaluate the PCHIP interpolant or its derivative. |
derivative([der]) | Construct a piecewise polynomial representing the derivative. |