bundles / scipy latest / scipy / interpolate / _polyint / KroghInterpolator
class
scipy.interpolate._polyint:KroghInterpolator
Signature
class KroghInterpolator ( xi , yi , axis = 0 ) Members
Summary
Krogh interpolator (C∞ smooth).
Extended Summary
The polynomial passes through all the pairs (xi, yi). One may additionally specify a number of derivatives at each point xi; this is done by repeating the value xi and specifying the derivatives as successive yi values.
Allows evaluation of the polynomial and all its derivatives. For reasons of numerical stability, this function does not compute the coefficients of the polynomial, although they can be obtained by evaluating all the derivatives.
Parameters
xi: array_like, shape (npoints, )Known x-coordinates. Must be sorted in increasing order.
yi: array_like, shape (..., npoints, ...)Known y-coordinates. When an xi occurs two or more times in a row, the corresponding yi's represent derivative values. The length of
yialong the interpolation axis must be equal to the length ofxi. Use theaxisparameter to select the correct axis.axis: int, optionalAxis in the
yiarray corresponding to the x-coordinate values. Defaults toaxis=0.
Notes
Be aware that the algorithms implemented here are not necessarily the most numerically stable known. Moreover, even in a world of exact computation, unless the x coordinates are chosen very carefully - Chebyshev zeros (e.g., cos(i*pi/n)) are a good choice - polynomial interpolation itself is a very ill-conditioned process due to the Runge phenomenon. In general, even with well-chosen x values, degrees higher than about thirty cause problems with numerical instability in this code.
Based on [1].
Examples
To produce a polynomial that is zero at 0 and 1 and has derivative 2 at 0, callfrom scipy.interpolate import KroghInterpolator
✓KroghInterpolator([0,0,1],[0,2,0])
✗import numpy as np rng = np.random.default_rng() xi = np.linspace(0, 1, 5) yi, ypi = rng.random((2, 5)) xi_k, yi_k = np.repeat(xi, 2), np.ravel(np.dstack((yi,ypi)))✓
KroghInterpolator(xi_k, yi_k)
✗KroghInterpolator([0,1],[[2,3],[4,5]])
✗Aliases
-
scipy.interpolate.KroghInterpolator