-
Notifications
You must be signed in to change notification settings - Fork 7
Cubic.Function.createCubicSplineInterpolator
commons-math-interpolation / Cubic / createCubicSplineInterpolator
function createCubicSplineInterpolator(xVals, yVals): UniFunction;Defined in: Cubic.ts:44
Returns a natural (also known as "free" or "unclamped") cubic spline interpolating function for a dataset.
For n interpolation points with x values x[0] < x[1] < ... < x[n-1] (the "knot points"),
the spline function consists of n - 1 cubic polynomials, one for each segment x[i] ... x[i+1].
The value of the spline function at a point x is computed by finding the segment i to which x belongs
and evaluating the polynomial of that segment at x - x[i].
The interpolating polynomials satisfy:
- The value of the spline function at each of the input x values equals the corresponding y value.
- Adjacent polynomials are equal through two derivatives at the knot points (i.e., adjacent polynomials "match up" at the knot points, as do their first and second derivatives).
- The second derivative is zero at the first and the last knot point ("natural" boundary condition).
Arguments outside the range of the knot points are extrapolated with the cubic polynomial
of the first or last segment. If the argument is NaN, the function returns NaN.
The passed arrays are not referenced by the returned function.
The cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires, Numerical Analysis, 4th Ed., 1989, PWS-Kent, ISBN 0-53491-585-X, pp 126-131.
ArrayLike<number>
The arguments of the interpolation points, in strictly increasing order. The values must be finite.
ArrayLike<number>
The values of the interpolation points.
A function which interpolates the dataset.
Error
If xVals and yVals have different lengths, if there are fewer than 3 points,
or if xVals contains non-finite values or is not strictly increasing.