linear interpolation, nearest neighbor interpolation, nearest right neighbor interpolation, spline interpolation, polynomial interpolation
These functions calculate a value based on known points in a 2-dimensional space by applying one of the following interpolation schemes:
Function name | Description |
---|---|
linear interpolation | Straight lines are drawn between the points |
nearest neighbor interpolation | Staircase pattern: Y-value takes value of nearest neighbor. If both distances are equal, then the nearest left neighbor is chosen. |
nearest right neighbor interpolation | Same as above, nearest right neighbor chosen if distances are equal. |
spline interpolation | Natural cubic spline interpolation |
polynomial interpolation | Creates n-th order polynomial (n = number of points - 1) which passes through all specified points. |
All interpolation functions ensure that the calculated lines cross the specified points. If discontinuities are undesirable, use spine or polynomial interpolation.
Note that the polynomial interpolation create some oscillation effects between the outer 2-3 points at the beginning and at the end.
The spline interpolation does not have this problem.
See interpolation examples with visualized charts.
Indirect parameter passing is disabled
3-5
No. | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 input |
numeral set of numerals |
X-values One or more X-values provided in order to calculate one or more Y-values | ||||||||||
2 input |
set of numerals | X-coordinates of points The list of known points consist of X-coordinates provided in this function parameter and Y-coordinates in the next function parameter. | ||||||||||
3 input |
set of numerals | X-coordinates of points The list of known points consist of X-coordinates provided in the previous function parameter and Y-coordinates in this function parameter. The X-values must be in ascending order. | ||||||||||
Opt. 4 input |
string | Extrapolation options beyond left side Extrapolation option left side (and also applicable to beyond the right side if the 5th parameter is not specified). Following options exist:
| ||||||||||
Opt. 5 input |
string | Extrapolation options beyond right side Extrapolation option right side. Same value selection as defined for the 4th aprameter (extrapolation options beyond left side). Default value: same as specified in 4th parameter, otherwise reject |
Type | Description |
---|---|
numeral set of numerals |
Result Calculated Y-value (or Y-values if set with multiple numerals are passed into 1st function parameter). |
Rejected extrapolation
X-values not in ascending order
Empty sets or sets of different lengths provided for X- and/or Y-coordinates
x[] = {-1 .. 12 };
y[] = linear interpolation( x[], {0, 4, 8, 10}, {0, 8, 5, 0}, flat, continue );
// Note: Extrapolation is done for for x[] = -1, 11 and 12.
echo(y[]);
{0,0,2,4,6,8,7.25,6.5,5.75,5,2.5,0,-2.5,-5}