Wilcoxon signed-rank test calculator
Paste paired measurements for the same subjects, or one sample of differences. The Wilcoxon signed-rank test ranks the absolute differences and sums the signed ranks. You get W+ and W−, the exact p value for small samples without ties or zeros, the normal approximation p values, the z statistic, and the matched-pairs rank-biserial effect size.
Enter the two paired columns, or a single column of differences. The calculator returns the midranks of the absolute differences, W+ (sum of positive ranks), W− (sum of negative ranks), the exact p value when there are no ties or zeros and n is at most 30, the tie-corrected asymptotic p value, the z statistic, and the matched-pairs rank-biserial correlation r = (W+ − W−)/(n(n+1)/2). On the R documentation example, the Hamilton depression scale data of Hollander and Wolfe (1973, 29f), the page gives W+ = 5, W− = 40, the exact two-sided p value 0.0390625 and the asymptotic two-sided p value 0.0382. The table below shows each value.
Updated 2026-11-16
Calculator
The R documentation example
The example data come from the R manual for wilcox.test: the Hamilton depression scale factor measurements in 9 patients with mixed anxiety and depression, taken at the first (x) and second (y) visit after initiation of a therapy. The example is Hollander and Wolfe (1973), 29f. R runs wilcox.test(x, y, paired = TRUE, alternative = "greater") and wilcox.test(y - x, alternative = "less"), and marks the second call as the same test. R defines V as the sum of the ranks of the positive differences, so V = 40 for x − y and V = 5 for y − x. The table compares the page output with SciPy 1.13.1, with the R definition of V and with an exact enumeration. R manual, wilcox.test.
| Quantity | This page | Reference |
|---|---|---|
| W+ (sum of positive ranks of y − x) | 5 | V = 5, the statistic of wilcox.test(y - x, alternative = "less"), which sums the ranks of the positive values of y − x |
| W− (sum of negative ranks of y − x) | 40 | V = 40, the statistic of wilcox.test(x, y, paired = TRUE), which sums the ranks of the positive values of x − y |
| p, exact two-sided | 0.0390625 | 0.0390625 (SciPy 1.13.1 wilcoxon(x, y) and a full enumeration of all 512 sign assignments) |
| p, exact one-sided, y − x tends to be negative | Not shown (the page gives two-sided p values only) | 0.01953125 (SciPy wilcoxon(y, x, alternative = "less")) |
| p, asymptotic two-sided | 0.038152 | 0.038151710173415135 (SciPy wilcoxon(d, method = "approx")) |
| z statistic | −2.073221 | z = (W+ − 22.5)/8.440972 = −2.073221 |
| Matched-pairs rank-biserial r | −0.777778 | (5 − 40)/45 |
With n = 9 pairs and no zeros there are 2⁹ = 512 sign assignments of the ranks 1 to 9. The differences y − x are −0.952, 0.147, −1.022, −0.43, −0.62, −0.59, −0.49, 0.08, −0.01, so the absolute differences rank to 8, 3, 9, 4, 7, 6, 5, 2, 1. Only the ranks 2 and 3 add up on the positive side: W+ = 2 + 3 = 5. The two-sided exact p value counts the assignments with W+ ≤ 5 or W+ ≥ 40: 10 + 10 of 512, which is 20/512 = 0.0390625.
Zeros and ties, and what R and SciPy do
- Differences equal to zero carry no sign. This page drops them and reduces n accordingly, as SciPy does with the default
zero_method="wilcox". R changed this in version 4.6.0. Its source code says "In R < 4.6.0, we always removed zeros" and "Follow Pratt rather than Wilcoxon and do not remove zeros", so R can give a different p value when there are zeros. R says the Wilcoxon signed rank test is of "the null that the distribution of x (in the one sample case) or of x − y (in the paired two sample case) is symmetric about mu". - Equal absolute differences get the average (mid) rank. The W statistic uses these mid ranks.
- With ties or dropped zeros present, this page does not calculate the exact p value. It computes the exact p value only when all differences are nonzero and no absolute difference occurs more than once and n is at most 30. With ties or zeros, it shows only the tie-corrected asymptotic p values and says so.
- R-devel does something different: "If there are ties, exact inference is performed using the conditional/permutation distribution given the observed ranks, using an implementation of the Streitberg–Röhmel shift algorithm". R also notes that "an exact p-value is computed if the samples contain less than 50 finite values". This page does not do that permutation calculation. R manual, wilcox.test.
- SciPy's default
zero_method="wilcox""Discards all zero-differences";zero_method="pratt""Includes zero-differences in the ranking process, but drops the ranks of the zeros", andzero_method="zsplit"splits the zero ranks between positive and negative. This page follows the "wilcox" behavior. SciPy manual, scipy.stats.wilcoxon.
Effect size, the matched-pairs rank-biserial correlation
Alongside the p value the page reports the matched-pairs rank-biserial correlation r = (W+ − W−)/(n(n+1)/2), which runs from −1 (every difference is negative) to +1 (every difference is positive). For the R example r = (5 − 40)/45 = −0.777778. Most of the rank weight is on the pairs where the second-visit value (y) is lower than the first-visit value (x). Kerby (2014, Comprehensive Psychology, volume 3, doi 10.2466/11.IT.3.1) calls this computation "the simple difference formula", and the Wikipedia article on the Wilcoxon signed-rank test uses it as the effect size for this test.
The calculator prints the midranks of the absolute differences with every result, so you can verify the rank assignment by hand before you trust the p values.
Wilcoxon signed-rank or the paired t test?
The SciPy manual calls the Wilcoxon signed-rank test "a non-parametric version of the paired T-test". For the paired t test itself, use the paired mode of the ABWex t-test calculator. The Wikipedia article compares the test with the sign test: "The Wilcoxon test is a more powerful alternative to the sign test because it considers the magnitude of the differences, but it requires this moderately strong assumption of symmetry." Do not confuse this test with the Wilcoxon rank-sum test. The R manual runs the rank-sum test when x and y are given and paired is FALSE, and calls it "equivalent to the Mann-Whitney test". It is for two independent samples. The SciPy manual lists scipy.stats.mannwhitneyu under "See also", and ABWex offers the Mann-Whitney U test calculator for that case.
Limits and accuracy
- The page calculates the exact p value with dynamic programming over the signed-rank distribution. It shows the exact p value only when there are no zeros and no ties and n is at most 30. The two-sided exact p value is 2 × P(W ≥ max(W+, W−)), with a maximum of 1.
- The asymptotic p values use the tie-corrected standard deviation σ² = n(n+1)(2n+1)/24 − Σ(t³ − t)/48, where t is the size of each group of equal absolute differences, and the normal distribution. z = (W+ − n(n+1)/4)/σ. The page shows two normal p values. The first has no continuity correction, as
scipy.stats.wilcoxon(method="approx")with its defaultcorrection=False. The second moves |W+ − n(n+1)/4| by 0.5 toward 0, but not below 0, as SciPy does withcorrection=True. - Values from −1,000,000,000 to 1,000,000,000 are accepted, with up to 10,000 values. The page sets its own exact limit of n = 30. SciPy uses the exact method when len(d) <= 50, and R when the sample has less than 50 finite values, so for n from 31 to 50 SciPy and R can report an exact p value where this page reports the normal approximation. The calculation runs in your browser and makes no network request.
- In paired mode the page rounds each difference at the 13th significant digit of the larger of the two values before it ranks. Thus 0.050000000000000044 and 0.05 get the same rank, and 123456789.0123 and 123456789.0124 keep different ranks. The SciPy manual warns that roundoff in x - y can give different ranks to values that are tied. The page rounds the rank sums, z, the rank-biserial r and the p values to 12 significant digits. A normal p value below 1e-300 is shown as "less than 1e-300".
Disclaimers
- Results are statistical estimates and not medical, business or financial advice.
- The reference example is the published R documentation example, and it names its source. The "Load a zeros example" and "Load a ties example" buttons load made-up values that only show how the page handles zeros and ties. They are not real measurements.
By Michael Lip, builder and maintainer of ABWex, open source at github.com/theluckystrike/abwex.com. Profile.
ABWex is a free A/B test statistics calculator from Zovo Tools. The calculation runs in your browser in JavaScript. The page does not send the numbers that you enter to a server. Published 2026-11-16.