Explore

Rank tests: Mann–Whitney, Wilcoxon and Kruskal–Wallis

H₀: neither group tends to give larger values · H₁: one group tends to give larger values

U = 47 · p = 0.0070

p = 0.0070 ≤ α = 0.05: reject H₀. One group tends to give larger values than chance alone would easily produce: a value from group 1 beats one from group 2 in 0.2089 of pairs.

How to read the picture

  • For small samples without ties the bars are the exact null distribution of the rank statistic; otherwise the curve is its normal (or χ²) approximation.

  • The vertical line is your statistic; the highlighted bars or the shaded area are the p-value.

  • Kruskal–Wallis's H lands on the χ² curve with k − 1 degrees of freedom.

  • The tables show the ranks behind the statistic.

Your data

Test

Data

Alternative hypothesis

Significance level α

A rank test replaces each value by its place in the sorted data, so one huge value counts as the largest and no more. Mann–Whitney compares two independent groups, Wilcoxon's signed-rank test compares paired measurements, and Kruskal–Wallis compares several groups. They ask whether one group tends to give larger values, not whether the means differ.

The estimate and what the data show

The p-value uses the normal approximation, corrected for ties and for continuity.
Each group's size, median and mean rank
Groupnmedianmean rank
A155.311.1333
B151219.8667

The worked steps

  1. Rank all the values together; R₁ is group 1's rank sum

    n₁ = 15, n₂ = 15 · R₁ = 167
  2. The U statistic

    U₁ = R₁ − n₁(n₁ + 1)/2 = 167 − 120 = 47 · U₂ = n₁ n₂ − U₁ = 178
  3. Mean and standard deviation of U under H₀ (tie-corrected)

    μ_U = n₁ n₂ / 2 = 112.5 · σ_U = 24.1011
  4. The z statistic (with the continuity correction)

    z = (U − μ_U − ½) / σ_U = 2.697
  5. The p-value

    p = 2 × P(Z ≥ 2.697) = 0.0070
  6. Effect size (rank-biserial correlation)

    r = 2 U₁ / (n₁ n₂) − 1 = -0.5822
  7. Chance a value from group 1 beats one from group 2

    U₁ / (n₁ n₂) = 0.2089

The same in code

scipy
from scipy import stats

stats.mannwhitneyu(a, b, alternative='two-sided')
Excel (the normal approximation by formula)
=RANK.AVG(A2, $A$2:$A$100, 1)  (rank every value together)
=NORM.S.DIST(z, TRUE)
Excel has no Mann–Whitney test: rank the pooled values with RANK.AVG, compute U and z by formula, and read the tail from NORM.S.DIST. scipy picks the exact distribution itself for small samples without ties.

Formulas

U₁ counts the pairs in which the value from group 1 is the larger: about half of all pairs if the groups do not differ.

Try this

  1. One huge value

    Open the small exact sample and change the last value of the second group from 7.7 to 770.

    Look for: The mean of the second group jumps, but its ranks do not move: U and the p-value stay exactly the same. That is what a rank test buys you.

  2. Three tests, three questions

    Open Meridian's claim amounts by tier here, then the two-means explorer on the same claims.

    Look for: Mann–Whitney asks whether one tier tends to give larger claims (not clearly: p = 0.148); Welch on the raw amounts asks about the arithmetic means, which differ. Different questions, different answers.

  3. After Kruskal–Wallis

    Open Meridian's regions and read the pairwise table.

    Look for: Six pairs are compared, so each p-value is adjusted with Holm's method before it is read against α: three of the six pairs survive.

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to Hypothesis Testing Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.