Teachers' Portal  /  A-Level Further Maths 9231  /  Non-parametric tests  /  Wilcoxon rank-sum test
Lesson pack · A-Level Further Maths 9231 · 4.4 · AS & A Level

Wilcoxon rank-sum test

Two samples, one ranking. When two independent samples come from populations you cannot assume are normal, put all the values in one list, rank them, and add up the ranks of the smaller sample.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Non-parametric tests
Syllabus reference
Cambridge International AS and A Level Further Mathematics 9231, 4.4
Level
AS & A Level
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 3 of 3 in Non-parametric tests; follows Wilcoxon signed-rank tests
Central model
Fig. 1: the heights of 4 plants given fertiliser P and 6 given fertiliser Q, combined into one ranking. The P plants (circles) take four of the lowest six ranks, so their rank sum is small
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • Rank the samples together: The rank-sum test compares two independent samples, of sizes \(m\) and \(n\) with \(m \le n\).
  • Compare W with the table: The tables list, for each pair \((m, n)\) with \(m \le n \le 10\), the largest value \(w\) with \(P(W \le w) \le\) the significance level.
  • Large samples and which test: When the sample sizes go beyond the table (both greater than 10 is the usual case), the rank sum is approximately normal.
Key points to leave on the board
  • State \(H_0\): the populations are identical, and \(H_1\) (one- or two-tailed) in context.
  • Rank all \(m + n\) values together, smallest first; \(m\) is the SMALLER sample size.
  • Sum the ranks of the smaller sample to get \(R_m\), then find \(m(n + m + 1) - R_m\); \(W\) is the smaller.
  • Compare with the table value for \((m, n)\) at the right level: reject \(H_0\) if \(W \le\) it.
  • Large samples: \(z = \dfrac{W + 0.5 - \frac{1}{2}m(m + n + 1)}{\sqrt{\frac{1}{12}mn(m + n + 1)}}\).
  • Conclude in context: 'there is (in)sufficient evidence at the ...% level that ...'.
The core visual model

One picture every idea returns to

Combine the two samples (sizes \(m \le n\)) and rank all \(m + n\) values from smallest. \(R_m\) is the sum of the ranks of the smaller sample. The test statistic is \(W\), the smaller of \(R_m\) and \(m(n + m + 1) - R_m\). Reject \(H_0\) (the two populations are identical) if \(W \le\) the table critical value for \((m, n)\). Beyond the table, use \[W \approx N\!\left(\tfrac{1}{2}m(m + n + 1),\ \tfrac{1}{12}mn(m + n + 1)\right)\] with a continuity correction.

Fertiliser P (m = 4) Fertiliser Q (n = 6) height (cm) rank 19.8 23.1 24.2 25.6 26.9 27.4 28.3 29.0 30.5 31.2 1 2 3 4 5 6 7 8 9 10 Rm = 1 + 2 + 4 + 6 = 13 m(n + m + 1) − Rm = 4 × 11 − 13 = 31, so W = 13
Fig. 1: the heights of 4 plants given fertiliser P and 6 given fertiliser Q, combined into one ranking. The P plants (circles) take four of the lowest six ranks, so their rank sum is small
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Two samples, one ranking.. When two independent samples come from populations you cannot assume are normal, put all the values in one list, rank them, and add up the ranks of the smaller sample. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: Rank the samples togetherThe rank-sum test compares two independent samples, of sizes \(m\) and \(n\) with \(m \le n\). Project tab 4 of the lab (Distributions lab, rank-sum test) and let a student drive it while the class predicts. Model the worked example Rank sum for two fertilisers on the board, one line at a time. Your turn: Sample A: 14, 9, 17. Sample B: 11, 20, 16, 22, 13. Find \(R_m\) and \(W\).Whole class, then pairs
13 to 21 minTeach and check: Compare W with the tableThe tables list, for each pair \((m, n)\) with \(m \le n \le 10\), the largest value \(w\) with \(P(W \le w) \le\) the significance level. Model the worked example One-tailed test on the fertiliser data on the board, one line at a time.Pairs
21 to 30 minTeach and check: Large samples and which testWhen the sample sizes go beyond the table (both greater than 10 is the usual case), the rank sum is approximately normal. Model the worked example Normal approximation, two-tailed on the board, one line at a time. Your turn: Samples of sizes 11 and 13 give \(R_m = 110\) for the smaller sample. Test at the 5% level whether the population of the smaller sample tends to take smaller values.Numbered Heads Together
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 31 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Large samples and which test, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Numbered Heads Together

Teams of four number off. Put up a question, give the team time to make sure every member can answer, then call a number: that student answers for the team, so nobody can leave the thinking to someone else.

The full structure, with its PIES check and a worked example for every subject, is on the cooperative-learning page, one of fifteen structures there.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
Rank the two samples TOGETHER, not each one separately (ranking within a sample always gives \(1 + 2 + \dots\) and tells you nothing).And \(R_m\) is the rank sum of the SMALLER sample, whatever order the question lists them in.
The decision rule runs the opposite way to a \(t\) or \(z\) test: SMALL \(W\) means significant, and \(W\) equal to the critical value counts as significant.Also, a two-tailed 5% test uses the one-tailed 0.025 column; in the battery example the one-tailed 0.05 value is 21, which would have wrongly given a significant result.
The variance is \(\tfrac{1}{12}mn(m + n + 1)\), with \(mn\), not \(m^{2}\).The continuity correction moves \(W\) TOWARDS the mean: use \(W + 0.5\), not \(W - 0.5\). And never use the rank-sum test on paired data: pairing is information the rank-sum test throws away.
Worksheet

Wilcoxon rank-sum test: worksheet

6 questions, 31 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · recall[3 marks]

Sample A: 4.7, 6.2, 5.1. Sample B: 5.8, 7.3, 6.6, 4.9, 7.0.

Find \(R_m\) and the value of the Wilcoxon rank-sum statistic \(W\).

Q2 · calculation[5 marks]

The times (seconds) taken to solve a puzzle were recorded for two groups. Group A (no hint): 61, 55, 48, 66, 52. Group B (a misleading hint): 70, 58, 74, 63, 68, 77.

Test at the 5% significance level whether times in group A tend to be shorter than times in group B.

Q3 · calculation[6 marks]

Concentrations of a pollutant (mg per litre) were measured at two rivers. River P: 12.1, 15.4, 13.8, 11.2, 14.6, 16.9. River Q: 17.3, 15.9, 18.8, 13.1, 19.4, 17.8, 20.2.

(a) Test at the 1% significance level whether the concentrations at the two rivers differ.

(b) State, with a reason, whether the conclusion would be different at the 5% level.

Q4 · analysis[6 marks]

A teacher compares the scores of 15 students from School X with those of 20 students from School Y. In the combined ranking of all 35 scores (no ties), the School X students have rank sum 201.

Test at the 1% significance level whether scores at School X tend to be lower than those at School Y.

Q5 · proof[5 marks]

Two independent samples have sizes \(m = 2\) and \(n = 3\), and \(H_0\) is true.

(a) List the 10 equally likely sets of ranks for the smaller sample and hence find the distribution of \(R_m\).

(b) Verify that \(E(R_m) = \tfrac{1}{2}m(m + n + 1)\) and \(\operatorname{Var}(R_m) = \tfrac{1}{12}mn(m + n + 1)\).

(c) Explain why no one-tailed test at the 5% level can reject \(H_0\) with these sample sizes.

Q6 · analysis[6 marks]

A researcher records the times (minutes) that two separate groups of volunteers take to fall asleep. Group A (warm drink): 42, 57, 49, 38. Group B (no drink): 61, 45, 66, 53, 71, 59, 64, 50.

(a) Give one reason why a Wilcoxon matched-pairs signed-rank test is not suitable, and one reason why the rank-sum test may be preferred to a two-sample \(t\)-test.

(b) Test at the 2.5% significance level whether volunteers in group A tend to fall asleep more quickly.

Answer key and marking notes
Q1 · 3 marks
  • Combined order: 4.7 (A), 4.9, 5.1 (A), 5.8, 6.2 (A), 6.6, 7.0, 7.3.
  • A has ranks 1, 3, 5, so \(R_m = 9\).
  • \(m(n + m + 1) - R_m = 3 \times 9 - 9 = 18\), so \(W = 9\).
Q2 · 5 marks
  • \(H_0\): the times for A and B come from identical populations. \(H_1\): times for A tend to be shorter. One-tailed, \(m = 5,\ n = 6\).
  • Combined order: 48 (A), 52 (A), 55 (A), 58, 61 (A), 63, 66 (A), 68, 70, 74, 77. A has ranks 1, 2, 3, 5, 7.
  • \[ R_m = 18, \quad 5 \times 12 - 18 = 42, \quad W = 18 \]
  • A ranks low, as \(H_1\) claims. Critical value for \(m = 5,\ n = 6\), one-tailed 5%: \(20\).
  • \(18 \le 20\): reject \(H_0\). There is sufficient evidence at the 5% level that times in group A tend to be shorter.
Q3 · 6 marks
  • (a) \(H_0\): the concentrations at P and Q come from identical populations. \(H_1\): they differ. Two-tailed, \(m = 6,\ n = 7\).
  • Combined order: 11.2 (P), 12.1 (P), 13.1, 13.8 (P), 14.6 (P), 15.4 (P), 15.9, 16.9 (P), 17.3, 17.8, 18.8, 19.4, 20.2. P has ranks 1, 2, 4, 5, 6, 8.
  • \[ R_m = 26, \quad 6 \times 14 - 26 = 58, \quad W = 26 \]
  • Two-tailed 1% (one-tailed 0.005) critical value for \(m = 6,\ n = 7\): \(24\). \(26 > 24\): do not reject \(H_0\). Insufficient evidence at the 1% level that the concentrations differ.
  • (b) Two-tailed 5% (one-tailed 0.025) critical value: \(27\). \(26 \le 27\), so at 5% \(H_0\) would be rejected: there would be sufficient evidence that the concentrations differ.
Q4 · 6 marks
  • \(H_0\): the scores at X and Y come from identical populations. \(H_1\): scores at X tend to be lower. One-tailed, \(m = 15,\ n = 20\), beyond the tables.
  • \(15 \times 36 - 201 = 339\), so \(W = 201\) (X ranks low, as \(H_1\) claims).
  • \[ \begin{aligned} E &= \tfrac{1}{2}(15)(36) = 270 \\ \operatorname{Var} &= \tfrac{1}{12}(15)(20)(36) = 900 \end{aligned} \]
  • \[ z = \frac{201.5 - 270}{30} = -2.283 \]
  • One-tailed 1% critical value: \(-2.326\). Since \(-2.283 > -2.326\), do not reject \(H_0\).
  • There is insufficient evidence at the 1% level that scores at School X tend to be lower.
Q5 · 5 marks
  • (a) The sets {1,2}, {1,3}, {1,4}, {1,5}, {2,3}, {2,4}, {2,5}, {3,4}, {3,5}, {4,5} give sums 3, 4, 5, 6, 5, 6, 7, 7, 8, 9.
  • \(R_m\) takes the values 3, 4, 5, 6, 7, 8, 9 with probabilities 0.1, 0.1, 0.2, 0.2, 0.2, 0.1, 0.1.
  • (b) The distribution is symmetric about 6, so \(E(R_m) = 6 = \tfrac{1}{2}(2)(6)\).
  • \[ E(R_m^{2}) = \frac{9 + 16 + 50 + 72 + 98 + 64 + 81}{10} = 39, \quad \operatorname{Var}(R_m) = 39 - 36 = 3 = \tfrac{1}{12}(2)(3)(6) \]
  • (c) The smallest possible value, \(R_m = 3\), has probability 0.1, which is more than 0.05. No value of \(W\) is extreme enough, so the 5% critical region is empty.
Q6 · 6 marks
  • (a) The two groups are different people, so the data are not paired (the sizes, 4 and 8, cannot even be matched). The samples are small and there is no information that the times are normally distributed, which the \(t\)-test needs.
  • (b) \(H_0\): the times for A and B come from identical populations. \(H_1\): times for A tend to be shorter. One-tailed, \(m = 4,\ n = 8\).
  • Combined order: 38 (A), 42 (A), 45, 49 (A), 50, 53, 57 (A), 59, 61, 64, 66, 71. A has ranks 1, 2, 4, 7.
  • \[ R_m = 14, \quad 4 \times 13 - 14 = 38, \quad W = 14 \]
  • Critical value for \(m = 4,\ n = 8\), one-tailed 2.5%: \(14\). \(W = 14 \le 14\): reject \(H_0\).
  • There is sufficient evidence at the 2.5% level that volunteers given a warm drink tend to fall asleep more quickly.
Quiz

8 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

Sample A: 12.7, 15.3, 10.9, 14.1. Sample B: 16.2, 13.4, 18.8, 17.5, 11.6. Find \(R_m\) and \(W\).

  • A\(R_m = 15,\ W = 15\)
  • B\(R_m = 15,\ W = 25\)
  • C\(R_m = 25,\ W = 25\)
  • D\(R_m = 30,\ W = 10\)
Q21 mark

What is the null hypothesis of a Wilcoxon rank-sum test?

  • AThe two populations are identical
  • BThe median of the paired differences is zero
  • CThe two population means are equal
  • DThe two samples are the same size
Q31 mark

In a Wilcoxon rank-sum test the samples have sizes \(m = 5\) and \(n = 8\), and the rank sum of the smaller sample is \(R_m = 48\). Find \(W\).

  • A\(W = 48\)
  • B\(W = 17\)
  • C\(W = 64\)
  • D\(W = 22\)
Q41 mark

Samples of sizes \(m = 10\) and \(n = 14\) are compared. Find the mean and variance of \(R_m\) under \(H_0\).

  • AMean \(120\), variance \(291.7\)
  • BMean \(125\), variance \(3500\)
  • CMean \(175\), variance \(291.7\)
  • DMean \(125\), variance \(291.7\)
Q51 mark

Times (s) for two independent groups. Group A: 41.2, 49.9, 39.5, 44.6, 50.3. Group B: 48.9, 53.1, 46.2, 55.7, 51.4, 49.6, 57.0. Critical values for \(m = 5,\ n = 7\): 21 (one-tailed 5%), 20 (one-tailed 2.5%). Test at the 5% level whether the populations differ.

  • A\(W = 19 \le 20\): evidence that the populations differ
  • B\(W = 21 > 20\): insufficient evidence that the populations differ
  • C\(W = 44 > 20\): insufficient evidence that the populations differ
  • D\(W = 21 \le 21\): evidence that the populations differ
Q61 mark

Samples of sizes 13 (A) and 15 (B) give a rank sum of 225 for sample A. Using a normal approximation, test at the 5% level whether population A tends to take larger values. Which is correct?

  • A\(z = -1.66 > -1.96\): insufficient evidence that A tends to take larger values
  • B\(z = -0.0764\): insufficient evidence that A tends to take larger values
  • C\(z = -2.99 < -1.645\): evidence that A tends to take larger values
  • D\(z = -1.66 < -1.645\): evidence that A tends to take larger values
Q71 mark

Two samples each have size 4. By listing the possible sets of ranks, find the one-tailed 5% critical value of \(W\).

  • A\(12\)
  • B\(11\)
  • C\(10\)
  • D\(13\)
Q81 mark

Two samples each have size 3. Which statement about a two-tailed Wilcoxon rank-sum test at the 5% level is correct?

  • A\(H_0\) is rejected if \(W \le 7\), since \(P(R_m \le 7) = \tfrac{2}{20} \le 0.10\)
  • B\(H_0\) is rejected if \(W = 6\), since \(P(R_m = 6) = \tfrac{1}{120} < 0.025\)
  • C\(H_0\) can never be rejected, since \(P(R_m = 6) = \tfrac{1}{20} > 0.025\)
  • D\(H_0\) is rejected if \(W = 6\), since \(P(R_m = 6) = \tfrac{1}{20} \le 0.05\)
Quiz key
Q1: A

Combined order: 10.9 (A, 1), 11.6 (B, 2), 12.7 (A, 3), 13.4 (B, 4), 14.1 (A, 5), 15.3 (A, 6), 16.2, 17.5, 18.8 (B, 7 to 9). \(R_m = 1 + 3 + 5 + 6 = 15\), and \(m(n + m + 1) - R_m = 4 \times 10 - 15 = 25\), so \(W = \min(15, 25) = 15\). \(W = 25\) takes the larger value. \(R_m = 25\) ranks from the largest and then forgets to take the smaller one. \(R_m = 30\) sums the ranks of the LARGER sample, B.

Q2: A

Under \(H_0\) both samples come from the same (identical) population, so every arrangement of the combined ranks is equally likely. Equal means is the two-sample \(t\)-test hypothesis, which needs normality. A zero median difference belongs to the matched-pairs signed-rank test. Sample sizes are chosen by the experimenter and can differ.

Q3: D

\(m(n + m + 1) - R_m = 5 \times 14 - 48 = 70 - 48 = 22\), so \(W = \min(48, 22) = 22\). \(48\) is \(R_m\) itself, without the comparison. \(64\) uses \(n(n + m + 1) - R_m\) with the larger size. \(17\) uses \(m(m + n) - R_m\), dropping the \(+1\).

Q4: D

Mean \(= \tfrac{1}{2} \times 10 \times 25 = 125\). Variance \(= \tfrac{1}{12} \times 10 \times 14 \times 25 = 291.7\) (3 s.f.). \(120\) drops the \(+1\), using \(\tfrac{1}{2}m(m + n)\). \(175\) uses the larger size, \(\tfrac{1}{2}n(m + n + 1)\). \(3500\) forgets to divide by 12.

Q5: B

Combined order: 39.5, 41.2, 44.6 (A: 1, 2, 3), 46.2, 48.9, 49.6 (B: 4, 5, 6), 49.9, 50.3 (A: 7, 8), then B: 9 to 12. \(R_m = 1 + 2 + 3 + 7 + 8 = 21\); \(5 \times 13 - 21 = 44\), so \(W = 21\). Two-tailed 5% uses the one-tailed 2.5% value, 20: \(21 > 20\), so do not reject \(H_0\). There is insufficient evidence that the populations differ. Using 21 is the one-tailed 5% value. \(W = 44\) takes the larger value. \(W = 19\) misranks 49.9 as below 48.9.

Q6: D

\(m(m + n + 1) = 13 \times 29 = 377\), so \(W = \min(225, 152) = 152\). Mean \(188.5\), variance \(\tfrac{1}{12}(13)(15)(29) = 471.25\). \(z = \dfrac{152.5 - 188.5}{\sqrt{471.25}} = \dfrac{-36}{21.71} = -1.66 < -1.645\), so reject \(H_0\): there is evidence that A tends to take larger values (the exact tail is 0.0489). Comparing with \(-1.96\) uses a two-tailed value for a one-tailed test. \(-0.0764\) divides by the variance, not the standard deviation. \(-2.99\) uses the mean \(\tfrac{1}{2}n(m + n + 1) = 217.5\).

Q7: B

Rank sets with small totals: 10 \(\{1, 2, 3, 4\}\); 11 \(\{1, 2, 3, 5\}\); 12 \(\{1, 2, 3, 6\}, \{1, 2, 4, 5\}\); 13 has three more. \(P(R_m \le 11) = \tfrac{2}{70} = 0.0286 \le 0.05\), but \(P(R_m \le 12) = \tfrac{4}{70} = 0.0571 > 0.05\), so the critical value is 11. \(12\) is the first value that goes past 5%. \(10\) is the 2.5% value (\(\tfrac{1}{70} = 0.0143\)). \(13\) is the 10% value (\(\tfrac{7}{70} = 0.1\)).

Q8: C

There are \(\binom{6}{3} = 20\) equally likely rank sets, and the smallest total, 6, comes only from \(\{1, 2, 3\}\), so \(P(R_m = 6) = \tfrac{1}{20} = 0.05\). A two-tailed 5% test allows only 0.025 in each tail, so even the most extreme result is not significant: \(H_0\) can never be rejected with samples this small. Comparing with 0.05 forgets to halve the level. \(\tfrac{1}{120}\) counts ordered selections instead of sets. Using 0.10 is the two-tailed 20% test.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonWilcoxon signed-rank tests