Performs cubic spline interpolation.
SPLINE(series, n)
series |
- |
A series or table, the input to interpolate. |
n |
- |
An integer. The interpolation factor. |
A series or table, the cubic spline interpolated result.
W1: {6, 5, 8, 11, 6}
W2: spline(W1, 10)
W3: W2;overplot(W1, RED);setsymbol(SQUARE, 2)
Compare the spline fit with the original data (red curve with square symbols). The cubic spline interpolation is smoother.
SPLINE is also useful for XY plots with monotonic X values. For example:
W1: {1, 5, 8, 10, 15}
W2: {2, 6, 4, 8, 10}
W3: xy(W1, W2)
W4: spline(W3, 10);overp(w3, lred);setsym(14, 2);setplotstyle(1, 2)
SPLINE can be used on XY plots with non-monotonic X values. For example:
W1: {1, 5, 8, 10, 7}
W2: {2, 6, 4, 8, 10}
W3: xy(W1, W2)
W4: xy(spline(xvals(W3), 10), spline(yvals(w3), 10));overp(w3, lred);setsym(14, 2);setplotstyle(1, 2)
SPLINE effectively fits a third order polynomial between adjacent samples and uses the polynomial equation to calculate the interpolated values.
SPLINE automatically adjusts the sample rate (1/DELTAX) of the resulting series.
See XYLOOKUP to find a Y value from an arbitrary X value with possible spline interpolation.