BCompare groups · Guide test 022
Brunner–Munzel test
Tests whether the probability that one group exceeds another, with half weight for ties, equals one half.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Brunner–Munzel test (stochastic equality) — Does one group tend to have larger values than the other, without assuming equal shapes or variances?
In Brunner–Munzel test (stochastic equality), choose Test = Brunner–Munzel (t approximation).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Brunner–Munzel test
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how t varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .760).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- mean pooled rank in group j
- variance of placements
- Satterthwaite-type degrees of freedom
The verdict
t(28.44) = −0.31, p = .760, p̂ = 0.47
p > α = .050: compatible with H₀
Effect size: P(X < Y) + ½P(X = Y) p̂ = 0.470
Tests P(X < Y) + ½P(X = Y) = ½ without assuming equal shapes — the robust replacement for Mann–Whitney when spreads differ.
- Statistic
- −0.308
- p-value
- 0.7603
Brunner–Munzel test on Group 1: n = 20; Group 2: n = 20: t(28.44) = −0.31, p = .760, p̂ = 0.47. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: P(X<Y)+½P(X=Y)=½; H1: this relative effect differs.
Assumptions
Independent samples; ordered measurements and nondegenerate placement variances. Unlike the rank sum location model, equal shapes and variances are unnecessary.
Formula
Parameters and notation
h=I(X<Y)+½I(X=Y); Ai=n⁻¹Σjh(Xi,Yj), Bj=m⁻¹Σih(Xi,Yj). sA²,sB² are sample variances of placements.
Structure of the method
Compute cross-sample pairwise placements, their superiority estimate, and separate placement-variance estimates. Studentization produces a Welch-like statistic and approximate fractional degrees of freedom. The weak null concerns one relative effect rather than equality of entire distributions, which is why an unstudentized ordinary rank permutation is not automatically exact.
Estimated and nuisance parameters
Estimate the relative effect and the variability of placements within each sample. Group means and raw measurement variances are not the fitted nuisance quantities. Tie handling enters the pairwise kernel directly through half weights. The target relative effect is fixed at one-half unless a documented extension supports another null.
Settings and design choices
Choose alternative direction, t versus normal approximation, studentized permutation calibration, replication budget, and multiplicity correction. For small samples, the t reference and an appropriately studentized resampling method warrant comparison. A large bootstrap budget cannot compensate for a resampling scheme that imposes the wrong null hypothesis.
Fitting and adaptation
Recompute all cross-sample placements and variances after changing either group. An adaptation to paired observations is a different procedure because placements are no longer independent across groups. Report an interval for the relative effect when available and retain the distinction between estimated superiority and a median or mean contrast.
Sensitivity and robustness
Near-complete separation can make placement variances zero or nearly zero, producing undefined or unstable statistics. Small discrete samples may have few attainable outcomes. Strong imbalance limits the information from the smaller sample. Equal-shape assumptions are unnecessary for the weak relative-effect target, but independence and reliable variance estimation remain essential.
How to use and calibrate
Use a Welch type t approximation with ν=(a+b)²/[a²/(m−1)+b²/(n−1)], a=sA²/m,b=sB²/n. Studentized permutation variants help in small samples.
Example application
Compare ordinal outcomes with different spreads between groups.
Interpretation and pitfalls
Watch out
Plain unstudentized permutation is not exact for the weak relative effect null. Very small samples and near zero placement variance require care.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Rank tests generally concern distributions or relative effects; a location interpretation needs additional shape assumptions.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x = np.array([4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0])
y = np.array([4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9])
print(stats.brunnermunzel(x,y,distribution="t"))
Output
BrunnerMunzelResult(statistic=np.float64(-2.700353220312274), pvalue=np.float64(0.016919718782574946))
Not run — Syntax checked; runtime not verified in the final environment · needs lawstat
x <- c(4.2,5.1,5.4,4.8,6.0,5.8,4.9,5.6,6.2,5.0)
y <- c(4.0,4.4,4.8,5.0,5.1,4.3,4.7,4.6,5.2,4.9)
print(lawstat::brunner.munzel.test(x,y))
Sources
- SciPy — SciPy · brunnermunzeldocs.scipy.org
- scipy.stats.brunnermunzeldocs.scipy.org
- brunner.munzel.testsearch.r-project.org
- Statistics guide v4 (historical):
- R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 022, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT022.