Rank test, paired data

Wilcoxon signed rank test calculator

Test paired data without assuming the differences are normal. The Wilcoxon signed rank test ranks the absolute differences and compares the ranks of the positive and negative ones. Exact p for fewer than 50 pairs with no ties or zeros.

  • Exact p for small samples
  • Zero differences dropped, as R does
  • V statistic as R reports it

Sources checked on November 21, 2026. Results computed by the site's engine and tested against R and SciPy.

Paste a column from a spreadsheet, or type numbers separated by spaces, commas or new lines.

Wilcoxon signed rank test First visit minus Second visit, one-sided, greater

V (sum of positive ranks)40
Pairs used9
p (one-sided, greater)0.0195

At the 5% level, there is evidence of a positive shift in the differences.

V can run from 0 to 45; the negative ranks sum to 5. p from the exact distribution (no ties or zeros, fewer than 50 pairs). SciPy's default skips the continuity correction, so its approximate p can differ slightly from R's.

Reproduce this result in R or Python

R

x <- c(1.83, 0.5, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3)
y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
wilcox.test(x, y, paired = TRUE, alternative = "greater")   # V = sum of positive ranks

Python (SciPy)

from scipy.stats import wilcoxon
print(wilcoxon([1.83, 0.5, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3], [0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29], alternative="greater"))   # prints V, the sum of positive ranks

When to use it

Use the signed rank test in place of the paired t-test when you have few pairs and the differences are skewed or include outliers. It uses the size order of the differences and their signs, not their exact values. It asks whether the differences are centered on zero, which for symmetric differences is a test of the median difference.

Worked example: depression scores

The calculator opens with the paired example in R's wilcox.test help page, from Hollander and Wolfe (1973): Hamilton depression scale scores for 9 patients at a first and a second visit after treatment began. The question is whether scores fell, so the first visit should be greater.

Each difference (first minus second) is ranked by its absolute size. The positive differences hold ranks summing to V = 40, out of a possible 45. With 9 pairs, no ties and no zeros, the exact one-sided p is 0.0195, which is 10 out of the 512 equally likely sign patterns. R prints V = 40, p-value = 0.01953. At the 5% level there is evidence that scores were lower at the second visit.

How V is built

  1. Subtract: d = first minus second for each pair.
  2. Drop pairs with d = 0 (R's default; the result says how many were dropped).
  3. Rank the absolute differences from smallest to largest, giving tied values their average rank.
  4. Add the ranks of the positive differences. That sum is V.
  5. Compare V with its distribution when signs are random: exact for small samples, normal approximation otherwise.

Exact p, ties and zeros

With fewer than 50 pairs and no ties or zeros, the calculator counts every possible sign pattern, as R does. With ties or zeros it uses the normal approximation with a tie correction and a continuity correction, again following R's defaults. SciPy's wilcoxon drops zeros by default too, but does not apply the continuity correction unless asked, and for two-sided tests it reports the smaller of the two rank sums rather than V. For this example its two-sided statistic is 5 with p = 0.0391.

Compared with the paired t-test

The one-sided paired t-test on the same scores gives t = 3.04 and p = 0.0081. Both tests point the same way. The signed rank test gives up a little power when the differences are normal, and gains robustness when they are not.

Reporting

Give V (or the statistic your software prints), the number of pairs used, the direction, and p: for example, V = 40, n = 9, p = .020 (one-sided, exact). Describe the data with the median difference. Say how many zero differences were dropped, if any.

Sources