Classical statistics for small analyses: descriptive statistics, the Student t, normal, chi-square and F distributions, t-tests with confidence intervals and effect sizes, Pearson correlation with a p-value, and an ordinary least squares fit with the full summary table (standard errors, t statistics, p values, confidence intervals, F test, R-squared, AIC and BIC). Compile with -lib stats,gen_collect; it needs nothing from System.ML.
No call here ends the program on bad input. A function that returns a Float returns NaN, and a function that returns a result object returns one whose IsValid() is false and whose GetError() says why. Design and verification notes: docs/AI.md, "Statistics".
Stats
Descriptive statistics over a Float[]. Each function returns NaN when the array is Nil, too short for the statistic, or holds a NaN or infinity.
Operations
Covariance # function
Sample covariance of two arrays of the same length.
function : Covariance(x:Float[], y:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | first values, at least 2 |
| y | Float | second values, same length as x |
Return
| Type | Description |
|---|---|
| Float | covariance, NaN for mismatched or bad input |
Mean # function
Arithmetic mean.
function : Mean(x:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | values |
Return
| Type | Description |
|---|---|
| Float | mean, NaN for Nil, empty or non-finite input |
Median # function
Median: the middle value, or the mean of the two middle values.
function : Median(x:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | values |
Return
| Type | Description |
|---|---|
| Float | median, NaN for Nil, empty or non-finite input |
PopulationVariance # function
Population variance (divides by n).
function : PopulationVariance(x:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | values, at least 1 |
Return
| Type | Description |
|---|---|
| Float | variance, NaN for Nil, empty or non-finite input |
StdDev # function
Sample standard deviation (divides by n - 1).
function : StdDev(x:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | values, at least 2 |
Return
| Type | Description |
|---|---|
| Float | standard deviation, NaN for bad input |
StdError # function
Standard error of the mean: the sample standard deviation over the square root of n.
function : StdError(x:Float[]) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| x | Float | values, at least 2 |
Return
| Type | Description |
|---|---|
| Float | standard error, NaN for bad input |