Cambridge International AS & A Level · Topic 4.4
A-Level Further Maths 9231 / Topic 4.4 / AS & A Level

Use the signs and the sizes.

The sign test throws away everything except whether each value is above or below the claimed median. The Wilcoxon signed-rank test keeps the sizes too, by ranking the differences, so it can detect a shift the sign test misses. The price is one assumption: the population must be symmetric.

The key idea

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
Section 01

Rank the differences, keep the signs.

Suppose a population is symmetric with median \(m\). Test \(H_0: m = m_0\). If \(H_0\) is true, each difference \(x - m_0\) is as likely to be positive as negative, whatever its size, so the big ranks should be split roughly evenly between the two signs. A large imbalance of rank (not just of count) is evidence against \(H_0\). That is why this test is more powerful than the sign test: it uses the magnitudes. It is also why it needs symmetry: in a skewed population the large differences tend to fall on one side even when the median is \(m_0\).

One-tailed5%2.5%1%0.5%
Two-tailed10%5%2%1%
\(n = 6\)20--
\(n = 7\)320-
\(n = 8\)5310
\(n = 9\)8531
\(n = 10\)10853
\(n = 11\)131075
\(n = 12\)171397
Worked example Ranking and the check P + Q
A machine is meant to fill bags with median mass 50 g. Eight bags have masses (g) 53.2, 47.9, 58.4, 55.1, 49.3, 61.0, 52.6, 56.8. Find \(P\) and \(Q\) for a test of \(m = 50\).
  1. Differences \(x - 50\): 3.2, -2.1, 8.4, 5.1, -0.7, 11.0, 2.6, 6.8.
  2. Order the absolute values: 0.7 (rank 1, negative), 2.1 (2, negative), 2.6 (3), 3.2 (4), 5.1 (5), 6.8 (6), 8.4 (7), 11.0 (8).
  3. \(Q = 1 + 2 = 3\) and \(P = 3 + 4 + 5 + 6 + 7 + 8 = 33\).
  4. Check: \(P + Q = 36 = \tfrac{1}{2}(8)(9)\).
Answer: \(P = 33,\ Q = 3\); for \(H_1: m > 50\), \(T = Q = 3 \le 5\) (one-tailed 5%), so there is evidence that the median exceeds 50 g
Worked example A two-tailed single-sample test
A bus journey is claimed to have median time 12.0 minutes. Ten journeys took 10.4, 13.9, 9.1, 11.6, 8.7, 12.5, 10.9, 7.8, 13.2, 9.6 minutes. Assuming the times are symmetrically distributed, test at the 5% level whether the median differs from 12.0 minutes.
  1. \(H_0: m = 12.0\), \(H_1: m \ne 12.0\), where \(m\) is the population median journey time.
  2. Differences: -1.6, 1.9, -2.9, -0.4, -3.3, 0.5, -1.1, -4.2, 1.2, -2.4.
  3. Positive differences 0.5, 1.2, 1.9 have ranks 2, 4, 6, so \(P = 12\) and \(Q = 55 - 12 = 43\).
  4. \(T = \min(12, 43) = 12\). Critical value for \(n = 10\), two-tailed 5%: 8.
  5. \(12 > 8\), so do not reject \(H_0\).
Answer: Insufficient evidence at the 5% level that the median journey time differs from 12.0 minutes
Your turn
For \(n = 9\) differences, \(P = 37\). Find \(T\) and say whether a two-tailed test at 5% rejects \(H_0\).
Examiner trap

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.

Section 02

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. Take the difference within each pair and run a signed-rank test on those differences with hypothesised median 0. \(H_0\): the two populations are identical (the differences have median 0); \(H_1\): one population tends to give larger values. The symmetry assumption is now about the population of DIFFERENCES.

Worked example Before and after a revision course
Nine students took a test before and after a revision course. Before: 52, 61, 48, 70, 55, 63, 58, 66, 49. After: 56, 60, 54, 73, 62, 61, 67, 71, 57. Test at the 5% level whether scores tend to increase.
  1. \(H_0\): the population median of after minus before is 0. \(H_1\): it is greater than 0 (one-tailed).
  2. Differences (after minus before): 4, -1, 6, 3, 7, -2, 9, 5, 8.
  3. The absolute values 1 to 9 are their own ranks; the negative ones are ranks 1 and 2, so \(Q = 3\) and \(P = 42\) (check: \(45\)).
  4. \(H_1\) predicts few negatives, so \(T = Q = 3\). Critical value for \(n = 9\), one-tailed 5%: 8.
  5. \(3 \le 8\), so reject \(H_0\).
Answer: Sufficient evidence at the 5% level that scores tend to increase after the course
Worked example The same data with a sign test
Use a sign test on the nine differences above, at the 5% level, and compare the conclusion with the Wilcoxon test.
  1. 7 of the 9 differences are positive. Under \(H_0\), \(X \sim B(9, 0.5)\).
  2. \(P(X \ge 7) = \dfrac{\binom{9}{7} + \binom{9}{8} + \binom{9}{9}}{2^{9}} = \dfrac{36 + 9 + 1}{512} = 0.0898\).
  3. \(0.0898 > 0.05\), so the sign test does not reject \(H_0\).
  4. The Wilcoxon test noticed that the two negatives were the SMALLEST differences; the sign test only counted them.
Answer: The sign test gives insufficient evidence, the Wilcoxon test gives sufficient evidence: using the sizes makes the Wilcoxon test more powerful
Examiner trap

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.

Stage 1 · Learn

Check your understanding

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

In a signed-rank test with \(n = 12\), \(P = 50\). What is \(Q\)?

Quick check+10 XP

Why is the Wilcoxon signed-rank test valid only for a symmetric population?

Quick check+10 XP

The differences from \(m_0\) are -3.1, 1.4, 2.2, -0.6, 4.5. Find \(P\).

Quick check+10 XP

For \(n = 9\), a two-tailed test at 5% has critical value 5. The sample gives \(T = 6\). The correct decision is

Section 03

Large samples: the normal approximation.

Under \(H_0\) each rank \(r\) is added to \(P\) with probability \(\tfrac{1}{2}\), independently. So \(E(P) = \tfrac{1}{2}\sum r = \tfrac{n(n + 1)}{4}\) and \(\operatorname{Var}(P) = \tfrac{1}{4}\sum r^{2} = \tfrac{n(n + 1)(2n + 1)}{24}\), and the same holds for \(Q\) and \(T\). When \(n\) is too large for the table (beyond 20), use \(T \approx N\!\left(\tfrac{n(n + 1)}{4},\ \tfrac{n(n + 1)(2n + 1)}{24}\right)\). \(T\) takes whole-number values, so apply a continuity correction: \(P(T \le t)\) becomes \(P(\text{normal} < t + 0.5)\).

Worked example One-tailed with n = 30
A signed-rank test on \(n = 30\) differences gives \(T = 140\), where \(T\) is the sum that should be small under \(H_1\). Test at the 5% level.
  1. \[\begin{aligned} E(T) &= \tfrac{30 \times 31}{4} = 232.5 \\ \operatorname{Var}(T) &= \tfrac{30 \times 31 \times 61}{24} = 2363.75 \end{aligned}\]
  2. \[z = \frac{140.5 - 232.5}{\sqrt{2363.75}} = \frac{-92}{48.62} = -1.892\]
  3. One-tailed 5%: critical value \(-1.645\). \(-1.892 < -1.645\), so reject \(H_0\).
Answer: \(z = -1.89\): sufficient evidence at the 5% level to support \(H_1\)
Worked example Two-tailed with n = 25
A two-tailed Wilcoxon signed-rank test at 5% on 25 matched pairs gives \(P = 235\). Carry out the test.
  1. \(Q = \tfrac{25 \times 26}{2} - 235 = 325 - 235 = 90\), so \(T = 90\).
  2. \[\begin{aligned} E(T) &= \tfrac{25 \times 26}{4} = 162.5 \\ \operatorname{Var}(T) &= \tfrac{25 \times 26 \times 51}{24} = 1381.25 \end{aligned}\]
  3. \[z = \frac{90.5 - 162.5}{\sqrt{1381.25}} = \frac{-72}{37.17} = -1.937\]
  4. \(|z| = 1.937 < 1.96\), so do not reject \(H_0\).
Answer: Insufficient evidence at the 5% level of a difference between the populations (only just)
Your turn
Find \(E(T)\) and \(\operatorname{Var}(T)\) for \(n = 40\).
Examiner trap

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\).

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to AS & A Level Further Mathematics Paper 1 to 4 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

For a Wilcoxon signed-rank test with \(n = 40\), the normal approximation to \(T\) has

Exam style+20 XP

The median reaction time is claimed to be 20 ms. Seven values give differences from 20 of -4.1, -2.6, 1.3, -5.8, -0.9, -3.4, -6.2. Test \(H_1: m < 20\) at the 5% level (critical value 3).

Exam style+20 XP

A one-tailed matched-pairs test on 8 pairs gives \(T = 5\). The critical values for \(n = 8\) are 5 (5% level) and 3 (2.5% level). Which is correct?

Exam style+20 XP

A two-tailed signed-rank test at 5% on \(n = 24\) pairs gives \(T = 81\). Using a normal approximation, which is correct?

Skill unlocked

Signs and sizes ranked.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
The identity \(P + Q = \tfrac{1}{2}n(n + 1)\), a single-sample test for a median, two judges as matched pairs, the normal approximation, a head-to-head with the sign test and why tiny samples can never reject.