Skip to content

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.

Runs in CodeSplashPython example validatedR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

20
20
−0.60
1.0
2.0
0.050

Your data

Drag a point or use ↑/↓ to change it
Group 1 · n = 20 · mean −0.24Group 2 · n = 20 · mean −0.29

If H₀ were true

t = −0.31
  1. The reference: how t varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .760).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

WBM=n1n2(Rˉ2−Rˉ1)(n1+n2)n1σ^12+n2σ^22W_{BM} = \dfrac{n_1 n_2(\bar R_2-\bar R_1)}{(n_1+n_2)\sqrt{n_1\hat\sigma_1^2+n_2\hat\sigma_2^2}}

With your numbers

WBM=(−0.31),ν=28.44W_{BM} = (-0.31),\qquad \nu = 28.44
Rˉj\bar R_j
mean pooled rank in group j
σ^j2\hat\sigma_j^2
variance of placements
ν\nu
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 H0.

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

p^=(mn)−1∑ijh(Xi,Yj)T=p^−1/2sA2/m+sB2/n\begin{gathered}\widehat p=(mn)^{-1}\sum_{ij}h(X_i,Y_j)\\[5pt] T=\frac{\widehat p-1/2}{\sqrt{s_A^2/m+s_B^2/n}}\end{gathered}

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.

Python · native

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))
R

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

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.