A simple non-parametric test that is used in two situations:
1. A random sample of n observations x1, x2,…, xn is taken on the random variable X; the null hypothesis is that the population has median m0.
2. A random sample of n observations (x1, y1), (x2, y2),…, (xn, yn) is taken on the pair of random variables (X, Y); the null hypothesis is that the distribution of X − Y has median 0.
In both cases the analysis begins by noting the signs of the differences d1, d2,…, dn, where in case (1) dj=xj − m0 and in case (2) dj=xj − yj. In either case the test statistic, r, is the number of differences that have a positive value.
If the null hypothesis is correct and there are no zero differences, r is an observation from a binomial distribution with parameters n and 0.5. If the one-tail or two-tail probability (as appropriate) is unusually low, then the null hypothesis will be rejected.
If there are k differences equal to 0, it is conventional to ignore the corresponding observations and to use a binomial distribution with parameters (n − k) and 0.5.
As an example, suppose that the null hypothesis is that the distribution of the weights of 20-year-old males has median 77 kg, the alternative being that this is not the case. A random sample of thirteen 20-year-old males have the following weights (in kg): 59, 84, 99, 83, 65, 70, 77, 69, 85, 66, 76, 73, 81. The question is whether these data support the null hypothesis. In the sample there is one value equal to the hypothesized median. This is ignored. Of the remaining twelve values, five exceed 77 kg. Using the binomial distribution with n=12 and p=0.5, the probability of five or fewer is 0.387. The two-tail probability is therefore 0.774: we conclude that there is no significant evidence to refute the null hypothesis.