Wilcoxon Signed-Rank Test Calculator
Enter two paired samples (or ready-made differences) and this Wilcoxon signed-rank test calculator computes W⁺, W⁻, the z statistic with tie correction and continuity correction, the p-value, and the decision at your chosen significance level.
Compare Paired Measurements by Signed Ranks
Wilcoxon Signed-Rank Test Formula
Where:
- \(d_i\) — paired difference \(y_i - x_i\) (second measurement minus first)
- \(n\) — number of non-zero differences (pairs with \(d_i = 0\) are dropped)
- \(t\) — size of each group of tied absolute differences
- \(z\) — standardized statistic referred to the standard normal distribution; the \(-0.5\) term is the optional continuity correction
Under the null hypothesis of no systematic shift, positive and negative ranks should balance, so \(W^+\) is expected to equal \(\mu_W\). A \(W^+\) far from \(\mu_W\) produces a large \(|z|\) and a small p-value. The tie correction \(\sum(t^3-t)/48\) reduces the variance when several differences share the same absolute value.
Wilcoxon Signed-Rank Test – Calculation Example
Example: ten students scored 85, 92, 78, 88, 95, 82, 90, 76, 89, 84 on a first test (Sample 1) and 91, 90, 85, 95, 99, 86, 88, 79, 92, 82 on a second test (Sample 2). Testing the two-sided hypothesis at \(\alpha = 0.05\) with continuity correction:
\[ d_i = y_i - x_i = 6;\ -2;\ 7;\ 7;\ 4;\ 4;\ -2;\ 3;\ 3;\ -2 \quad \Rightarrow \quad n = 10 \]
\[ |d| = 2,2,2,3,3,4,4,6,7,7 \;\Rightarrow\; \text{ranks } 2,2,2,4.5,4.5,6.5,6.5,8,9.5,9.5 \]
\[ W^+ = 8+9.5+9.5+6.5+6.5+4.5+4.5 = 49, \qquad W^- = 2+2+2 = 6 \]
\[ \mu_W = \frac{10 \cdot 11}{4} = 27.5, \qquad \sigma_W^2 = \frac{10 \cdot 11 \cdot 21}{24} - \frac{42}{48} = 95.375 \]
\[ z = \frac{49 - 27.5 - 0.5}{\sqrt{95.375}} = \frac{21}{9.7658} = 2.1493 \]
\[ p = 2\left(1 - \Phi(2.1493)\right) = 0.0316 \]
Result: \(W^+ = 49\), \(W^- = 6\), \(W = 6\), \(z = 2.1493\), \(p \approx 0.0316 < 0.05\). Reject \(H_0\): the second test scores are systematically higher. The median paired difference is 3.5 points.
How to use the calculator
- Choose the Data format: “Two paired samples” if you have both measurements for each pair, or “Differences only” if you have already computed \(d_i\).
- Enter the first measurement of every pair into Sample 1 (first / before), one value per pair, separated by spaces, new lines or semicolons.
- Enter the matching values into Sample 2 (second / after), in the same order and the same count. Differences are computed as second − first. If you chose “Differences only”, type them into Paired differences (second − first) instead.
- Pick the Alternative hypothesis: two-sided for any systematic change, one-sided if you expect the second measurement to tend higher (> 0) or lower (< 0) than the first.
- Set the Significance level \(\alpha\) (0.05 by default) and leave Apply continuity correction checked for a more accurate approximate p-value.
- Read the results: \(n\), \(W^+\), \(W^-\), the test statistic \(W\), \(z\), the p-value, the decision at \(\alpha\), and the median of the paired differences, together with a full table of signed ranks.
What the Wilcoxon signed-rank test is
The Wilcoxon signed-rank test is a non-parametric test for comparing two paired measurements — before and after a treatment, two methods applied to the same subjects, matched pairs — when you cannot assume the differences are normally distributed. It is the distribution-free counterpart of the paired t-test.
The test works entirely on the differences \(d_i\). It asks not just whether differences tend to be positive or negative (that would be the weaker sign test) but also how large they are: each non-zero difference is ranked by absolute size, and the sign is attached to the rank. If the null hypothesis of no systematic shift is true, the positive and negative ranks should roughly balance, so \(W^+ \approx W^- \approx n(n+1)/4\). A strong imbalance — a large \(W^+\) with a small \(W^-\), or vice versa — is evidence of a consistent direction of change. Because the test uses ranks, it is robust to outliers and works for ordinal as well as numeric data with meaningful differences.
The p-value answers: if there were truly no systematic difference, how likely is a rank imbalance at least as extreme as the one observed? A small p-value (at or below \(\alpha\)) means the observed pattern is hard to explain by chance. Note that significance tells you a shift exists, not that it is large — always judge practical importance alongside the reported median of the paired differences and the raw data. If you want to quantify effect size rather than test a hypothesis, the paired structure of your data still applies, and the Cohen's d calculator is a common companion for the parametric version.
Assumptions, limitations and practical tips
- Pairing is essential. The observations must come in pairs measured on the same or matched units; two independent samples cannot be tested this way. For independent samples, a rank-sum test or the t-test for independent groups is appropriate.
- Independence between pairs. Each pair must be independent of the others. Repeated measurements on the same subject over several time points violate this and need a different approach.
- Symmetry of the differences. The test assumes the distribution of the \(d_i\) is roughly symmetric, so the hypothesis is genuinely about the median. With strongly skewed differences, the test still runs but the median interpretation weakens; check with the skewness and kurtosis calculator.
- Zeros and ties. Pairs whose difference is exactly 0 are dropped, reducing \(n\). Tied absolute differences receive mid-ranks, and the variance is corrected by \(\sum(t^3 - t)/48\). With very heavy ties the corrected variance can shrink to zero, in which case the normal approximation is undefined.
- Small samples. The p-value here uses the normal approximation with continuity correction, which is accurate from about \(n \ge 10\) but rough below that; with fewer non-zero differences, prefer an exact signed-rank test from a statistics package. The calculator warns you when \(n < 10\).
- One-sided hypotheses. “Median difference > 0” means the second measurement tends to be larger than the first. Choose a one-sided test only if that direction was specified before looking at the data.
- Binary paired outcomes (e.g. success/failure before and after) do not fit this test — use the McNemar's test calculator instead.
Frequently Asked Questions
Why is my W statistic different from what R, SPSS or Python reports?
Software reports the signed-rank statistic in different conventions. This calculator reports \(W\) as the smaller of \(W^+\) and \(W^-\); R reports \(W^+\) by default (statistic V in wilcox.test), and SPSS reports the smaller sum but labels it differently. Additionally, some packages use Pratt's method (keeping zeros with rank 0) instead of dropping zero differences. The p-values should agree closely once \(n \ge 10\) even if the statistic values differ. Convert by remembering \(W^+ + W^- = n(n+1)/2\).
Can I just halve the two-sided p-value to get a one-sided result?
Usually yes, but only approximately. Because the test statistic is discrete, the exact two-sided p-value is not always exactly twice the one-sided value, and the normal approximation used here can add small discrepancies. For a clean one-sided analysis, set the alternative hypothesis in the calculator directly — the p-value is then computed for that direction. Remember to choose a one-sided test only if you specified the direction before seeing the data; switching afterward inflates the Type I error rate.
What is the minimum sample size for the Wilcoxon signed-rank test?
The test is mathematically valid from as few as 3 non-zero differences, but the normal approximation used for the p-value is rough below \(n \approx 10\). For small samples, statistical packages can compute the exact p-value from the permutation distribution of the signed ranks, which is more accurate. As a rule of thumb, with \(n < 10\) you also have very low power — even a perfectly consistent set of differences may not reach significance at \(\alpha = 0.05\).
How do I report the Wilcoxon signed-rank test in a paper?
A typical APA-style sentence: "A Wilcoxon signed-rank test indicated a significant increase in scores after the intervention, \(z = 2.15\), \(p = .032\), median difference = 3.5 points." Include the statistic, p-value, sample size (specify how many zero differences were dropped), and a measure of effect size. Also report the median difference so readers can judge practical importance, since a significant p-value alone says nothing about the magnitude of the change.
What effect size can I compute from the Wilcoxon signed-rank test?
The most common one is the matched-pairs rank-biserial correlation \(r = 1 - 2W^- / [n(n+1)/2]\), which ranges from −1 to +1 and expresses the tendency of differences to be positive. Alternatively, \(r = |z| / \sqrt{n}\) can be derived directly from the reported z statistic. Values around 0.1, 0.3 and 0.5 are conventionally read as small, medium and large, though always interpret them in the context of your field.
Wilcoxon signed-rank test or paired t-test — which should I use?
Use the paired t-test when the differences are approximately normally distributed, because it has more statistical power and directly estimates the mean difference. Use the signed-rank test when the differences are skewed, contain outliers, or are ordinal — it tests the median and is robust to extreme values. You can check normality of the differences first (e.g. with a Q-Q plot or Shapiro-Wilk test); when in doubt, the signed-rank test is the safer choice, losing only a little power under normality.
Does the test compare medians or means?
Strictly, the Wilcoxon signed-rank test tests whether the distribution of the differences is symmetric around zero. When the differences are roughly symmetric, median and mean coincide, so it can be read as a test of the median difference (and then also of the mean). With strongly skewed differences, the median and mean diverge and the test no longer cleanly targets either — report the median difference and describe the skew, or consider a transformation or the sign test, which tests the median without any symmetry assumption.