StepInterp

Revision as of 23:25, 16 February 2016 by Bbecane (talk | contribs)


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.