What this calculator does
This calculator runs the Wilcoxon signed-rank test on one sample or on paired samples. It computes the differences, drops zeros, ranks the absolute differences (average ranks for ties), and reports W+, W-, the statistic W, a normal-approximation Z, a p-value and a decision. It suits students and analysts who need a nonparametric alternative to the one-sample or paired t-test when normality is doubtful.
How to use it
Enter Sample X as numbers separated by commas, semicolons, spaces or new lines. Enter Sample Y in the same order and count for a paired test, or a single - for a one-sample test. Set the hypothesized value or difference d0 (usually 0). Choose the alternative: two-sided, greater or less. Select the significance level alpha.
Formula
Each difference is formed first, then ranked by absolute value:
$$d_i = x_i - y_i - d_0 \qquad (\text{one-sample: } d_i = x_i - d_0)$$
$$W = \min(W^+, W^-), \quad \mu_W = \frac{n(n+1)}{4}, \quad \sigma_W = \sqrt{\frac{n(n+1)(2n+1)}{24}}, \quad Z = \frac{W - \mu_W}{\sigma_W}$$
Here \(W^+\) and \(W^-\) are the sums of ranks of positive and negative differences, and \(n\) is the number of nonzero differences. The two-sided p-value is \(p = \min(1, 2\Phi(Z))\). For the greater alternative, \(Z\) uses \(W^+\) and \(p = 1 - \Phi(Z)\); for less, \(p = \Phi(Z)\).
Conventions and assumptions
- Differences equal to zero are omitted before ranking, after rounding each difference to 10 decimals so floating-point noise counts as zero.
- Tied absolute differences receive the average of the ranks they span.
- The normal approximation is used for every n, with no tie correction and no continuity correction. A warning appears when n is 30 or less.
- The null hypothesis is rejected when p is below alpha.
- The differences are assumed independent, symmetric about the median and measured on at least an interval scale.
- The normal CDF is computed from a high-accuracy complementary error function.
Worked example
One-sample test with X = 1.2, -0.5, 2.3, 0.8, 1.9, -0.3, 1.1, 2.6, \(d_0 = 0\), two-sided, \(\alpha = 0.05\). There are no zero differences, so \(n = 8\), with 6 positive and 2 negative differences.
$$W^+ = 33, \quad W^- = 3, \quad W = 3$$
$$\mu_W = \frac{8 \times 9}{4} = 18, \quad \sigma_W = \sqrt{\frac{8 \times 9 \times 17}{24}} = 7.1414$$
$$Z = \frac{3 - 18}{7.1414} = -2.1004, \quad p = 2\Phi(-2.1004) = 0.0357$$
Since 0.0357 is below 0.05, the decision is reject. The small-sample warning is true because n is 8.
Reading the result and limitations
A small p-value indicates that the differences are unlikely to be centred on d0 if the null hypothesis holds. A large p-value means the data do not show sufficient evidence of a shift; it does not prove there is none. For n of 30 or less, exact tables or exact p-values are the usual reference, so the normal approximation here can differ from them, especially with many ties, since the standard deviation has no tie correction. If all differences are zero the test cannot be computed.
FAQ
When should I use this instead of a t-test?
Use it when differences are not normally distributed but are roughly symmetric, or when the data are only ordinal-like with meaningful ranks of differences.
How are zero differences handled?
They are removed and n is reduced accordingly. The count of omitted zeros is reported.
How are ties handled?
Tied absolute differences share the average of their ranks, which can produce half-integer rank sums.
Why is the two-sided Z never positive?
Z is based on W, the smaller of W+ and W-, which cannot exceed the mean. If W+ equals W-, the two-sided p-value is 1.
Is the p-value exact for small samples?
No. It is a normal approximation, and a warning is shown when n is 30 or less.
Sources
- Signed Rank Test (Dataplot reference manual), NIST/SEMATECH Dataplot, 2023