Derivation of the Test Statistic for the Wilcoxon Signed-Rank Test

Exploring the cinematic intuition of Derivation of the Test Statistic for the Wilcoxon Signed-Rank Test.

Visualizing...

Our institutional research engineers are currently mapping the formal proof for Derivation of the Test Statistic for the Wilcoxon Signed-Rank Test.

Apply for Institutional Early Access →

The Formal Theorem

Let (D1,,Dn) (D_1, \dots, D_n) be a random sample of n n differences, where Di=XiYi D_i = X_i - Y_i for paired data or Di=XiM0 D_i = X_i - M_0 for one-sample data against a hypothesized median M0 M_0 . Let Di |D_i| denote the absolute differences, and let Ri R_i be the rank of Di |D_i| when all n n non-zero absolute differences are ranked from smallest to largest (observations with Di=0 D_i = 0 are typically removed, reducing n n ). Define an indicator variable Si S_i such that Si=1 S_i = 1 if Di>0 D_i > 0 and Si=0 S_i = 0 if Di<0 D_i < 0 . The Wilcoxon Signed-Rank test statistic, W W , is defined as the sum of the ranks corresponding to positive differences:
W=i=1nRiSi W = \sum_{i=1}^n R_i S_i
Under the null hypothesis H0 H_0 that the population median of the differences is zero (i.e., the distribution of differences is symmetric about zero), the expected value of W W is:
E[W]=n(n+1)4 E[W] = \frac{n(n+1)}{4}
And the variance of W W is:
Var[W]=n(n+1)(2n+1)24 Var[W] = \frac{n(n+1)(2n+1)}{24}
For large n n , W W can be approximated by a normal distribution, leading to the standardized test statistic Z Z :
Z=WE[W]Var[W] Z = \frac{W - E[W]}{\sqrt{Var[W]}}

Analytical Intuition.

Imagine a highly sensitive analytical scale, calibrated to detect even the most subtle imbalances. Our experimental data, consisting of n n paired observations or n n measurements compared to a hypothesized median M0 M_0 , generates a set of differences Di D_i . Each Di D_i is a 'deviation' from neutrality. First, we strip away the initial judgment, focusing solely on the magnitude of these deviations. We rank the absolute differences Di |D_i| , assigning higher ranks to larger deviations. This is akin to gauging the 'weight' of evidence each difference presents. Next, we reintroduce the 'direction' of the deviation – positive or negative. Under the null hypothesis, a perfect symmetry is expected; a positive deviation is just as likely as a negative one of the same magnitude. The test statistic W W then sums up the ranks only for those differences that are positive. If our sample truly reflects the null hypothesis, we'd expect the sum of positive ranks W W to be roughly half the total possible sum of ranks, as positive and negative deviations should balance out. A significantly higher or lower W W signals a departure from this symmetry, suggesting a real effect. The derivation then quantifies this 'expected balance' and its natural variability under pure chance, providing the bedrock for our statistical decision.
CAUTION

Institutional Warning.

A common point of confusion arises from the definition of the test statistic W W . Some texts define it as W+ W^+ (sum of positive ranks), while others use W W (sum of all signed ranks, where Di<0 D_i<0 corresponds to Ri -R_i ). Ensure clarity on which definition is being used, as it affects the expected value.

Academic Inquiries.

01

Why use ranks instead of the raw differences themselves?

The use of ranks makes the Wilcoxon Signed-Rank test non-parametric. It mitigates the disproportionate impact of outliers and allows the test to be valid even when the underlying distribution of the differences is not normal. It assesses the median difference rather than the mean difference, providing a robust inference for location shifts.

02

How are tied absolute differences or zero differences handled?

For tied absolute differences, the standard procedure is to assign the average of the ranks they would have received if they were distinct (the 'midrank' method). For zero differences (where Di=0 D_i = 0 ), these observations are typically removed from the analysis before ranking, and the sample size n n is reduced accordingly, as they provide no information about the direction of the difference.

03

What is the key assumption underpinning the derivation of E[W] E[W] and Var[W] Var[W] ?

The critical assumption under the null hypothesis is that each non-zero difference Di D_i has an equal probability (0.5 0.5 ) of being positive or negative, independent of its magnitude or the signs of other differences. This implies symmetry of the distribution of differences around zero, allowing us to treat the signs Si S_i as independent Bernoulli(0.5) random variables, whose ranks are fixed once the absolute differences are ordered.

Standardized References.

  • Definitive Institutional SourceConover, W. J. (1999). Practical Nonparametric Statistics (3rd ed.). John Wiley & Sons.

Institutional Citation

Reference this proof in your academic research or publications.

NICEFA Visual Mathematics. (2026). Derivation of the Test Statistic for the Wilcoxon Signed-Rank Test: Visual Proof & Intuition. Retrieved from https://nicefa.org/library/applied-statistics/derivation-of-the-test-statistic-for-the-wilcoxon-signed-rank-test

Dominate the Logic.

"Abstract theory is just a movement we haven't seen yet."