The guide
The sign test counts which way each pair moved, and that is both its strength and its limit
The sign test asks only whether differences lean positive or negative. Its p-value is an exact binomial sum, ties must leave, and two order statistics can bracket a median with a coverage you can state exactly.
- 1 in 2^82 chance of 82 male-majority years if each year were a fair toss
- 0.109375 two-sided p for 8 plus signs out of 10
- 0.145996 two-sided p if two ties are counted as minus signs (right: 0.021484)
- 501/512 exact coverage of the 2nd to 9th value at n = 10
- 6 values smallest sample whose min to max reaches 95 percent
Read the full guide Fold the guide
A test that only asks which way
John Arbuthnot looked at London birth records for each of 82 years, from 1629 to 1710. In every single year, more boys than girls had been born.
If boys and girls were equally likely to be the larger group in a year, the chance of 82 male-majority years in a row is 1 in 2^82, which is about 4.8 times ten to the 24th. Arbuthnot concluded that the two sexes were not born in exactly equal proportions. Writers on the sign test, among them Conover and Sprent as the Wikipedia article reports, count this as an early use of the test. Conover is quoted there as calling it perhaps the first published report of a nonparametric test.
The reasoning has not changed in three centuries. Take pairs of measurements, such as a weight before and after treatment, or the length of a hind leg and a foreleg on the same animal. Subtract within each pair. Then count only the direction of each difference and ignore its size. Under the null idea, a positive and a negative difference are equally likely for a random pair. The number W of positive differences then follows a binomial distribution with n trials and probability one half. That is the whole machine.
The test makes few demands, but it makes some. The differences should be independent of each other and drawn from the same continuous population, and the comparisons “larger”, “smaller” and “equal” must mean something. The same test also works on a single list: you count how many values lie above a stated number, such as asking whether the median grade in a class differs from 75.
Why zeros leave and why the tail doubles
A pair with no difference has no sign, so it cannot vote. The standard method omits such pairs and carries on with the smaller number n of pairs that are left. The page records how many were dropped, because that count is part of the evidence.
Counting a tie as a minus sign is a quiet and common mistake. Take twelve pairs with 9 plus signs, 1 minus sign and 2 exact ties. Dropped properly, n is 10 and the two-sided p-value is 11/512, which is 0.021484. Counted as minus signs, n becomes 12 with 9 plus signs, and the same arithmetic gives 0.145996. One choice falls below the 5 percent line and the other lands near 15 percent.
Dropping zeros is a rule, not a law of nature. In the Wilcoxon signed-rank test, Wilcoxon himself later recommended removing zeros, and Pratt then showed that this can behave paradoxically. The article on that test adds that, from the viewpoint of statistical efficiency, there is no perfect rule for handling zeros. For the sign test the removal is the standard treatment, and the tool states it plainly.
Now the tails. Once n signs remain, the chance of exactly j plus signs is the binomial coefficient C(n, j) divided by 2^n, because every one of the 2^n sign patterns is equally likely when each sign has probability one half. The left tail Pr(W at most w) adds the terms from 0 up to w. The right tail Pr(W at least w) adds from w up to n.
For a two-sided alternative the p-value is twice the smaller tail, and it can never exceed 1. Doubling is legitimate here for a specific reason. The Binomial test article warns that for a success probability other than one half the distribution is lopsided and simple doubling is wrong. At one half the distribution is symmetric, so doubling counts the mirror-image outcomes exactly.
Every one of these sums is a fraction whose bottom is a power of two. The tool adds them as exact integers, using BigInt, which holds integers too large for an ordinary number. It runs them in a Web Worker, a background thread, so the page stays responsive even at n = 1,000. SciPy’s binomtest, run with probability one half, agreed with the tool’s one-sided and two-sided values to within 1e-12 on eight different counts.
Bracketing the median with two numbers
Sort the values from smallest to largest and call them x(1) up to x(n). Suppose they come from a continuous distribution. Each value is then equally likely to fall below or above the true median, so the number of values below it behaves like a binomial count with probability one half.
The interval from x(k+1) to x(n-k) fails to contain the median only when at most k values lie below it or at most k lie above it. Those two failures cannot happen together, so the coverage is 1 minus twice P(B at most k), where B is binomial with n trials and probability one half. No normal curve and no assumption about the shape of the data are needed.
The Order statistic article works the n = 6 case by hand. The two middle values, the 3rd and 4th, contain the median with probability 5/16, about 31 percent. The 2nd to 5th contains it with probability 25/32, about 78 percent. The minimum to the maximum contains it with 31/32, about 97 percent, and a sample of 6 values is the smallest for which that extreme pair gives at least 95 percent. The formula above reproduces all three figures.
Coverage moves in steps, not smoothly. For n = 10 the choices are these: the 1st to 10th value covers 511/512, which is 0.998047; the 2nd to 9th covers 501/512, or 0.978516; the 3rd to 8th covers 57/64, or 0.890625; the 4th to 7th covers 21/32, or 0.65625.
Ask for 95 percent and the narrowest pair that qualifies is the 2nd to 9th, whose coverage is really 97.85 percent, not 95. Ask for 90 percent and you get the same pair, because the next pair in, at 0.890625, falls just short. That is why the page reports the coverage the chosen pair actually has, and not the level you typed.
One caution belongs here. The formula assumes a continuous distribution, in which ties have probability zero. With repeated values the true coverage can differ from the figure, so the tool says so whenever the sorted values contain a repeat.
A worked example, and what it gives up
The Wikipedia article on the sign test works a deer example attributed to Zar. Ten deer were measured for the left hind leg and the left foreleg. Subtracting foreleg from hind leg gives differences of 4, 4, -3, 5, -1, 5, 6, 5, 6 and 2 centimetres.
That is 8 plus signs and 2 minus signs. The outcomes as extreme as this are 8, 9 or 10 plus signs and 0, 1 or 2, so the two-sided p-value is 112/1024, which reduces to 7/64 and is 0.109375. The one-sided value for more plus signs is half of that, 0.054688. At the 5 percent level the idea of equal chances is not rejected. Nine plus signs out of ten would have given 0.0215.
For the same ten differences, sorted as -3, -1, 2, 4, 4, 5, 5, 5, 6, 6, the 95 percent request picks the 2nd to 9th value. That is an interval for the median difference running from -1 to 6 centimetres, with exact coverage 501/512. It includes zero, which fits the test that did not reject. The first load of the page shows exactly this.
What does the test give up? It threw away the sizes. The article notes that when the observations are real numbers, the paired t-test or the Wilcoxon signed-rank test usually has greater power. For the deer, the article reports a paired t-test p-value of 0.007, and recomputing it with SciPy gives 0.0077, either way far below 0.109375. The two minus signs were small, 3 and 1 centimetres, while the plus signs were as large as 6, and the sign test could not see that.
The reward is that the sign test needs no symmetry and no normal curve. The Wilcoxon test is more powerful because it uses magnitudes, but it needs the differences to be symmetric around a central value. When that is doubtful, the weaker test is the safer one.
Small samples have a hard floor. With n = 5 signs, the most extreme result possible is all five the same way, and its two-sided p-value is 2 out of 32, or 0.0625. Nothing at n = 5 can reach significance at 5 percent, whatever the data say. The Paired difference test article explains why pairing is used at all: comparing each subject with itself removes the baseline differences between subjects.
A single list can use a censored value without trouble. The article’s survival example has ten times in weeks, 49 up to 362, where the last patient was still alive at the end of the study. Compared with 200 weeks, 7 values lie below and 3 above, so the two-sided p-value is 0.34375 and nothing is rejected. Only the side of 200 mattered, so the unknown final time does no harm.
This page does not cover the signed-rank test, the paired t-test, resampling intervals or power analysis. It gives you the counts, the exact sums, the interval, and an honest statement of how much coverage that interval really has.
Sources
Every source consulted for this guide. Links checked November 10, 2026.
- Sign test Wikipedia
- Order statistic Wikipedia
- Binomial distribution Wikipedia
- Binomial test Wikipedia
- Wilcoxon signed-rank test Wikipedia
- Paired difference test Wikipedia
- John Arbuthnot Wikipedia
- scipy.stats.binomtest SciPy documentation
- BigInt MDN Web Docs
- Web Workers API MDN Web Docs