FitSlope

(Engine-Level Function)

Description: Linear regression slope. This function returns the slope of the least square curve fit of data in a pair of arrays.
Returns: Numeric
Usage: Script or steady state.
Function Groups: Generic Math
Related to: FitOffset | FitSlope
Format: FitSlope(XarrayElem, YarrayElem, N)
Parameters:  
XArrayElem
Required. Any array element giving the starting point in the array of X coordinates of the input data set. The subscript for the array may be any numeric expression.

If processing a multidimensional array, the usual rules apply to decide which dimension should be used.
YArrayElem
Required. Any array element giving the starting point in the array of Y coordinates of the input data set. The subscript for the array may be any numeric expression.

If processing a multidimensional array, the usual rules apply to decide which dimension should be used.
N
Required. Any numeric expression giving the number of data points to use from the arrays given by the first two parameters.
If N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed.
Comments: If an element of either array is invalid, then that X-Y pair is not included in the computation. If the number of valid data points is less than 2, the function returns an invalid value. Note that XArrayElem and YArrayElem are not necessarily the same array element number. This function is used in conjunction with the FitOffset function.

Example:

Assume that 2 arrays exist such that X = {0, 1, 2, 3} and Y = {1, 3, 5, 7 }, and both arrays' subscripts start at 0.

  Slope = FitSlope(X[0] { Starting X element },
                   Y[0] { Starting Y element }, 
                   4 { Number of elements to process }); 

The variable slope will be set to 2.