Investment Studio > Expressions > Functions > Statistical > SLOPE
float slope(float array known_ys, float array known_xs)
Returns the slope of the linear regression line of a set of known y(x) pairs.
known_ys and known_xs contain the known y(x) pairs. Arrays with different dimensions are allowed as long as they all have the same number of elements (e.g. 2 x 3 and 3 x 2 arrays). Corresponding elements are determined by order of appearance (reading from left to right, top to bottom).
All array elements are converted to float, with exclusion if conversion fails.
The linear regression line is the straight line which best fits the data in the least square sense. The slope is the vertical separation between any two points on the line, divided by their horizontal separation. The slope functions is therefore equivalent to (but more efficient than) the expression
=forecast(1, known_ys, known_xs) - forecast(0, known_ys, known_xs)
Example
=slope({1, 2, 3, 4}, {4, 3, 2, 1})
equals -1.
See also correl, forecast, growth, intercept, linest, logest, rsq, steyx, trend.