Skip to main content

Module comparisons

Module comparisons 

Source
Expand description

More tests comparing samples, following scipy.stats: equal variances (Levene, Bartlett, Fligner-Killeen), rank tests (Kruskal-Wallis, Friedman, Wilcoxon signed-rank), exact tests (Fisher’s exact test for 2 × 2 tables, the binomial test), permutation tests, and the adjustment of p-values for multiple comparisons (Benjamini-Hochberg, Benjamini-Yekutieli, Holm, Bonferroni).

See the book entry More hypothesis tests.

Structs§

MonteCarloResult
The result of monte_carlo_test.
PermutationResult
The result of permutation_test.

Enums§

Adjustment
How adjust_p_values controls the error rate across many tests.
BrunnerMunzelDistribution
The reference distribution of the Brunner-Munzel statistic.

Functions§

adjust_p_values
Adjusted p-values: reject the hypotheses whose adjusted p-value is at most the target rate.
bartlett
Bartlett’s test of equal variances for normal samples (SciPy’s bartlett), χ² with k − 1 degrees of freedom.
binomtest
The exact binomial test of k successes in n trials against success probability p (SciPy’s binomtest); the two-sided p-value sums the probabilities of all outcomes no more likely than k. The statistic is k / n.
brunnermunzel
The Brunner-Munzel test of P(X < Y) + ½ P(X = Y) = ½ (SciPy’s brunnermunzel): unlike the Mann-Whitney test it does not assume equal variances or shapes. With ranks R in the pooled sample and R⁽ˣ⁾ within each sample, the placement variances are S_x² = Σ (R_i − R_i⁽ˣ⁾ − R̄ + R̄⁽ˣ⁾)² / (n_x − 1) (likewise for y), and W = n_x n_y (R̄_y − R̄_x) / ((n_x + n_y) √(n_x S_x² + n_y S_y²)).
fisher_exact
Fisher’s exact test for a 2 × 2 table [[a, b], [c, d]] (SciPy’s fisher_exact): the statistic is the sample odds ratio ad / bc, and the p-value comes from the hypergeometric distribution of a with the margins fixed; the two-sided p-value sums the probabilities of all tables no more likely than the observed one.
fligner
The Fligner-Killeen test of equal variances (SciPy’s fligner, median centring): normal scores of the ranks of the absolute deviations, compared across groups; robust to non-normality.
friedman
Friedman’s test for k treatments measured on the same n blocks (SciPy’s friedmanchisquare): treatments[j][i] is treatment j on block i. Ranks within each block, with the tie correction, χ² with k − 1 degrees of freedom.
kruskal
The Kruskal-Wallis H test that k samples come from the same distribution (SciPy’s kruskal), with the tie correction, χ² with k − 1 degrees of freedom.
levene
Levene’s test of equal variances with Brown and Forsythe’s median centring (SciPy’s levene with center='median'): one-way ANOVA on the absolute deviations from each group’s median, referred to the F distribution with k − 1 and N − k degrees of freedom.
monte_carlo_test
A Monte Carlo hypothesis test (SciPy’s monte_carlo_test): the statistic of the observed samples is compared with its values on n_resamples sets of samples of the same sizes drawn from the null distribution by rvs(sample index, size, rng). The p-value counts the observed value among the resamples, (#{T* ≥ T} + 1)/(n + 1), so it is never zero, and two-sided p-values double the smaller tail.
permutation_test
A two-sample permutation test (SciPy’s permutation_test with permutation_type='independent'): the statistic f(x, y) is recomputed for every way of splitting the pooled observations into groups of the original sizes when there are at most n_resamples of them (exact), and otherwise for n_resamples random splits, for which the p-value counts the observed split as well.
wilcoxon
The Wilcoxon signed-rank test that the differences d (or x − y) are symmetric about zero (SciPy’s wilcoxon with its defaults: zeros dropped, no continuity correction). Without ties or zeros the p-value is exact, from the distribution of W⁺ computed by dynamic programming over the ranks; with ties, by enumerating all sign changes when n ≤ 13, and otherwise from the normal approximation with the tie correction. For the two-sided test the statistic is min(W⁺, W⁻), otherwise W⁺.