1-sample sign test: test a median, with an example
The 1-sample sign test checks whether the median of a population differs from a stated value. It only counts how many observations fall above and below that value, and under the null hypothesis each side is equally likely, so the count follows a binomial distribution with p = 0.5. Because it uses only the signs, it makes almost no assumptions about the shape of the data and is not disturbed by outliers.
When to use it
- The data are clearly skewed or contain outliers, and the sample is too small for the 1-sample t-test to be trusted.
- The requirement is about a median or a typical value rather than a mean.
- The data are ordinal (ratings, grades) or recorded with a limit, such as values reported as "below detection".
- For paired data, apply it to the differences: it then tests whether the median difference is zero.
- If the data are roughly symmetric, the 1-sample Wilcoxon test uses more information and has more power.
How it works
Let η be the population median and η₀ the stated value.
- H₀: η = η₀.
- H₁: η ≠ η₀, or η > η₀, or η < η₀.
Count the values above η₀ (S₊) and below it (S₋). Values exactly equal to η₀ carry no sign and are dropped, so the effective sample size is n = S₊ + S₋. Under H₀, S₊ follows a binomial distribution with n trials and probability 0.5. For H₁: η < η₀, few values should be above η₀:
p-value = P(S₊ ≤ s₊) = Σ_{k=0}^{s₊} C(n, k) · 0.5ⁿFor H₁: η > η₀ the p-value is P(S₊ ≥ s₊), and for a two-sided test it is twice the smaller tail. This article uses the exact binomial p-value. For large n, a normal approximation is also common: z = (S₊ ± 0.5 − n/2)/√(n/4), with the 0.5 a continuity correction toward n/2.
Confidence interval for the median. Sort all N values. The interval from the k-th smallest to the k-th largest value covers the median with confidence 1 − 2 × P(B ≤ k − 1), where B is binomial with N trials and p = 0.5. Choose the largest k whose confidence is still at least the level you want. Because k is a whole number, the achieved confidence is usually above the nominal level.
Assumptions: independent observations from a continuous distribution. No assumption about the shape.
Example
A machine shop switches to a new wiper insert for finish turning. The drawing calls for a surface roughness of Ra 0.8 µm, and the shop wants evidence that the typical part is now better than that. Roughness values are skewed: most parts are smooth, but now and then a chip mark gives a high reading. An inspector measures 16 parts, in µm:
| Ra (µm) | |||||||
|---|---|---|---|---|---|---|---|
| 0.62 | 0.71 | 0.58 | 0.80 | 0.66 | 1.24 | 0.69 | 0.74 |
| 0.55 | 0.83 | 0.63 | 0.77 | 0.68 | 0.97 | 0.60 | 0.72 |
Test H₀: η = 0.80 against H₁: η < 0.80 at α = 0.05.
- Above 0.80: 3 parts (0.83, 0.97, 1.24). Below: 12. Equal: 1 (dropped). So n = 15 and S₊ = 3.
- p-value = P(S₊ ≤ 3 | n = 15, p = 0.5) = 0.018.
- Sample median: 0.70 µm.
- One-sided upper bound for the median, from all 16 values: the 12th smallest value, 0.77 µm, with confidence 1 − P(B ≤ 4) = 96.2%.
- Two-sided interval: from the 4th smallest to the 4th largest value, 0.62 to 0.80 µm, with achieved confidence 97.9% (the next narrower pair reaches only 92.3%).
For comparison, a one-sided 1-sample t-test on the same data gives p = 0.080, and an Anderson–Darling test rejects normality (p = 0.016). The single reading of 1.24 µm inflates the standard deviation and weakens the t-test; the sign test only sees it as "above".
How to read the results
- The p-value of 0.018 is below 0.05: the median roughness with the new insert is below Ra 0.8 µm.
- The upper bound says the median is at most 0.77 µm with about 96% confidence. That is the claim the shop can make.
- The median is not the whole story. Three of 16 parts (19%) were above 0.8 µm. If the drawing limit applies to every part, the shop still has a problem with occasional high readings. Look at what causes them (chip control, insert edge condition) rather than at the median alone.
- Why not the t-test? The data are skewed with an outlier, and the t-test answers a question about the mean, which the outlier pulls up. For "is the typical part better than 0.8?", the median is the right measure.
Common mistakes
- Using the sign test when a t-test or Wilcoxon would do. The sign test throws away the size of each deviation, so with symmetric data it needs more parts for the same power.
- Keeping values equal to η₀ in the count. They carry no sign; drop them and reduce n.
- Reading a median result as a statement about every part. A median below the limit still allows a large share of parts above it.
- Using the normal approximation for small n. With fewer than about 20 non-tied values, use the exact binomial p-value.
Frequently asked questions
What is the difference between the sign test and the Wilcoxon signed-rank test?
Both test a median. The sign test uses only whether each value is above or below η₀. The Wilcoxon test also uses the ranks of the distances from η₀, so it is more powerful, but it assumes the distribution is symmetric around its median.
What happens to values equal to the hypothesized median?
They are dropped from the test, because they favor neither side. The sample size for the binomial calculation is the number of values above plus the number below.
Can I use the sign test on paired data?
Yes. Compute the difference for each pair and test whether the median difference is zero. This is a robust alternative to the paired t-test.
Why is the confidence level of the median interval not exactly 95%?
The interval's limits are actual data values, and the confidence attached to each pair of ranks comes from the binomial distribution in discrete steps. The reported interval is the narrowest one that reaches at least the requested confidence.