Stats 0.1.0 onewayanova test - 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.

OneWayAnova.Test

Compares the means of two or more groups.

public static TestResult Test(double[][] groups)

Parametersgroups are the samples to compare, at least two, each holding at least one value, and at least one holding more than one — scipy.stats.f_oneway takes its samples the same way, one array per group, which groups is params for.

ReturnsTestResult: the F statistic, and the upper-tail p-value.

ExceptionsArgumentException when there are fewer than two groups, a group is empty, or every group holds exactly one value.

Example — three shifts, fifteen measurements in all.

using Lodestar.Stats;

double[] morning = [12.0, 14.0, 11.0, 13.0, 15.0];
double[] afternoon = [16.0, 15.0, 18.0, 17.0, 14.0];
double[] evening = [21.0, 19.0, 22.0, 20.0, 23.0];

TestResult result = OneWayAnova.Test(morning, afternoon, evening);

double f = Math.Round(result.Statistic, 4);   // => 32.6667
double p = Math.Round(result.PValue, 8);      // => 1.396E-05

Remarks — a fully degenerate input answers NaN, not an exception. Two groups that are each internally constant, and constant at the same value, drive both the between- and the within-group sums of squares to exactly zero:

using Lodestar.Stats;

TestResult degenerate = OneWayAnova.Test([5.0, 5.0], [5.0, 5.0]);

bool isNaN = double.IsNaN(degenerate.Statistic);   // => True

Zero divided by zero has no value, and scipy's own f_oneway returns the same NaN on the same input — propagating it is the honest answer, not a guard this package chose to skip. Compare KruskalWallis.Test, which throws on the analogous all-tied input: an ANOVA on constants is a well-formed question with an undefined answer, where the rank-based statistic's inputs there are provably meaningless rather than merely indeterminate.

Applies to — net10.0, netstandard2.0.

See alsoKruskalWallis.Test for the rank-based counterpart, TTest.Independent, MultipleComparisons for correcting the many pairwise tests an ANOVA's rejection invites, the Python equivalence table.