Wilcoxon Signed-Rank Test Calculator
Paste two matched columns, such as pain scores before and after treatment…
Paste two matched columns, such as pain scores before and after treatment, to test the change by rank when a paired t-test’s normal curve doesn’t fit.
Read 10 values; left out the header row (“Pain before”).
Read 10 values; left out the header row (“Pain after”).
More optionsTwo-sided, 95% confidence
The significance level is 1 − the confidence level (0.05 at 95%).
ExampleP-value
0.0078
Pain after is lower than Pain before in 8 of 10 pairs (2 unchanged); typical change −2 (Hodges–Lehmann). Significant at the 5% level (p < 0.05).
Paste your own numbers to test them.
Each line joins one pair, from before to after; straight-down lines are pairs that didn’t change.
Every value W+ could take if each change were equally likely to go up or down; the lit bars are as extreme as yours or more.
- W+ · W−
- 0 · 36
- Rank-biserial r
- −1
- Method
- Exact, all 256 sign patterns
How this works: 9 sources,
How this works
Method
The Wilcoxon signed-rank test is the rank-based partner of the paired t-test: the same before-and-after or matched data, judged by the ranks of the changes rather than their average. It suits ratings such as a 0 to 10 pain score, small samples, or changes with a long tail. In the example, ten patients rated their pain before and after a course of physiotherapy; eight felt better, two felt the same and nobody felt worse. Full method
Sources
- Wilcoxon, Individual comparisons by ranking methods (Biometrics Bulletin, 1945)
- Wikipedia, Wilcoxon signed-rank test
- NIST/SEMATECH e-Handbook of Statistical Methods
- Abramowitz and Stegun, Handbook of Mathematical Functions, chapters 6, 7 and 26 (1964)
- SciPy 1.18 scipy.stats (reference values for the tests)
- statsmodels 0.15 (reference values for the A/B test and regression intervals)
- Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika) (1947)
- Fleiss, Levin and Paik, Statistical Methods for Rates and Proportions, 3rd edition (sample size for two proportions) (2003)
- Hyndman and Fan, Sample quantiles in statistical packages (The American Statistician) (1996)
How it’s tested
2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.
How the Wilcoxon signed-rank test works
The Wilcoxon signed-rank test is the rank-based partner of the paired t-test: the same before-and-after or matched data, judged by the ranks of the changes rather than their average. It suits ratings such as a 0 to 10 pain score, small samples, or changes with a long tail. In the example, ten patients rated their pain before and after a course of physiotherapy; eight felt better, two felt the same and nobody felt worse.
Work out each pair’s difference, drop the pairs that didn’t change, and rank the rest by size, ignoring the sign, with ties sharing the average rank. W+ adds up the ranks of the increases and W− the ranks of the decreases. If the treatment did nothing, each difference would be as likely to go up as down, so W+ would sit near n(n + 1)/4. Here every remaining change is a decrease, so W+ = 0 and W− = 36, as extreme as eight changes can be.
With few pairs the p-value is exact: the page counts all 2ⁿ ways the signs could have fallen (256 here), as SciPy does for up to 13 pairs with ties, or up to 50 without. Larger samples use the normal approximation with a tie correction. The Hodges–Lehmann estimate, the median of every pairwise average of the differences, gives the typical change in the data’s own units: 2 points of pain here.
W+ = Σ ranks of |dᵢ| with dᵢ > 0 · under no change, E(W+) = n(n + 1)/4
- Frank Wilcoxon introduced the signed-rank test and the rank-sum test in a four-page paper in 1945. Source: Wilcoxon, Individual comparisons by ranking methods (Biometrics Bulletin, 1945).
- The test ranks the absolute differences of the pairs, sums the ranks of the positive ones, and compares the sum with its distribution when each sign is equally likely; pairs with no difference are usually dropped. Source: Wikipedia, Wilcoxon signed-rank test.
Exact critical values of W (two-sided, 5%)
With n changed pairs and no ties: the smaller of W+ and W− must be at most this value for p ≤ 0.05, with the exact p-value at that value, from all 2ⁿ sign patterns.
| Pairs (n) | Sign patterns | Critical W | Exact p at it |
|---|---|---|---|
| 5 | 32 | none | — |
| 6 | 64 | 0 | 0.0313 |
| 7 | 128 | 2 | 0.0469 |
| 8 | 256 | 3 | 0.0391 |
| 9 | 512 | 5 | 0.0391 |
| 10 | 1,024 | 8 | 0.0488 |
| 12 | 4,096 | 13 | 0.0425 |
| 15 | 32,768 | 25 | 0.0479 |
| 20 | 1,048,576 | 52 | 0.0484 |
| 25 | 33,554,432 | 89 | 0.0483 |
Show all 11 rowsShow fewer
| 30 | 1,073,741,824 | 137 | 0.0497 |
Common questions
Wilcoxon signed-rank or paired t-test?
The paired t-test when the differences are roughly symmetric and measured on a real scale; it tests the mean change. The signed-rank test when the data are ratings, the sample is small and skewed, or a few large changes would dominate a mean. On the example both agree; the t-test’s p is about 0.0015.
What happens to pairs with no change?
They are dropped, Wilcoxon’s original rule and SciPy’s default, and the page says how many. With many unchanged pairs, report them too: “8 improved, 2 unchanged, none worse” says more than a p-value.
Is this the same as the Wilcoxon rank-sum test?
No. The rank-sum test (Mann-Whitney U) compares two independent groups. The signed-rank test is for paired data: the same people or things measured twice.