Interpolation functions
These three functions interpolate across arrays. Given arrays y and x with a common index i, these functions interpolate a value for y corresponding to value v along the x axis.
LinearInterp() and CubicInterp() use these variables:
Index_a:
| a | b | c |
Index_b:
| 1 | 2 | 3 |
Array_a:
| Index_b ▶ | |||
|---|---|---|---|
| Index_a: ▼ | 1 | 2 | 3 |
| a | 7 | -3 | 1 |
| b | -4 | -1 | 6 |
| c | 5 | 0 | -2 |
Stepinterp(x, y, v, i)
Returns the element or slice of array y for which v has the smallest value less than or equal to x. x and y must both be indexed by i, and x must be increasing along index i. If v is greater than all values of x, it returns the element of y for which x has the largest value.
When an optional parameter, LeftLookup, is specified as True, it returns the element or slice of y corresponding to the largest value in x that is less than or equal to v.
If v is an atom (scalar value), the result is an array indexed by all indexes of a except x’s index. If v is an array, the result is also indexed by the indexes of v.
If the first parameter x is an index of y, the fourth parameter is optional. Stepinterp(x, y, v) is similar to y[x = v] except that y[x = v] selects based on v being equal to x, while Stepinterp(x, y, v) selects based on v being greater than or equal to x.
Stepinterp() can be used to perform table lookup.
Library: Array
Examples: To see the values in Car_prices corresponding to Years >= 2007.5:
Stepinterp(Years, Car_prices, 2007.5, Years) →
| VW | Honda | BMW |
|---|---|---|
| 19K | 22K | 30K |
Here v is a list of two values:
Stepinterp(Years, Car_prices, [2007, 2008], Years) →
| VW | Honda | BMW | |
|---|---|---|---|
| 2007 | 18K | 20K | 28K |
| 2008 | 19K | 22K | 30K |

Enable comment auto-refresher