Skip to content

Linear.Function.createLinearInterpolator

Christian d'Heureuse edited this page Sep 25, 2026 · 1 revision

commons-math-interpolation / Linear / createLinearInterpolator

Function: createLinearInterpolator()

function createLinearInterpolator(xVals, yVals): UniFunction;

Defined in: Linear.ts:30

Returns a linear interpolating function for a dataset.

Arguments outside the range of the interpolation points are extrapolated with the straight line 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.

Parameters

xVals

ArrayLike<number>

The arguments of the interpolation points, in strictly increasing order. The values must be finite.

yVals

ArrayLike<number>

The values of the interpolation points.

Returns

UniFunction

A function which interpolates the dataset.

Throws

Error If xVals and yVals have different lengths, if there are fewer than 2 points, or if xVals contains non-finite values or is not strictly increasing.

Clone this wiki locally