Stats 0.1.0 continuity - CyrilB1531/lodestar GitHub Wiki

Lodestar.Stats 0.1.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

Continuity

Whether a discrete statistic's normal approximation gets the half-unit correction.

public enum Continuity { Applied, None }

MembersApplied shifts the statistic half a unit toward the mean before the normal tail is read. None takes the statistic as it stands.

Example — the same asymptotic Mann-Whitney p-value, with and without the correction.

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 corrected = MannWhitney.Test(
    control, treated, Alternative.TwoSided, Continuity.Applied, ExactMethod.Asymptotic);
TestResult uncorrected = MannWhitney.Test(
    control, treated, Alternative.TwoSided, Continuity.None, ExactMethod.Asymptotic);

double correctedP = Math.Round(corrected.PValue, 6);     // => 0.006392
double uncorrectedP = Math.Round(uncorrected.PValue, 6); // => 0.004998

Remarks — one idea, three spellings in scipy. use_continuity on mannwhitneyu defaults to true, correction on wilcoxon defaults to false, and correction on chi2_contingency defaults to true and is applied to 2×2 tables only. The three defaults disagree with each other, which is exactly why this is a named argument here rather than a bool nobody reads — MannWhitney.Test defaults to Applied, matching scipy's own default there, and Wilcoxon.Paired and Wilcoxon.OneSample default to None, matching scipy's default there too.

The correction only ever touches a normal-approximation p-value; the exact and permutation routes have no continuous approximation to correct, so continuity is silently unused on them — MannWhitney.Test's own parameter documentation says as much.

Applies to — net10.0, netstandard2.0.

See alsoMannWhitney.Test, Wilcoxon.Paired, ChiSquare.Contingency, the Python equivalence table.