Stats testresult - CyrilB1531/lodestar GitHub Wiki

Home › Stats › Hypothesis tests

TestResult

A test statistic and the p-value that goes with it.

public sealed record TestResult(double Statistic, double PValue)

Properties — Statistic is the test statistic, on whichever scale the family defines. PValue is the probability of a statistic at least this extreme under the null.

Example — the two numbers a rank-based test hands back.

using Lodestar.Stats;

double[] control = [7.0, 3.0, 6.0, 2.0, 8.0, 5.0];
double[] treated = [9.0, 12.0, 8.0, 11.0, 15.0, 10.0];

TestResult result = MannWhitney.Test(control, treated);

double statistic = result.Statistic;                // => 0.5
double p = Math.Round(result.PValue, 6);             // => 0.006392

Remarks — eight of the ten families return exactly this, because eight of the ten scipy calls return exactly this — measured, not assumed: MannWhitney.Test, Wilcoxon.Paired and Wilcoxon.OneSample, ChiSquared.GoodnessOfFit, FisherExact.Test, OneWayAnova.Test, KruskalWallis.Test and ShapiroWilk.Test. The three that carry more — a t-test's degrees of freedom, a contingency table's expected frequencies, a Kolmogorov-Smirnov result's location and sign — have their own record, TTestResult, ChiSquaredContingencyResult and KsResult, rather than making the other eight pay for fields they would leave empty.

Being a record, two results with the same statistic and p-value are equal.

Applies to — net10.0, netstandard2.0.

See also — TTestResult, ChiSquaredContingencyResult, KsResult, the Python equivalence table.

Members

Member What it does
TestResult.GetHashCode A hash consistent with the equality, every NaN alike.