Skip to content
Rodrigo Celso de Lima Porto edited this page Jan 13, 2026 · 1 revision

Calculates the slope $A$ of the linear regression $Y = AX + B$ between two numerical lists X and Y.

Syntax

List.Slope(
    X as list,
    Y as list
) as nullable number

Parameters

  • X: A list of numerical values representing the independent variable.
  • Y: A list of numerical values representing the dependent variable.

Return Value

Returns a number representing the slope of the linear regression line calculated using the least squares method. If the lists have different lengths, the function returns null.

Remarks

  • Both input lists must have the same length; otherwise, the function returns null.
  • The function uses the least squares method to calculate the slope.
  • Non-numeric values in the lists will cause an error during calculation.

Examples

Example 1: Calculates the slope of linear regression.

List.Slope({1, 2, 3}, {4, 5, 6})

Result

1

Example 2: Returns null if input lists have different lenghts.

List.Slope({1, 2}, {3})

Result

null

Clone this wiki locally