Wilcoxon Signed-Rank Test Calculator

Test whether paired measurements differ, using ranks instead of the raw values, with the z score, the p value and the shift.

Math and PercentUpdated 2026-10-224 min read
Wilcoxon Signed-Rank Test Calculator
At least 5 paired values, separated by commas, for example 30, 28, 35, 26, 32, 24, 29, 31.
The matching values in the same order, so each entry pairs with the one in the first box.
The usual choice is 0.05. The tool compares the p value with this number.
Sum of the positive ranks
...
Sum of the negative ranks...
Test statistic W...
z score...
p value...
Hodges-Lehmann estimate...
Median of the differences...
Reading of the result...

What it does

Sometimes the data comes in pairs rather than in two separate groups. A blood pressure before and after a drug, a score before and after teaching, the same machine measured on two days. When the pairing matters, the Wilcoxon signed rank test is the standard tool, and it needs no assumption about the shape of the data.

The procedure is short. Take the difference inside each pair, drop the pairs where the two values are exactly equal, and rank what is left by its size while ignoring the sign. Then put the signs back and add the ranks of the positive differences to get W plus, and the ranks of the negative differences to get W minus. The NIST Dataplot reference describes the test statistic as the smaller of the two sums, and the null hypothesis as the two population means being equal.

The reason it works is that the ranks carry the ordering and the signs carry the direction, and neither of those depends on the distribution. If the pairing makes no difference, the signs fall as often to the left as to the right, and the reference notes that there are two to the n ways of assigning signs to n ranks, all of them equally likely. That is what the p value is built from.

For bigger samples the exact distribution is replaced by the normal approximation. The same NIST page gives the mean of the test statistic as n times n plus one over four, and the standard deviation as the square root of n times n plus one times two n plus one over 24, with the critical region then read from the normal table.

This page does the whole chain for paired samples: the difference list, the rank sums, the test statistic, the z score with a tie correction and a continuity correction, the p value for a two sided or one sided test, and two ways of describing the size of the shift. It is the paired partner of the rank sum test, which compares two unrelated samples.

How to use

  1. Paste the first sample into the first box and the matching second sample into the second box, keeping the pairs in the same order.
  2. Choose the alternative hypothesis. Use two sided if you only care whether the pairs differ.
  3. Set the significance level, which is 0.05 unless your field uses another value.
  4. Read the two rank sums and the test statistic W, which is the smaller of them.
  5. Read the z score and the p value, then check the verdict against the significance level you set.
  6. Read the Hodges-Lehmann estimate and the median difference to quote the size of the shift in the units of your own data.

Formula

Rank sums: W plus is the sum of the ranks of the positive differences and W minus the sum of the ranks of the negative ones. The test statistic is W = the smaller of the two, and z = (W plus - mean) over the standard deviation.
W plus
Sum of the ranks of the differences that came out positive.
W minus
Sum of the ranks of the differences that came out negative.
n
Number of pairs whose two values differ exactly.
mean
Expected value of the rank sum under the null hypothesis, n times n plus one over four.
standard deviation
Square root of n times n plus one times two n plus one over 24, with a correction for tied ranks.

The tie correction subtracts the sum of t cubed minus t for each group of tied ranks from the variance, and the continuity correction moves the statistic half a step back towards the mean before the z score is formed. The Hodges-Lehmann estimate is the median of the n times n plus one over two averages of pairs of differences, and it is the location estimate that goes with this test.

Worked example

Example: eight pairs of scores before and after a course

Defaults: a first sample of 30, 28, 35, 26, 32, 24, 29, 31 and a second sample of 24, 22, 29, 25, 21, 27, 20, 23, a two sided test and a significance level of 0.05.

  1. The differences, first sample minus second, are 6, 6, 6, 1, 11, -3, 9 and 8, and none of the pairs is exactly equal.
  2. Rank the absolute differences, which are 1, 3, 6, 6, 6, 8, 9 and 11. The three 6s share the ranks 3, 4 and 5, so each takes 4.
  3. That gives the ranks 1, 2, 4, 4, 4, 6, 7 and 8 for the differences 1, 3, 6, 6, 6, 8, 9 and 11.
  4. The positive differences carry the ranks 4, 4, 4, 1, 8, 7 and 6, so W plus is 34, and the single negative difference carries rank 2, so W minus is 2.
  5. The test statistic is the smaller sum, 2, and the expected value is n times n plus one over four = 18.
  6. The tie correction takes 27 minus 3 = 24 off the variance, so the standard deviation is the square root of 8 x 9 x 17 minus 24 over 24, which is 7.0711, and z = (34 - 18 - 0.5) / 7.0711 = 2.1920.
  7. The two sided p value is 0.0284, which is below 0.05, and the tool shows 34, 2, 2, 2.1920, 0.0284, 6.0000, 6.0000 and a result that is significant at 0.05.

Reference table

What the z score means for the p value, on both the two sided and the one sided reading
Absolute zTwo sided pOne sided pUsual reading
1.6450.1000.050marginal evidence
1.9600.0500.025the usual 5 % cut
2.5760.0100.005strong evidence
3.2910.0010.0005very strong evidence

Limits

  • The test needs paired data. If the pairs are not related, use the rank sum test for two independent samples instead.
  • The normal approximation used here needs a reasonable number of pairs. With five or fewer pairs the exact tables are the right reference.
  • It compares the location of the pairs, so it says nothing about how large the differences are, only their direction and order.
  • The p value does not tell you how important the change is in practice, and it carries no correction for running the test many times.

Common mistakes

  • Ranking the raw values instead of the absolute differences. The signs are put back afterwards, not before.
  • Keeping the pairs where the two values are exactly equal. Those pairs carry no direction and the reference leaves them out.
  • Forgetting the tie correction when several differences have the same size, which makes the p value too small.
  • Using the signed rank test on two unrelated groups, where the pairing is meaningless.
  • Reading the p value as the size of the effect. The Hodges-Lehmann estimate and the median difference are what describe the size of the shift.

Try it yourself

Quick checks. Answers sit tucked under each question.

What changes if the alternative hypothesis is that the first sample is higher?

The z score stays at 2.1920, because the data have not changed, but the p value halves to 0.0142. A one sided test only counts one tail of the normal distribution, so the p value is exactly half of the two sided 0.0284.

How much did the pairs change?

The median of the eight differences is 6.0000, and the Hodges-Lehmann estimate, which is the median of the Walsh averages, is 6.0000 as well. Seven of the eight differences were positive and one was negative, so the typical pair moved by 6 in the direction of the first sample.

What does the test statistic of 2 mean here?

W is the smaller of the two rank sums, so it is the 2 from the single negative difference against 34 from the seven positive ones. The expected value under the null hypothesis is 18, so a statistic of 2 is far into the tail and the result comes out significant.

Questions

What is the Wilcoxon signed rank test for?

It tests whether paired measurements differ in location, without assuming that the differences are normally distributed. It is the paired counterpart of the t test for two independent samples.

How is the test statistic worked out?

Rank the absolute differences, put the signs back, and add the ranks of the positive differences and of the negative differences. The test statistic is the smaller of the two sums, and the null hypothesis is that the two sums should be about equal.

What is the Hodges-Lehmann estimate?

The median of the averages of every pair of differences, which is the location estimate that belongs with this test. The University of Minnesota course notes behind this page describe it as the point estimate associated with the signed rank test.

What happens to pairs where the two values are exactly equal?

They are left out of the test, because a zero difference carries no direction. The NIST reference notes that tied values are not included, and the tool reports how many pairs were dropped.

When do I need the exact tables instead of the normal approximation?

With few pairs. The NIST page says the critical regions are tabulated for small samples and that the normal approximation takes over for the larger ones, and the tool asks for at least 5 pairs that differ.

Does the test need the data to be normal?

No. The test only uses the order of the values, which is why it is the standard answer when the t test assumptions are not met.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.