Skip to content

BasicInterpolators.Function.getFallbackInterpolationMethod

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

commons-math-interpolation / BasicInterpolators / getFallbackInterpolationMethod

Function: getFallbackInterpolationMethod()

function getFallbackInterpolationMethod(interpolationMethod, n): BasicInterpolationMethod;

Defined in: BasicInterpolators.ts:68

Degrades an interpolation method when there are too few points for it.

  • "akima" with fewer than 5 points is replaced by "cubic".
  • "cubic" with fewer than 3 points is replaced by "linear".
  • Any method with fewer than 2 points is replaced by "nearestNeighbor". The resulting function returns the y value of the single point, or NaN if there are no points.

The rules are applied one after the other, so e.g. "akima" with 2 points results in "linear".

Parameters

interpolationMethod

BasicInterpolationMethod

The requested interpolation method.

n

number

The number of points.

Returns

BasicInterpolationMethod

The interpolation method that can be used for n points.

Clone this wiki locally