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

Wilcoxon signed-rank tests

Use the signs and the sizes. The sign test throws away everything except whether each value is above or below the claimed median.

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 2 of 3 in Non-parametric tests; follows Sign tests; leads into Wilcoxon rank-sum test
Central model
Fig. 1: the exact distribution of P, the sum of the positive ranks, for n = 8 when H0 is true. Each of the 2^8 = 256 sign patterns is equally likely, so the distribution is symmetric about E(P) = 18. P(P ≤ 5) = 10/256 ≈ 0.039 is within 5% but P(P ≤ 6) = 14/256 ≈ 0.055 is not, so the one-tailed 5% critical value for n = 8 is 5
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 differences, keep the signs: Suppose a population is symmetric with median \(m\).
  • Matched pairs: test the differences: When each subject is measured twice (before and after, judge A and judge B), the two samples are not independent.
  • Large samples: the normal approximation: Under \(H_0\) each rank \(r\) is added to \(P\) with probability \(\tfrac{1}{2}\), independently.
Key points to leave on the board
  • Hypotheses: \(H_0: m = m_0\) (or the median difference is 0), with \(m\) defined in context; state symmetry as the assumption.
  • Differences: \(x - m_0\), or within each pair; rank the absolute values 1 to \(n\).
  • Sums: \(P\) (positive ranks), \(Q\) (negative ranks), check \(P + Q = \tfrac{1}{2}n(n + 1)\).
  • Statistic: \(T = \min(P, Q)\) two-tailed; the sum \(H_1\) predicts small, one-tailed. Reject if \(T \le\) critical value.
  • Large \(n\): \(z = \dfrac{T + 0.5 - n(n + 1)/4}{\sqrt{n(n + 1)(2n + 1)/24}}\), compared with the normal critical value.
The core visual model

One picture every idea returns to

Subtract the hypothesised median \(m_0\) from each value (or take the differences of matched pairs), rank the absolute differences from 1 (smallest) to \(n\), and add the ranks of the positive differences to get \(P\) and of the negative ones to get \(Q\). Always \(P + Q = \tfrac{1}{2}n(n + 1)\). The test statistic is \(T = \min(P, Q)\) and you reject \(H_0\) if \(T \le\) the critical value. For large \(n\), \(T \approx N\!\left(\tfrac{n(n + 1)}{4},\ \tfrac{n(n + 1)(2n + 1)}{24}\right)\). The test is valid only if the population (of values or of differences) is symmetric.

0 5 10 15 20 25 30 35 0 5 10 sum of positive ranks, P (n = 8) ways (out of 256) E(P) = 18 P ≤ 5 10/256 ≈ 0.039 Symmetric about 18 P(P ≤ 6) = 14/256 ≈ 0.055 One-tailed 5%: reject if T ≤ 5
Fig. 1: the exact distribution of P, the sum of the positive ranks, for n = 8 when H0 is true. Each of the 2^8 = 256 sign patterns is equally likely, so the distribution is symmetric about E(P) = 18. P(P ≤ 5) = 10/256 ≈ 0.039 is within 5% but P(P ≤ 6) = 14/256 ≈ 0.055 is not, so the one-tailed 5% critical value for n = 8 is 5
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Use the signs and the sizes.. The sign test throws away everything except whether each value is above or below the claimed median. 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 differences, keep the signsSuppose a population is symmetric with median \(m\). Project tab 3 of the lab (Distributions lab, signed-rank test) and let a student drive it while the class predicts. Model the worked example Ranking and the check P + Q on the board, one line at a time. Your turn: For \(n = 9\) differences, \(P = 37\). Find \(T\) and say whether a two-tailed test at 5% rejects \(H_0\).Whole class, then pairs
13 to 21 minTeach and check: Matched pairs: test the differencesWhen each subject is measured twice (before and after, judge A and judge B), the two samples are not independent. Model the worked example Before and after a revision course on the board, one line at a time.Pairs
21 to 30 minTeach and check: Large samples: the normal approximationUnder \(H_0\) each rank \(r\) is added to \(P\) with probability \(\tfrac{1}{2}\), independently. Model the worked example One-tailed with n = 30 on the board, one line at a time. Your turn: Find \(E(T)\) and \(\operatorname{Var}(T)\) for \(n = 40\).Rally Coach
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, 26 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: the normal approximation, 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

Rally Coach

Pairs share one worksheet. One partner solves the first question aloud while the other coaches, checking each line and offering a prompt rather than the answer; they swap roles for the next question.

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 ABSOLUTE differences, but add up the ranks, not the differences.Summing the positive differences themselves (for example 3.2 + 8.4 +...) is a common slip that produces a number the table knows nothing about.
Do not treat the before and after scores as two separate samples.Matched pairs are tested through their differences; the rank-sum test of the next lesson is for two INDEPENDENT samples.
The continuity correction moves \(T\) TOWARDS the mean: use \(T + 0.5\) because \(T\) is below \(E(T)\).Using \(T - 0.5\), or none at all, can flip a borderline decision, and dividing by the variance instead of its square root gives a tiny, meaningless \(z\).
Worksheet

Wilcoxon signed-rank tests: worksheet

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

NameClassDate
Q1 · recall[2 marks]

In a Wilcoxon signed-rank test on 15 differences, the sum of the positive ranks is \(P = 87\). Find \(Q\) and the value of \(T\) for a two-tailed test.

Q2 · calculation[5 marks]

Packets of rice are labelled with median mass 250 g. Eleven packets have masses (g)

253.8, 248.8, 255.6, 252.1, 249.6, 257.3, 254.5, 247.3, 256.1, 251.6, 258.2.

Assuming the masses are symmetrically distributed, use a Wilcoxon signed-rank test at the 5% level to test whether the median mass differs from 250 g. (Critical value for \(n = 11\), two-tailed 5%: 10.)

Q3 · calculation[5 marks]

Two judges, A and B, score the same ten entries.

A: 7.4, 6.2, 8.9, 5.5, 7.8, 4.6, 6.9, 5.8, 9.1, 6.0
B: 6.8, 7.6, 6.6, 5.8, 6.1, 7.5, 6.0, 6.3, 5.7, 7.1

Test at the 5% level whether there is a difference between the judges' scores. (Critical value for \(n = 10\), two-tailed 5%: 8.)

Q4 · calculation[5 marks]

A Wilcoxon signed-rank test of \(H_0: m = m_0\) against \(H_1: m < m_0\) uses a sample of 50 values and gives \(P = 420\).

(a) Explain why \(P\) is the appropriate test statistic.

(b) Using a normal approximation, carry out the test at the 5% level and at the 1% level.

Q5 · analysis[5 marks]

Ten differences are 2.4, 5.1, -0.8, 3.7, 1.5, 6.2, -1.1, 4.4, 0.6, 2.9. Test \(H_0\): median difference 0 against \(H_1\): median difference greater than 0.

(a) Carry out a sign test at the 5% level.

(b) Carry out a Wilcoxon signed-rank test at the 5% level (critical value 10).

(c) Explain why the conclusions differ, and state the extra assumption needed in (b).

Q6 · proof[4 marks]

(a) Show that for a sample of 4 differences a one-tailed Wilcoxon signed-rank test can never reject \(H_0\) at the 5% level.

(b) Show that for \(n = 5\) the one-tailed 5% critical value is 0.

Answer key and marking notes
Q1 · 2 marks
  • \(P + Q = \tfrac{1}{2}(15)(16) = 120\), so \(Q = 120 - 87 = 33\).
  • \(T = \min(87, 33) = 33\).
Q2 · 5 marks
  • \(H_0: m = 250\), \(H_1: m \ne 250\), where \(m\) g is the population median mass.
  • Differences: 3.8, -1.2, 5.6, 2.1, -0.4, 7.3, 4.5, -2.7, 6.1, 1.6, 8.2.
  • The negative differences -0.4, -1.2, -2.7 have ranks 1, 2, 5, so \(Q = 8\) and \(P = 66 - 8 = 58\).
  • \(T = \min(58, 8) = 8\), and \(8 \le 10\), so reject \(H_0\).
  • There is sufficient evidence at the 5% level that the median mass is not 250 g.
Q3 · 5 marks
  • \(H_0\): the population median of A - B is 0 (no difference between judges). \(H_1\): it is not 0.
  • Differences A - B: 0.6, -1.4, 2.3, -0.3, 1.7, -2.9, 0.9, -0.5, 3.4, -1.1.
  • Ranks of the absolute values: 0.3 (1), 0.5 (2), 0.6 (3), 0.9 (4), 1.1 (5), 1.4 (6), 1.7 (7), 2.3 (8), 2.9 (9), 3.4 (10).
  • Positive ranks 3, 4, 7, 8, 10: \(P = 32\); \(Q = 55 - 32 = 23\). \(T = 23\).
  • \(23 > 8\), so do not reject \(H_0\): insufficient evidence at the 5% level of a difference between the judges.
Q4 · 5 marks
  • (a) If \(m < m_0\), most differences \(x - m_0\) are negative, so the positive ranks, and their sum \(P\), should be small.
  • \[\begin{aligned} E(T) &= \tfrac{50 \times 51}{4} = 637.5 \\ \operatorname{Var}(T) &= \tfrac{50 \times 51 \times 101}{24} = 10731.25 \end{aligned}\]
  • \[z = \frac{420.5 - 637.5}{\sqrt{10731.25}} = \frac{-217}{103.59} = -2.095\]
  • 5%: \(-2.095 < -1.645\), so reject \(H_0\): sufficient evidence that \(m < m_0\).
  • 1%: \(-2.095 > -2.326\), so do not reject \(H_0\) at the 1% level.
Q5 · 5 marks
  • (a) 8 of 10 are positive; \(X \sim B(10, 0.5)\): \(P(X \ge 8) = \dfrac{45 + 10 + 1}{1024} = 0.0547 > 0.05\). Do not reject \(H_0\).
  • (b) The negative differences -0.8 and -1.1 have ranks 2 and 3, so \(Q = 5\), \(P = 50\).
  • \(H_1\) predicts few negative ranks, so \(T = Q = 5 \le 10\): reject \(H_0\); sufficient evidence that the median difference is positive.
  • (c) The Wilcoxon test also uses the fact that both negative differences are among the smallest; the sign test only counts signs, so it is less powerful.
  • The Wilcoxon test assumes the population of differences is symmetric.
Q6 · 4 marks
  • (a) Under \(H_0\) each of the \(2^{4} = 16\) sign patterns is equally likely. The smallest possible \(T\) is 0 (no ranks of the predicted sign).
  • \(P(T = 0) = \tfrac{1}{16} = 0.0625 > 0.05\), so even \(T = 0\) is not significant: no critical region exists.
  • (b) With \(2^{5} = 32\) patterns, \(T = 0\) needs all five signs the same way: \(P(T = 0) = \tfrac{1}{32} = 0.03125 \le 0.05\).
  • \(T = 1\) occurs only when rank 1 alone has the other sign, so \(P(T \le 1) = \tfrac{2}{32} = 0.0625 > 0.05\). Hence the critical value is 0.
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

The differences from a hypothesised median are 2.3, \(-0.8\), 4.1, \(-1.6\), 3.5, 0.4, \(-2.9\). Find \(P\), \(Q\) and \(T\) for a two-tailed Wilcoxon signed-rank test.

  • A\(P = 4,\ Q = 3,\ T = 3\)
  • B\(P = 18,\ Q = 10,\ T = 10\)
  • C\(P = 18,\ Q = 10,\ T = 18\)
  • D\(P = 22,\ Q = 6,\ T = 6\)
Q21 mark

Which statement about the Wilcoxon signed-rank test, compared with the sign test, is correct?

  • AIt uses only the signs, and needs no assumption about shape
  • BIt tests the population mean, using ranks instead of values
  • CIt uses the sizes of the differences, but needs a symmetric population
  • DIt uses the sizes of the differences, but needs a normal population
Q31 mark

A Wilcoxon signed-rank test with \(n = 11\) tests \(H_1\): median \(> m_0\). The rank sums are \(P = 54\) and \(Q = 12\). The critical values for \(n = 11\) are 13 (one-tailed 5%) and 10 (one-tailed 2.5%). At the 5% level, which is correct?

  • A\(T = 12 > 10\): do not reject \(H_0\)
  • B\(T = 12 \le 13\): reject \(H_0\)
  • C\(T = 12 < 13\): do not reject \(H_0\)
  • D\(T = 54 > 13\): do not reject \(H_0\)
Q41 mark

For a Wilcoxon signed-rank test with \(n = 26\), find \(E(T)\) and \(\operatorname{Var}(T)\) for the normal approximation.

  • A\(E(T) = 175.5,\ \operatorname{Var}(T) = 1550.25\)
  • B\(E(T) = 351,\ \operatorname{Var}(T) = 1550.25\)
  • C\(E(T) = 175.5,\ \operatorname{Var}(T) = 6201\)
  • D\(E(T) = 175.5,\ \operatorname{Var}(T) = 39.4\)
Q51 mark

Eight samples are each timed, in seconds, by method \(X\) and method \(Y\). \(X\): 23.5, 18.2, 27.6, 21.0, 25.3, 19.9, 30.1, 22.4. \(Y\): 20.3, 18.8, 22.5, 18.6, 20.6, 21.2, 24.1, 20.6 (same sample in each position). Critical values for \(n = 8\): 5 (one-tailed 5%), 3 (one-tailed 2.5%). Test at the 5% level whether the methods differ.

  • A\(T = 33 > 3\): no evidence that the methods differ
  • B\(T = 3 \le 3\): evidence that the methods differ
  • C\(T = 2 \le 3\): evidence that the methods differ
  • D\(T = 3\), not below 3: no evidence that the methods differ
Q61 mark

For \(n = 7\), find the exact probability under \(H_0\) that \(P \le 3\).

  • A\(\dfrac{10}{128}\)
  • B\(\dfrac{5}{128}\)
  • C\(\dfrac{3}{128}\)
  • D\(\dfrac{4}{128}\)
Q71 mark

A Wilcoxon signed-rank test on a sample of 22 tests \(H_1\): median \(< m_0\) at the 5% level. The sum of the positive ranks is 76. Using a normal approximation, which is correct?

  • A\(z = -1.66\): evidence that the median is less than \(m_0\)
  • B\(z = -5.73\): evidence that the median is less than \(m_0\)
  • C\(z = -1.62\): insufficient evidence that the median is less than \(m_0\)
  • D\(z = -0.0527\): insufficient evidence that the median is less than \(m_0\)
Q81 mark

A two-tailed Wilcoxon signed-rank test at the 5% level uses \(n = 12\). Critical values for \(n = 12\): 17 (one-tailed 5%), 13 (one-tailed 2.5%). For which values of \(P\), the sum of the positive ranks, is \(H_0\) rejected?

  • A\(P \le 13\) only
  • B\(P \le 13\) or \(P \ge 65\)
  • C\(P \le 13\) or \(P \ge 66\)
  • D\(P \le 17\) or \(P \ge 61\)
Quiz key
Q1: B

In order of size: 0.4 (1), 0.8 (2), 1.6 (3), 2.3 (4), 2.9 (5), 3.5 (6), 4.1 (7). Positive: \(1 + 4 + 6 + 7 = 18 = P\). Negative: \(2 + 3 + 5 = 10 = Q\). Check: \(P + Q = 28 = \tfrac{1}{2}(7)(8)\). \(T = \min(P, Q) = 10\). Taking \(T = 18\) uses the larger sum. \(P = 22,\ Q = 6\) ranks the signed values instead of their sizes. \(P = 4,\ Q = 3\) just counts the signs, which is a sign test.

Q2: C

Ranking the absolute differences uses their sizes as well as their signs, so the test is usually more powerful than the sign test; the price is that it is valid only when the population (of values or differences) is symmetric. Using only the signs describes the sign test. Normality is the \(t\)-test assumption. Like the sign test, it is a test of the median.

Q3: B

Under \(H_1\) the negative differences should have small ranks, so \(T = Q = 12\) (check \(P + Q = 66 = \tfrac{1}{2}(11)(12)\)). One-tailed 5% critical value: 13. \(12 \le 13\), so reject \(H_0\): there is evidence that the median exceeds \(m_0\). Using \(T = 54\) takes the sum that is large under \(H_1\). Saying small \(T\) means do not reject reverses the rule. Comparing with 10 uses the two-tailed 5% value.

Q4: A

\(E(T) = \dfrac{26 \times 27}{4} = 175.5\) and \(\operatorname{Var}(T) = \dfrac{26 \times 27 \times 53}{24} = 1550.25\). \(351\) is \(\tfrac{1}{2}n(n + 1)\), the total of all the ranks. \(6201\) divides by 6 instead of 24 (it is \(\sum r^{2}\), forgetting the factor \(\tfrac{1}{4}\)). \(39.4\) is the standard deviation, not the variance.

Q5: B

\(X - Y\): 3.2, \(-0.6\), 5.1, 2.4, 4.7, \(-1.3\), 6.0, 1.8. Sizes ranked: 0.6 (1), 1.3 (2), 1.8 (3), 2.4 (4), 3.2 (5), 4.7 (6), 5.1 (7), 6.0 (8). Negative ranks: \(Q = 1 + 2 = 3\), so \(P = 36 - 3 = 33\) and \(T = 3\). Two-tailed 5% critical value 3: \(3 \le 3\), so reject \(H_0\); there is evidence that the two methods give different times. \(T = 33\) uses the larger sum. \(T = 2\) counts the negative differences instead of adding their ranks. Rejection includes equality with the critical value.

Q6: B

Each of the \(2^{7} = 128\) choices of which ranks are positive is equally likely. Sets with total at most 3: \(\{\}\) (0), \(\{1\}\), \(\{2\}\), \(\{3\}\), \(\{1, 2\}\) (3). That is 5, so \(P(P \le 3) = \dfrac{5}{128} = 0.0391\); since \(P(P \le 4) = \dfrac{7}{128} = 0.0547\), the one-tailed 5% critical value for \(n = 7\) is 3. \(\dfrac{4}{128}\) misses \(\{1, 2\}\). \(\dfrac{10}{128}\) doubles for two tails. \(\dfrac{3}{128}\) misses both the empty set and \(\{1, 2\}\).

Q7: C

\(E(T) = \dfrac{22 \times 23}{4} = 126.5\), \(\operatorname{Var}(T) = \dfrac{22 \times 23 \times 45}{24} = 948.75\). \(z = \dfrac{76.5 - 126.5}{\sqrt{948.75}} = \dfrac{-50}{30.80} = -1.62\). Since \(-1.62 > -1.645\), do not reject \(H_0\): there is insufficient evidence that the median is less than \(m_0\) (the exact tail, 0.0527, agrees). \(-1.66\) corrects the wrong way (75.5). \(-5.73\) uses the mean \(\tfrac{1}{2}n(n + 1) = 253\). \(-0.0527\) divides by the variance instead of the standard deviation.

Q8: B

Two-tailed 5% uses the one-tailed 2.5% value, 13. \(P + Q = 78\), so \(T \le 13\) when \(P \le 13\) or \(Q = 78 - P \le 13\), i.e. \(P \ge 65\). \(P \le 13\) only forgets that a very large \(P\) means a very small \(Q\). \(17\) and \(61\) use the one-tailed 5% value. \(P \ge 66\) is an off-by-one slip: \(P = 65\) gives \(Q = 13\), which is rejected.

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 lessonSign tests