Difference between revisions of "StepInterp"
m (updated d+r to xi+yi) |
|||
Line 2: | Line 2: | ||
[[Category:Doc Status D]] <!-- For Lumina use, do not change --> | [[Category:Doc Status D]] <!-- For Lumina use, do not change --> | ||
[[Category:Array Library]] | [[Category:Array Library]] | ||
− | == StepInterp( | + | == StepInterp(xi, yi, x, ''i'') == |
− | Given coordinates | + | Given arrays of numerical coordinates «xi» and «yi», indexed by «i», it returns the y value corresponding to the smallest value of xi>=x. Thus, it returns a step function, with risers at each value of «xi». If optional parameter «leftLookup» is <code>True</code>, it returns the y value corresponding to the largest value of xi<=x. «xi», «yi», and «x» must be numbers. The numbers in «xi» must be in increasing order. If «xi» is itself a simple index, «yi» must be indexed by «xi», and parameter «i» may be omitted. Otherwise, «i» must be a common index of «xi» and «yi». «x» may be a scalar or array. If «x» is less than the smallest (and first) value in «xi» (x < xi[@i=1]), it returns that smallest value. Similarly, if «x» is larger than the last (largest) value in «xi» (x > xi[@i=Size(i)]), it returns that largest value. |
− | If «x» is a single value, the result of [[StepInterp]] is an array indexed by all indexes of | + | If «x» is a single value, the result of [[StepInterp]] is an array indexed by all indexes of «yi» except «xi»’s index. If «x» is an array, the result of [[Stepinterp]] is also indexed by the indexes of «x». |
[[StepInterp]] is similar to [[Subscript]](u1, i, u2); however, [[Subscript]] selects based on the index value being equal to «x», while [[StepInterp]] selects based on the array value being greater than or equal to «x». | [[StepInterp]] is similar to [[Subscript]](u1, i, u2); however, [[Subscript]] selects based on the index value being equal to «x», while [[StepInterp]] selects based on the array value being greater than or equal to «x». | ||
Line 12: | Line 12: | ||
==Examples== | ==Examples== | ||
− | The following examples use [[ | + | The following examples use [[User Guide Examples]]. |
To see the values in <code>Car_prices</code> corresponding to <code>Years >= 2007.5</code>: | To see the values in <code>Car_prices</code> corresponding to <code>Years >= 2007.5</code>: | ||
Line 52: | Line 52: | ||
==Optional Parameters== | ==Optional Parameters== | ||
=== ''i'' === | === ''i'' === | ||
− | Specifies the common index of | + | Specifies the common index of «xi» and «yi». You can omit this, if «xi» is itself an index of «yi». |
=== ''extrapolationMethod'' === | === ''extrapolationMethod'' === | ||
− | Specifies the value to return if «x» is outside the values of | + | Specifies the value to return if «x» is outside the values of «xi»: |
− | *1: Use the | + | *1: Use the «yi» for nearest «xi» (default method) |
*2: Return [[Null]] | *2: Return [[Null]] | ||
*3: Same as 1 (nearest point) for normal evaluation, but [[Null]] during optimization. | *3: Same as 1 (nearest point) for normal evaluation, but [[Null]] during optimization. | ||
=== ''leftLookup'' === | === ''leftLookup'' === | ||
− | When the optional parameter, «leftLookup», is specified as True, [[StepInterp]] returns the element or slice of | + | When the optional parameter, «leftLookup», is specified as <code>True</code>, [[StepInterp]] returns the element or slice of «yi» corresponding to the largest value in «xi» that is less than or equal to «x». |
− | The two graphs interpolate from the same set of ''( | + | The two graphs interpolate from the same set of ''(xi,yi)'' points, with different settings for «leftLookup». |
{| | {| | ||
| [[Image:Stepinterp-graph.png|450px]] | | [[Image:Stepinterp-graph.png|450px]] | ||
Line 76: | Line 76: | ||
* [[LinearInterp]] | * [[LinearInterp]] | ||
* [[CubicInterp]] | * [[CubicInterp]] | ||
+ | * [[MonoCubicInterp]] | ||
* [[Subscript]] | * [[Subscript]] | ||
+ | *[[User Guide Examples]] / [[Media: Array Function Examples.ana | Array Function Examples.ana]] / Reducing Functions Module |
Revision as of 02:41, 17 November 2015
StepInterp(xi, yi, x, i)
Given arrays of numerical coordinates «xi» and «yi», indexed by «i», it returns the y value corresponding to the smallest value of xi>=x. Thus, it returns a step function, with risers at each value of «xi». If optional parameter «leftLookup» is True
, it returns the y value corresponding to the largest value of xi<=x. «xi», «yi», and «x» must be numbers. The numbers in «xi» must be in increasing order. If «xi» is itself a simple index, «yi» must be indexed by «xi», and parameter «i» may be omitted. Otherwise, «i» must be a common index of «xi» and «yi». «x» may be a scalar or array. If «x» is less than the smallest (and first) value in «xi» (x < xi[@i=1]), it returns that smallest value. Similarly, if «x» is larger than the last (largest) value in «xi» (x > xi[@i=Size(i)]), it returns that largest value.
If «x» is a single value, the result of StepInterp is an array indexed by all indexes of «yi» except «xi»’s index. If «x» is an array, the result of Stepinterp is also indexed by the indexes of «x».
StepInterp is similar to Subscript(u1, i, u2); however, Subscript selects based on the index value being equal to «x», while StepInterp selects based on the array value being greater than or equal to «x».
StepInterp can be used to perform table lookup.
Examples
The following examples use User Guide Examples.
To see the values in Car_prices
corresponding to Years >= 2007.5
:
StepInterp(Years, Car_prices, 2007.5, Years) →
Car_type ▶ | ||
---|---|---|
VW | Honda | BMW |
19 | 22 | 30 |
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 |
Optional Parameters
i
Specifies the common index of «xi» and «yi». You can omit this, if «xi» is itself an index of «yi».
extrapolationMethod
Specifies the value to return if «x» is outside the values of «xi»:
- 1: Use the «yi» for nearest «xi» (default method)
- 2: Return Null
- 3: Same as 1 (nearest point) for normal evaluation, but Null during optimization.
leftLookup
When the optional parameter, «leftLookup», is specified as True
, StepInterp returns the element or slice of «yi» corresponding to the largest value in «xi» that is less than or equal to «x».
The two graphs interpolate from the same set of (xi,yi) points, with different settings for «leftLookup».
![]() |
![]() |
leftLookup:False (default) | leftLookup:True |
---|
See Also
- The User Group Webinar Intro to Step Interpolation recording.
- LinearInterp
- CubicInterp
- MonoCubicInterp
- Subscript
- User Guide Examples / Array Function Examples.ana / Reducing Functions Module
Enable comment auto-refresher