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(d, r, x, ''i'') ==
+
== StepInterp(xi, yi, x, ''i'') ==
Given coordinates «d» and «r», indexed by «i», it returns the y value corresponding to the smallest value of d>=x.  Thus, it returns a step function, with risers at each value of «d». If optional parameter «leftLookup» is True, it returns the y value corresponding to the largest value of d<=x. «d», «r», and «x» must be numbers. The numbers in «d» must be in increasing order. If «d» is itself a simple index, «r» must be indexed by «d», and parameter «i» may be omitted.  Otherwise, «i» must be a common index of «d» and «r». «x» may be a scalar or array. If «x» is less than the smallest (and first) value in «d» (x < d[@i=1]), it returns that smallest value. Similarly, if «x» is larger than the last (largest) value in «d» (x > d[@i=Size(i)]), it returns that largest value.
+
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 «r» except «d»’s index. If «x» is an array, the result of [[Stepinterp]] is also indexed by the indexes of «x».
+
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 [[Array Function Example Variables]].
+
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 «d» and «r». You can omit this, if «d» is itself an index of «r».
+
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 «d»:
+
Specifies the value to return if «x» is outside the values of «xi»:
*1: Use the «r» for nearest «d» (default method)
+
*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 «r» corresponding to the largest value in «d» that is less than or equal to «x».
+
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 ''(d,r)'' points, with different settings for «leftLookup».
+
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».

Stepinterp-graph.png StepInterp2-graph.png
leftLookup:False (default) leftLookup:True

See Also

Comments


You are not allowed to post comments.