Is the median score greater than 5? A consumer group rated 12 manufactured products
import
ed from a single
source on a scale
of 1 to 10. The data are shown below. Do the data provide sufficient evidence to
indicate tha
t the median score is greater than 5? Use
the
sign test at the 1% level of significance.
2
9
6
7
8
5
10
2
8
5
3
4
 A: The sign test is the name of two related location tests, suitable respectively for paired and single samples from continuous distributions.
The paired test is the more common, but the calculations are essentially the same for both.
In the case of the paired test, the usual hypothesis being considered is that $H_0: P(X-Y>0) = \frac{1}{2}$. 
We also have a one-sample test by considering the differences $Z = X-Y$ as a single sample, which is then a test of whether the population median of $Z$ is zero. We don't even need the $Z$'s to be differences. 
This is readily extended to a test of a general median (consider $Z=Z^*-\stackrel{\sim}{\mu_0}$ - a test for $Z$ having zero median is the same as a test for $Z^*$ having median $\mu_0$; and the paired test can be extended to testing for a specified shift in the same manner.)
So in each of the mentioned cases, our test boils down to testing $H_0:P(Z>0)=\frac{1}{2}$. The small sample test statistic is the count of observations where $Z>0$, which if the null hypothesis is true, has a binomial distribution with $p=\frac{1}{2}$ and $n$ the sample size (number of observations in one sample, or the number of pairs in the paired case). The alternative may be one or two tailed as required.
It can equivalently be treated as a proportions test (which is a scaled binomial), and in large samples reduces to the usual one sample Z-test of proportions.
(Further, testing other quantiles than the median is a matter of choosing the relevant proportion.)

Ties
Under the original assumption of continuity, no ties are possible.
If we have ties (such as $X_i=Y_i$,$Z^*_i=\stackrel{\sim}{\mu_0}$,or $Z_i=0$), then the distribution of the test statistic is no longer as stated. 
The most common advice seems to be to throw out the ties, but we have to take care; that's potentially suitable in some situations but not in others.
Consider a two-tailed test - if we condition on $Z\neq 0$ we can get a test statistic that has a binomial distribution (with $n$ correspondingly reduced), but if we reject the null, that doesn't of itself imply the median is not 0, only that the conditional median is not zero. It's quite possible to reject the null and have the actual population median be zero!
When ties are possible, one must take care when considering what one is actually testing. 
(We might be concerned, then, that the most common advice on how to deal with ties in this test is potentially flawed; in some cases it rescues the distribution of test statistic at the expense of the hypothesis! However, if the null is not rejected in the reduced case, it should also not be rejected in the unconditional case.)
The original hypothesis relating to the median can be rescued, however, without resort to computing permutations of signs. 
Consider the distribution of $B =\text{sign}(Z)$, with $p_+ + p_0 + p_- = 1$. If we were to test both $p_+\leq\frac{1}{2}$ and $p_-\leq\frac{1}{2}$ (against alternatives that they're $>\frac{1}{2}$) at the $\alpha/2$ level and neither rejected, we would have failed to reject the null that the median was 0.
(The one-tailed equivalent would be to perform just one of those two tests, at level $\alpha$.)

The problem in the question:
This is a one-tailed test, so we can actually proceed with it without much difficulty, as long as we take a little care with the null.
The stated alternative is that $\stackrel{\sim}{\mu}>5$; in this case we can actually take the null to be the complement.
Now the test statistic: if the number of cases where $Z^*_i>5$ is higher than could be expected from a $\text{Bin}(n,\frac{1}{2})$ we can reject.
(One can see that 6 of 12 values exceed 5; clearly we won't reject at any sensible significance level; it wasn't even necessary for me to count them when I made my earlier comment about seeing at a glance we wouldn't reject since I could see without counting it was close to half.)
