Function csplineMonot

  • Returns a monotonous cubic spline interpolation function for given pivot points, that prevent overshoot of interpolated values.

    Notes: Don't mutate xs and ys arrays after creating this function since data from these arrays is read during interpolation.

    Parameters

    • xs: ArrayLike<number>

      The array of X coordinates of pivot points in ascending order.

    • ys: ArrayLike<number>

      The array of corresponding Y coordinates of pivot points.

    Returns Mapper<number>

    The function that takes X coordinate and returns an interpolated Y coordinate.

    const f = csplineMonot(xs, ys);
    const y = f(x);