v2026.11.2
All Bundles
Bundle

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".

TTestResult

The outcome of a t-test. A failed test (IsValid() false) has NaN in every number and GetError() set.

The mean difference is the first group minus the second (or the sample mean minus the hypothesised mean for a one-sample test, or the mean of the pairwise differences for a paired one). The confidence interval is for that difference.

Operations

GetCiHigh #

Upper end of the confidence interval for the difference.

method : public : GetCiHigh() ~ Float

Return

TypeDescription
Floatupper bound

GetCiLow #

Lower end of the confidence interval for the difference.

method : public : GetCiLow() ~ Float

Return

TypeDescription
Floatlower bound

GetCohenD #

Cohen's d: the mean difference over the pooled standard deviation (two-sample), or over the standard deviation of the sample (one-sample) or of the differences (paired).

method : public : GetCohenD() ~ Float

Return

TypeDescription
Floatd

GetDf #

Degrees of freedom (fractional for the Welch test).

method : public : GetDf() ~ Float

Return

TypeDescription
Floatdegrees of freedom

GetError #

Why the test did not run, or an empty string.

method : public : GetError() ~ String

Return

TypeDescription
Stringreason

GetHedgesG #

Hedges' g: Cohen's d times the exact small-sample correction Gamma(df/2) / (sqrt(df/2) * Gamma((df-1)/2)) (see Dist->HedgesJ).

method : public : GetHedgesG() ~ Float

Return

TypeDescription
Floatg

GetLevel #

Confidence level the interval was made at.

method : public : GetLevel() ~ Float

Return

TypeDescription
Floatlevel, such as 0.95

GetMean1 #

Mean of the first sample.

method : public : GetMean1() ~ Float

Return

TypeDescription
Floatmean

GetMean2 #

Mean of the second sample, or the hypothesised mean for a one-sample test.

method : public : GetMean2() ~ Float

Return

TypeDescription
Floatmean

GetMeanDiff #

Mean difference: first minus second.

method : public : GetMeanDiff() ~ Float

Return

TypeDescription
Floatdifference

GetMethod #

Name of the test.

method : public : GetMethod() ~ String

Return

TypeDescription
Stringname

GetN1 #

Size of the first sample (or the only one).

method : public : GetN1() ~ Int

Return

TypeDescription
Intcount

GetN2 #

Size of the second sample, 0 for a one-sample test.

method : public : GetN2() ~ Int

Return

TypeDescription
Intcount

GetP #

Two-sided p-value.

method : public : GetP() ~ Float

Return

TypeDescription
Floatp

GetStdError #

Standard error of the mean difference.

method : public : GetStdError() ~ Float

Return

TypeDescription
Floatstandard error

GetT #

The t statistic.

method : public : GetT() ~ Float

Return

TypeDescription
Floatt, NaN when invalid

IsSignificant #

Whether the p-value is below a significance level.

method : public : IsSignificant(alpha:Float) ~ Bool

Parameters

NameTypeDescription
alphaFloatlevel, such as 0.05

Return

TypeDescription
Booltrue if p < alpha (false when invalid)

IsValid #

Whether the test ran.

method : public : IsValid() ~ Bool

Return

TypeDescription
Booltrue if every number is meaningful