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".
Correlation
Pearson correlation with a p-value and a confidence interval.
Failures (IsValid() false): Nil, unequal lengths, fewer than 3 pairs, NaN or infinity in the data, a level outside (0, 1), and zero variance in either array.
Operations
Pearson # function
Pearson correlation at the 95% level.
function : Pearson(x:Float[], y:Float[]) ~ CorrelationResultParameters
| Name | Type | Description |
|---|---|---|
| x | Float | first values |
| y | Float | second values, same length |
Return
| Type | Description |
|---|---|
| CorrelationResult | result |
Pearson # function
Pearson correlation. The p-value is the two-sided Student t test with n - 2 degrees of freedom; the interval is the Fisher z transform one.
function : Pearson(x:Float[], y:Float[], level:Float) ~ CorrelationResultParameters
| Name | Type | Description |
|---|---|---|
| x | Float | first values |
| y | Float | second values, same length |
| level | Float | confidence level of the interval, strictly between 0 and 1 |
Return
| Type | Description |
|---|---|
| CorrelationResult | result |