Statistical Functions
Statistical Functions
| Function | Description |
|---|---|
| varS(array) | Returns the sample variance of the numeric array. Uses n − 1 as the denominator (Bessel’s correction). Returns null if fewer than two non-null values are present. Example: varS(3, 4, 8) returns 7.0 |
| varP(array) | Returns the population variance of the numeric array. Uses n as the denominator. Returns 0 when the array contains exactly one non-null value. Example: varP(3, 4, 8) returns 4.666666666666667 |
| stdevS(array) | Returns the sample standard deviation of the numeric array. Equivalent to the square root of varS. Returns null if fewer than two non-null values are present. Example: stdevS(3, 4, 8) returns 2.6457513110645907 |
| stdevP(array) | Returns the population standard deviation of the numeric array. Equivalent to the square root of varP. Example: stdevP(3, 4, 8) returns 2.160246899469287 |
| covarS(y, x) | Returns the sample covariance between arrays y and x. Uses n − 1 as the denominator. Pairs where either element is null are excluded. Returns null if the arrays differ in length, are empty, or contain fewer than two non-null pairs. Example: covarS({3, 4, 8}, {3, 10, 8}) returns 4.0 |
| covarP(y, x) | Returns the population covariance between arrays y and x. Uses n as the denominator. Pairs where either element is null are excluded. Returns null if the arrays differ in length or are empty. Example: covarP({3, 4, 8}, {3, 10, 8}) returns 2.6666666666666665 |
| correl(y, x) | Returns the Pearson correlation coefficient between arrays y and x. Values range from −1 (perfect negative correlation) to 1 (perfect positive correlation). Returns null if the arrays differ in length, are empty, or if either variable has zero variance. Example: correl({3, 4, 8}, {3, 10, 8}) returns 0.4193139346887673 |
| rsq(y, x) | Returns the coefficient of determination (R²) between arrays y and x. Calculated as the square of correl. Values range from 0 to 1 and represent the proportion of variance in y explained by x. Example: rsq({3, 4, 8}, {3, 10, 8}) returns 0.17582417582417584 |
| slope(knownY, knownX) | Returns the slope of the least-squares regression line fitted to knownY and knownX. Represents the change in Y for a one-unit increase in X. Returns null if the arrays differ in length, contain fewer than two non-null pairs, or if knownX has zero variance. Example: slope({3, 4, 8}, {3, 10, 8}) returns 0.3076923076923077 |
| intercept(knownY, knownX) | Returns the Y-intercept of the least-squares regression line fitted to knownY and knownX. Represents the predicted value of Y when X equals zero. Requires at least two non-null data point pairs. Example: intercept({3, 4, 8}, {3, 10, 8}) returns 2.846153846153846 |
| forecast(x, knownY, knownX) | Returns the predicted Y value for a given x using the linear regression line fitted to knownY and knownX. Equivalent to intercept(knownY, knownX) + slope(knownY, knownX) * x. Returns null if x is null or if the regression line cannot be determined. Example: forecast(1, {3, 4, 8}, {3, 10, 8}) returns 3.1538461538461533 |