functioninterpolate
Extends from Function ((Weighted) geometric mean).
Information
This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The output y is the interpolated value given a list of tuples (tuples = { {x1,y1}, {x2,y2}, ...}) and an index value jlo (default = 1) to guide the search. The function will also return the actual index value jsav used for the interpolation.
Syntax
Functions.interpolate(x, tuples); // jlo = 1 Functions.interpolate(x, tuples, jlo);
Implementation
The index value jlo is used to guide the further procedure: If jlo == 1 then we assume that we are starting out a fresh search und accordingly locate() is used to come up with the correct index value to use for rawInterpolate().
If jlo > 1, then we assume to already have searched in the list of tuples and we can use the last index value to speed up the search; accordingly hunt will be used to find the new index value.
Examples
interpolate(1.5, {{0,1},{1,2}, {2,4},{3,5}}); // (3.0, 2)
See also
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x (from geometricMean) | Vector input | |
| Real | weights (from geometricMean) | ones(size(x, 1)) | Vector of weights |
| Real | tuples | Ordered list of values | |
| Integer | jlo | 1 | Index start value for the search |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | y (from geometricMean) | ||
| Integer | jsav | Index value used for the current interpolation |
Revisions
- Introduced in v2.1.0.