Difference between revisions of "CubicInterp"

 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[Category:Interpolation functions]]
 
[[Category:Interpolation functions]]
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
+
[[Category:Doc Status D]]
 +
[[Category:Array Library]]
 +
<!-- For Lumina use, do not change -->
  
== CubicInterp(d,r,x,I) ==
+
== CubicInterp(xi, yi, x, ''i'') ==
 +
Given arrays of numerical coordinates «xi» and «yi», indexed by «i», it returns the y value corresponding to parameter «x», using cubic interpolation between the two values of «xi» nearest to «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 have any dimensions. 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 largest (and last) value in «d» (''x > xi[@i = Size(i)]''), it returns that largest value.
  
Returns the natural cubic spline interpolated values of ''r'' along ''d'', interpolating for values of X.  The points ''(r,d)'' that get interpolated are indexed by ''I''The values of ''d'' must be ascending.
+
Points having either «ci» or «yi» equal to [[Null]] are ignoredWhen «x» is [[Null]], the result is [[Null]].
The index ''I'' is optional when ''d'' and ''r'' have only one index is common; however, it is recommended that you explicitly specify ''I'', since this will enable your expression to array-abstract if any dimension is ever added to ''d'' and ''r'' in the future.
 
  
Null values are allowed in ''d'' and ''r'' only in releases later than 4.1.1 (not including 4.1.1).  Points having either ''d'' or ''r'' equal to null are ignored.  When ''x'' is null, the result is null.
+
:[[Image:Cubicinterp-graph.png]]
  
[[Image:Cubicinterp-graph.png]]
+
A cubic interpolation can vary wildly from the actual values of the data points.  In the above graph, all the «yi» values are positive, yet the interpolation is as small as -22.5 around x=33.  Even if the «yi» values are monotonically increasing, this does not mean that the cubic interpolation will be monotonically increasing. The [[MonoCubicInterp]] function is a variation that provides a guarantee of monotonicity.
  
A cubic interpolation can vary wildly from the actual values of the data points.  In the above graph, all the ''r'' values are positive, yet the interpolation is as small as -22.5 around x=33.  Even if the ''r'' values are monotonically increasing, this does not mean that the cubic interpolation will be monotonically increasing.  The [[MonoCubicInterp]] function is a variation that provides a guarantee of monotonicity.
+
==Example==
 
+
The following example can be found in the [[User Guide Examples]].
== Library ==
 
 
 
Array functions
 
 
 
== See also ==
 
  
* [[MonoCubicInterp]]
+
:<code>Cubicinterp(Index_b, Array_a, 1.5, Index_b) &rarr;</code>
* [[LinearInterp]]
+
:{| class="wikitable"
* [[StepInterp]]
+
!! colspan="3" style="text-align: left;" | a &#9654;
 
 
=User Guide=
 
Returns the natural cubic spline interpolated values of y along x, interpolating for values of v. x and y must both be indexed by i, and x must be increasing along i.
 
 
 
For each value of v, Cubicinterp() finds the nearest values from x, and using a natural cubic spline between the corresponding values of y, computes the interpolated value. If v is less than the minimum value in x, it returns the first value in y; if v is greater than the maximum value in x, it returns the last value for y.
 
 
 
==Library==
 
Array
 
 
 
==Example==
 
Cubicinterp(Index_b, Array_a, 1.5, Index_b)
 
Index_a >
 
{| class="wikitable"
 
 
|-
 
|-
 
! scope="col"| a
 
! scope="col"| a
Line 44: Line 28:
 
| 2.219
 
| 2.219
 
|}
 
|}
 +
 +
== 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»:
 +
*<code>1</code>: Use the «yi» for nearest «xi» (default method)
 +
*<code>2</code>: Return [[Null]]
 +
*<code>3</code>: Same as <code>1</code> (nearest point) for normal evaluation, but [[Null]] during optimization.
 +
 +
== History ==
 +
*Analytica 4.1+
 +
**Null values allowed in «xi» and «yi».
 +
 +
== See also ==
 +
* [[MonoCubicInterp]]
 +
* [[LinearInterp]]
 +
* [[StepInterp]]
 +
*[[User Guide Examples]] / [[Media: Array Function Examples.ana | Array Function Examples.ana]] / Interpolation Functions Module

Latest revision as of 23:04, 22 January 2016


CubicInterp(xi, yi, x, i)

Given arrays of numerical coordinates «xi» and «yi», indexed by «i», it returns the y value corresponding to parameter «x», using cubic interpolation between the two values of «xi» nearest to «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 have any dimensions. 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 largest (and last) value in «d» (x > xi[@i = Size(i)]), it returns that largest value.

Points having either «ci» or «yi» equal to Null are ignored. When «x» is Null, the result is Null.

Cubicinterp-graph.png

A cubic interpolation can vary wildly from the actual values of the data points. In the above graph, all the «yi» values are positive, yet the interpolation is as small as -22.5 around x=33. Even if the «yi» values are monotonically increasing, this does not mean that the cubic interpolation will be monotonically increasing. The MonoCubicInterp function is a variation that provides a guarantee of monotonicity.

Example

The following example can be found in the User Guide Examples.

Cubicinterp(Index_b, Array_a, 1.5, Index_b) →
a ▶
a b c
0.6875 -2.875 2.219

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.

History

  • Analytica 4.1+
    • Null values allowed in «xi» and «yi».

See also

Comments


You are not allowed to post comments.