Wize Introductory Statistics Textbook > Hypothesis Testing

Permutation Tests and Wilcoxon Rank-Sum Test

Permutation and Wilcoxon rank-sum tests

A permutation test compares an observed statistic with values from relabeling observations under a justified exchangeability rule. The Wilcoxon rank-sum test applies this logic to pooled ranks for two independent groups, rather than directly comparing sample means.

Build the permutation reference

Choose a statistic and a null hypothesis that makes particular assignments equally likely. With nn observations and nAn_A A labels, there are (nnA)\binom{n}{n_A} fixed-size assignments.


For a two-sided mean-difference test against zero, the exact p-value is the fraction whose absolute difference is at least the observed absolute difference, including the observed assignment. Another statistic may require a different definition of two-sided extremeness relative to its null distribution.


In a randomized experiment, relabeling can follow the assignment design under a sharp no-effect null. For independent observational samples, label exchangeability under an equal-distribution null needs separate justification. A permutation test using means is not automatically a test only of medians.

Use pooled ranks

For the Wilcoxon rank sum, pool the groups, sort all observations, and assign average ranks to ties. Add A's ranks to obtain WW. The related Mann–Whitney statistic is U=W−nA(nA+1)/2U=W-n_A(n_A+1)/2: it counts A–B pairwise wins, with half credit for ties. An exchangeable equal-distribution null permits a rank-based reference by relabeling the ranks.


For a two-sided rank comparison, one centered extremeness measure is ∣W−nA(n+1)/2∣|W-n_A(n+1)/2|, equivalently ∣U−nAnB/2∣|U-n_A n_B/2|. Specify the one-sided or two-sided alternative before counting its tail. A high WW suggests A tends to have larger observations; a location or median interpretation requires additional shape assumptions.

Worked example

Suppose A is {4,10}\{4,10\} and B is {1,3,8}\{1,3,8\}, with independent observations and no ties. The pooled order is 1, 3, 4, 8, 10, so A receives ranks 3 and 5.


Thus W=3+5=8W=3+5=8, and U=8−2(3)/2=5U=8-2(3)/2=5, matching five A–B wins among six pairs. The exchangeable-null center is nAnB/2=3n_A n_B/2=3; the observed UU is above that center, but this alone is not a significance verdict.



Four distinct outcomes are 1, 2, 8, and 9. Group A received 8 and 9; group B received 1 and 2. Under an exchangeable equal-distribution null, test the absolute difference in group means using all assignments of two A labels. What is the exact two-sided p-value?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Group A has values 3, 7, 8; group B has 1, 4, 5. There are no ties. What are A’s Wilcoxon rank sum W and Mann–Whitney U?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

An investigator measures each person before and after an intervention, then proposes to pool all before and after measurements and randomly reassign them as if they came from independent groups. Which critique is most accurate?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors