Quant Memo
Core

The Wilcoxon Signed-Rank Test

A paired-comparison test that works on the ranks of the differences rather than their raw sizes, so a few outlier days can't dominate the result the way they would in a paired t-test.

Prerequisites: Hypothesis Testing, Rank Transforms and Uniformisation

You want to know whether a new hedging rule reduces daily P&L variance compared to the old rule, tested on the same 12 trading days (old rule and new rule both simulated on each day, so the comparisons are paired). A paired t-test would compare the mean of the 12 differences to zero, but it's sensitive to the exact size of each difference — one wild day where the new rule did dramatically better can single-handedly drag the mean and inflate the apparent effect, or a similarly wild bad day can wash it out. The Wilcoxon signed-rank test asks a more modest, more robust question: not "how big are the differences on average," but "are the differences, whatever their size, more often positive and more often large-in-rank than you'd expect if the rule made no difference at all."

An analogy: judging by order, not by inches

Two runners race on 12 different days. Instead of averaging the exact time gaps (where one freak 10-minute gap on a rainy day could dominate the whole comparison), you rank all 12 gaps by their size regardless of sign, then check whether the biggest gaps tend to favor the same runner. If runner A wins most of the days and wins the days with the largest gaps, that's a much more convincing pattern than one enormous gap on a single day propping up an otherwise mixed record. The Wilcoxon signed-rank test formalizes exactly this: rank the differences by absolute size, then see whether the ranks belonging to positive differences add up to much more (or less) than they would under pure chance.

The idea, one symbol at a time

For paired data with differences Di=XiYiD_i = X_i - Y_i (dropping any zero differences), rank the Di|D_i| from smallest to largest to get ranks RiR_i, then compute the signed-rank statistic

W+=i:Di>0Ri,W^+ = \sum_{i: D_i > 0} R_i,

the sum of ranks belonging to positive differences only. In plain English: throw away the exact magnitude of each difference and keep only its rank and its sign, then add up the ranks of the differences that went the "positive" direction. Under the null hypothesis that positive and negative differences are equally likely (no systematic effect), W+W^+ has a known distribution — for even moderate nn, approximately normal with mean n(n+1)/4n(n+1)/4 and variance n(n+1)(2n+1)/24n(n+1)(2n+1)/24 — letting you compute a p-value for how extreme the observed W+W^+ is.

Worked example 1: six paired days by hand

Suppose 6 paired P&L differences (new rule minus old rule, in $k): +2.1,0.3,+1.5,+0.8,0.1,+3.0+2.1, -0.3, +1.5, +0.8, -0.1, +3.0. Ranking by absolute value: 0.10.1 \to rank 1, 0.30.3 \to rank 2, 0.80.8 \to rank 3, 1.51.5 \to rank 4, 2.12.1 \to rank 5, 3.03.0 \to rank 6. The positive differences are 2.12.1 (rank 5), 1.51.5 (rank 4), 0.80.8 (rank 3), 3.03.0 (rank 6): W+=5+4+3+6=18W^+ = 5+4+3+6 = 18. Under the null, mean W+=6(7)/4=10.5W^+ = 6(7)/4 = 10.5 and variance =6(7)(13)/24=22.75= 6(7)(13)/24 = 22.75, so standard deviation 4.77\approx 4.77. The z-score is (1810.5)/4.771.57(18 - 10.5)/4.77 \approx 1.57, giving a two-sided p-value around 0.120.12 — suggestive that the new rule tends to do better, but not conventionally significant with only 6 days of data.

Worked example 2: why an outlier doesn't dominate

Now replace the +3.0+3.0 difference with an extreme +30.0+30.0 (one freak day). A paired t-test's mean difference would jump dramatically, since it's driven by the raw magnitude. But the Wilcoxon statistic barely changes: +30.0+30.0 is still just the single largest absolute difference, so it still gets rank 6 — exactly the same as before. W+W^+ stays at 18, and the p-value is unchanged. The signed-rank test only cares that this difference was the largest in magnitude and positive, not by how much; a rank-based test is deliberately blind to exactly this kind of magnitude distortion.

|D| rank sign 0.11- 0.32- 0.83+ 1.54+ 2.15+ 3.06+ W+ = 3+4+5+6 = 18
Absolute differences are ranked, and only the ranks of positive differences are summed to give W+ — the raw \$ sizes never enter the calculation once ranking is done.

Distribution · normal
0.9610.5020.04μvalue →
Within ±1σ 68.3%mean μ 10.50std σ 4.77

The normal curve above (mean 10.5, sd 4.77) is the large-sample approximation to W+'s null distribution for this example — the observed W+=18 sits about 1.57 standard deviations above center.

What this means in practice

The Wilcoxon signed-rank test is a standard default whenever comparing two paired strategies, models, or time periods on a small or heavy-tailed sample — before-and-after backtests, paired daily P&L comparisons, or any small-sample paired evaluation where a t-test's normality assumption is doubtful. It trades some statistical power (it needs somewhat more data than a t-test to detect a genuinely normal-shaped effect) for robustness against outliers and non-normal shapes.

The Wilcoxon signed-rank test replaces the raw sizes of paired differences with their ranks, then checks whether positive differences carry more total rank than chance would predict — making the result far less sensitive to any single outlier difference than a paired t-test would be.

The test assumes the distribution of differences is symmetric around its median under the null — if positive and negative differences have systematically different shapes (not just different signs), the test can be misleading even though it's often described as fully "distribution-free." Ties (equal-magnitude differences) also require a correction to the variance formula; ignoring them, or ignoring exact zero differences instead of dropping them, silently biases the p-value.

Related concepts

Practice in interviews

Further reading

  • Wilcoxon, 'Individual Comparisons by Ranking Methods', Biometrics Bulletin
  • Hollander, Wolfe & Chicken, Nonparametric Statistical Methods, ch. 3
ShareTwitterLinkedIn