Stats testresult - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Stats is 0.4.0 — read its documentation.

HomeStatsHypothesis tests

TestResult

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

public sealed record TestResult(double Statistic, double PValue)

PropertiesStatistic 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, ChiSquare.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, Chi2ContingencyResult 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 alsoTTestResult, Chi2ContingencyResult, KsResult, the Python equivalence table.