Non-parametric (distribution-free) tests are statistical tests that do not assume any particular form for the underlying population distribution. They typically work with ranks or signs rather than the actual data values.
| Aspect | Parametric | Non-parametric |
|---|---|---|
| Distribution assumption | Specific (often normal) | None / minimal |
| Data type | Interval / ratio | Ordinal / nominal also OK |
| Test statistic based on | Means, variances | Ranks, signs, counts |
| Power (when assumptions hold) | Higher | Lower, by how much depends on the test: for normal data Mann–Whitney is about 95 % as efficient as the t test (\(3/\pi\)), the sign test only about 64 % (\(2/\pi\)) |
| Sensitivity to outliers | Sensitive | Robust |
The tests of Units 3 and 4 assume that the form of the frequency function of the parent population is known (usually normal) and test hypotheses about its parameters; they are parametric tests. Some tests, such as the \(\chi^2\) test of goodness of fit, do not depend on that form. A test which does not depend on the particular form of the frequency function from which the samples are drawn, and is not concerned with estimating its parameters, is a non-parametric (N.P.) test: it makes no assumption about the form of the population.
Assumptions
Advantages
Disadvantages
| Parametric tests | Non-parametric tests | |
|---|---|---|
| 1. Observations | independent | independent |
| 2. Variable | need not be continuous | continuous |
| 3. Form of the frequency function | the test depends on it | the test does not depend on it |
| 4. Parent population | assumed known, usually normal | no assumption about its form |
| 5. Parameters | estimated and tested | mainly hypotheses about the distribution or its median |
| 6. Nominal or ordinal measurements | cannot be used | can be used |
| 7. Ranks and grades | cannot be used | only N.P. methods apply |
| 8. Measure used | mean and variance | median |
| 9. Two independent samples | \(t\)-test | runs test, median test, Mann–Whitney U |
| 10. Paired (matched) samples | paired \(t\)-test | sign test, Wilcoxon signed-rank test |
| 11. Efficiency | more efficient, greater power | less efficient, lower power |
| 12. Departures from the assumptions | sensitive to them | robust: valid whatever the continuous distribution |
| 13. Conclusions | more conclusions can be drawn | fewer conclusions can be drawn |
Paired samples are matched: each observation in one sample belongs to the same unit as one in the other (the same student before and after), so their sizes are equal.
Tests whether a sequence of two types of items (or values above/below the median) is random.
Sequence: H T H T H T H T H T H T (12 tosses) — \(n_1 = n_2 = 6\), \(R = 12\) (alternating). \(E(R) = 7,\; \text{Var}(R) \approx 2.73,\; Z = 5/1.65 = 3.03\) ⇒ reject randomness.
Sequence: H H H H H H T T T T T T — \(R = 2,\; Z = (2-7)/1.65 = -3.03\) ⇒ also reject (clustering, not random).
A caution on both examples. With \(n_1 = n_2 = 6\) the samples are below the size at which the normal approximation is reliable, so \(Z\) is only a rough guide here. The exact answer agrees: of the \(\binom{12}{6} = 924\) equally likely arrangements, only 2 give 12 runs and only 2 give 2 runs, so each has probability \(2/924 = 0.002\).
A run is a maximal sequence of letters of one kind, bounded by letters of the other kind (or by the ends); the number of letters in it is its length. In
AA BBB A B AA B AA
there are 7 runs: 4 runs of A and 3 of B; the first has length 2.
Turning numbers into letters. Find the median \(M\) of the sample; write A for an observation \(\le M\) and B for one \(> M\), in the original order. (If \(n\) is odd, one observation equals \(M\); many texts drop it so that A and B are equally many.) Count the runs \(r\), the A's \(n_1\) and the B's \(n_2\).
Decision. For \(n_1, n_2 \le 20\) the runs tables give critical values \(r_1 < r_2\): do not reject randomness if \(r_1 < r < r_2\); reject if \(r \le r_1\) (too few runs: clustering, a trend) or \(r \ge r_2\) (too many: alternation). Beyond 20, use the normal form above.
Under \(H_0\) (random order) every arrangement of \(n_1\) A's and \(n_2\) B's is equally likely; there are \(\binom{n_1 + n_2}{n_1}\) of them.
Even number of runs, \(r = 2k\). Then there are \(k\) runs of A and \(k\) of B, alternating, starting with either letter (factor 2). Splitting \(n_1\) A's into \(k\) non-empty runs means choosing \(k - 1\) of the \(n_1 - 1\) gaps between them: \(\binom{n_1 - 1}{k - 1}\) ways; likewise \(\binom{n_2 - 1}{k - 1}\) for the B's. So
\[ P(r = 2k) = \frac{2\binom{n_1 - 1}{k - 1}\binom{n_2 - 1}{k - 1}}{\binom{n_1 + n_2}{n_1}} . \]Odd number, \(r = 2k + 1\). One letter has \(k + 1\) runs (and starts and ends the sequence), the other \(k\):
\[ P(r = 2k + 1) = \frac{\binom{n_1 - 1}{k}\binom{n_2 - 1}{k - 1} + \binom{n_1 - 1}{k - 1}\binom{n_2 - 1}{k}}{\binom{n_1 + n_2}{n_1}} . \]The mean. The number of runs is 1 plus the number of places where the letter changes. Each of the \(N - 1\) adjacent pairs (\(N = n_1 + n_2\)) is a change with probability \(2 \cdot \dfrac{n_1}{N} \cdot \dfrac{n_2}{N - 1}\), so
\[ E(r) = 1 + (N - 1)\cdot\frac{2 n_1 n_2}{N(N - 1)} = \frac{2 n_1 n_2}{n_1 + n_2} + 1 . \]The variance, by the same counting over pairs of positions, is the \(\text{Var}(R)\) above. The critical values in the runs tables are read off this exact distribution: \(r_1\) is the largest value with \(P(r \le r_1) \le 0.025\), and \(r_2\) the smallest with \(P(r \ge r_2) \le 0.025\).
Largest possible number of runs. Runs alternate, so the scarcer letter limits them: \(2\min(n_1, n_2)\) runs, plus one if \(n_1 \ne n_2\). It equals \(n_1 + n_2\) only when \(n_1\) and \(n_2\) differ by at most 1 (for example 4 A's and 3 B's alternate as ABABABA: 7 runs).
Tests \(H_0\): median = \(M_0\) using only the signs of \((X_i - M_0)\). Or for paired samples, signs of \((X_i - Y_i)\).
15 measurements; 4 are below 50 (−), 11 above (+). \(n = 15, S = 11\). Two-tailed P-value from Binomial(15, 0.5): \(2 P(S \ge 11) = 2(0.0592) = 0.118\) ⇒ do not reject \(H_0\) at 5 %.
Before-after for 12 patients: +9 −2 (1 tie). \(n = 11, S_+ = 9\). \(P(S_+ \ge 9) = 0.0327\); two-tailed p = 0.065 ⇒ do not reject \(H_0\) at 5 %.
One sample. If \(M_0\) is the population median, then for a continuous variable \(P(X > M_0) = P(X < M_0) = \tfrac12\). The signs of \(x_i - M_0\) are independent, each “+” with probability \(\tfrac12\). Drop any zeros (they carry no sign) and let \(n\) be the number left. The number of + signs, \(S\), is then a count of successes in \(n\) independent trials with \(p = \tfrac12\):
\[ P(S = u) = \binom{n}{u}\left(\tfrac12\right)^u\left(\tfrac12\right)^{n-u} = \binom{n}{u}\left(\tfrac12\right)^n . \]Using the smaller count. Work with \(u\) = the number of the less frequent sign, and the cumulative probability \(p = \sum_{i=0}^{u}\binom{n}{i}(\tfrac12)^n\). Since Binomial\((n, \tfrac12)\) is symmetric, a count as small as \(u\) is equally likely in either sign, so the two-sided p-value is \(2p\). Reject \(H_0\) if \(2p \le \alpha\).
Large \(n\) (a common rule is \(n \ge 25\)): \(E(S) = np = \tfrac n2\) and \(V(S) = npq = \tfrac n4\), so \(z = \dfrac{S - n/2}{\sqrt{n/4}} \sim N(0,1)\) approximately.
Paired samples. With pairs \((x_i, y_i)\) take \(d_i = x_i - y_i\); under \(H_0\) (no difference between the two conditions), \(P(x_i > y_i) = P(x_i < y_i) = \tfrac12\) and the same binomial applies to \(u\) = the number of + signs. The critical values for a two-sided test at level \(\alpha\) are \(x_1\), the largest value with \(P(S \le x_1) \le \alpha/2\), and by symmetry \(x_2 = n - x_1\). Reject \(H_0\) if \(u \le x_1\) or \(u \ge x_2\); do not reject it if \(x_1 < u < x_2\).
The hypothesis that the two p.d.f.s are the same, \(H_0: f_1(x) = f_2(y)\), is tested through its consequence \(P(X > Y) = \tfrac12\): a zero median difference. For a two-sided test with the cumulative probability \(P\), compare \(2P\) with \(\alpha\), as in the one-sample case.
More powerful than the sign test because it uses the magnitudes of differences as well.
Differences \(d\): −2, +5, +1, −3, +6, +4. \(|d|\): 1, 2, 3, 4, 5, 6 ranked 1, 2, 3, 4, 5, 6. With signs: +1, −2, −3, +4, +5, +6 (matching order). \(W^+ = 1+4+5+6 = 16,\; W^- = 2+3 = 5\). \(W = 5\). For \(n = 6\), critical at 5 % two-tailed = 0; \(W = 5 > 0\) ⇒ do not reject \(H_0\).
10 paired differences with \(W^+ = 50, W^- = 5\). \(W = 5\). Critical Wilcoxon for \(n = 10\) at 5 % two-tailed = 8; \(W < 8\) ⇒ reject \(H_0\) — significant difference.
Tests whether two samples come from populations with the same median.
Sample A (10 obs): 4 above, 6 below grand median. Sample B (10 obs): 6 above, 4 below.
| Above M | Below M | |
|---|---|---|
| A | 4 | 6 |
| B | 6 | 4 |
Expected = 5 each. \(\chi^2 = 4(1)/5 = 0.80\). df = 1, \(\chi^2_{0.05} = 3.84\) ⇒ do not reject \(H_0\).
If Sample A has 9 above / 1 below and Sample B has 1 above / 9 below: \(\chi^2 = 4(4)^2/5 = 12.8\) ⇒ reject \(H_0\); medians differ.
Combine the two samples (sizes \(n_1, n_2\)) and find their common median \(M\). Count the observations \(\ge M\): \(m_1\) in the first sample, \(m_2\) in the second.
| Sample I | Sample II | Total | |
|---|---|---|---|
| \(\ge M\) | \(m_1\) | \(m_2\) | \(m_1 + m_2\) |
| \(< M\) | \(n_1 - m_1\) | \(n_2 - m_2\) | \(n_1 + n_2 - (m_1 + m_2)\) |
| Total | \(n_1\) | \(n_2\) | \(n_1 + n_2\) |
Where the hypergeometric comes from. Under \(H_0\) the two samples are one population, so given the margins, which \(m_1 + m_2\) of the \(n_1 + n_2\) observations land at or above \(M\) is a random choice. The chance that exactly \(m_1\) of them come from sample I is the hypergeometric probability
\[ P(m_1) = \frac{\binom{n_1}{m_1}\binom{n_2}{m_2}}{\binom{n_1 + n_2}{m_1 + m_2}} . \]The test uses a tail, not a single term. The p-value is the probability of a split at least as uneven as the one observed: \(P(M_1 \ge m_1)\), the sum of the terms from \(m_1\) upward (double it for a two-sided test). Reject \(H_0\) if it is at most \(\alpha\).
Larger samples (both \(n_1, n_2 > 10\)): use the \(2 \times 2\) \(\chi^2\) of Unit 4, \(\chi^2 = \dfrac{N(ad - bc)^2}{(a+b)(c+d)(a+c)(b+d)}\) with 1 d.f., with Yates' correction when a cell frequency is below 5.
Compare the tail, not one term. A single probability \(P(m_1)\) can be small even when nothing unusual has happened (with large samples every exact outcome is improbable), so the comparison with \(\alpha\) must use the tail sum. Note also that the median test, unlike the sign and Wilcoxon tests, needs no pairing: the two samples may differ in size.
The standard non-parametric test for comparing two independent samples: for normal data it is about 95 % as efficient as the two-sample t test, and for heavy-tailed data it can beat it. Tests whether the distributions are identical (or whether one tends to produce larger values).
Sample 1 (n₁=4): 12, 15, 9, 18. Sample 2 (n₂=5): 7, 10, 14, 11, 13.
Combined ranks: 7→1, 9→2, 10→3, 11→4, 12→5, 13→6, 14→7, 15→8, 18→9.
\(R_1 = 2 + 5 + 8 + 9 = 24,\; R_2 = 1+3+4+6+7 = 21\).
\(U_1 = 24 - 4 \cdot 5/2 = 14,\; U_2 = 21 - 5 \cdot 6/2 = 6\). \(U = 6\). Critical for (4,5) at 5 % two-tailed = 1; \(U = 6 > 1\) ⇒ do not reject \(H_0\).
Two methods scored over n₁ = 12, n₂ = 15 with \(R_1 = 250\). \(U_1 = 250 - 12(13)/2 = 172\). \(Z = (172 - 90)/\sqrt{12 \cdot 15 \cdot 28/12} = 82/\sqrt{420} = 82/20.49 = 4.00\) ⇒ reject \(H_0\); methods differ.
Tests whether two independent samples come from the same population. Uses runs in the combined ranked sample.
Sample A: 1,2,3,4,5; Sample B: 6,7,8,9,10. Combined ordered: A A A A A B B B B B → \(R = 2\). \(E(R) = 6, \text{Var}(R) = 2.22\). \(Z = (2-6)/1.49 = -2.68\) ⇒ reject \(H_0\); distributions differ.
Sample A: 1, 4, 6, 9; Sample B: 2, 3, 5, 7, 8, 10. Order: A B B A B A B B A B → \(R = 8\). \(n_1=4, n_2=6, E(R)=5.8, \text{Var}(R)=2.03\). \(Z = (8-5.8)/1.42 = 1.55\) ⇒ do not reject \(H_0\) at 5 %.
The two-sample runs test uses only the labels in the combined order, and the exact distribution of §2 (with \(n_1\) A's and \(n_2\) B's) applies unchanged. But if a value occurs in both samples, the order within that tie is arbitrary, and the number of runs depends on the choice. Worked Problem 9 below has 2 such ties; over every way of ordering them, \(r\) ranges from 24 to 26. The honest report gives that range (here every value leads to the same decision); a common alternative is to break ties at random.
The number of runs lies between 2 and \(2\min(n_1, n_2)\), plus one when \(n_1 \ne n_2\) (§2).
The Kruskal–Wallis test compares the locations of \(k \ge 3\) independent groups without assuming normality — the rank-based analogue of one-way ANOVA. Pool all \(N\) observations, rank them, and let \(R_j\) be the rank-sum of group \(j\) (size \(n_j\)).
Reject \(H_0\) (equal locations) when \(H\) exceeds \(\chi^2_{k-1}\) at level \(\alpha\).
Three groups — A: 12, 15, 18; B: 20, 22, 25; C: 8, 10, 14 (\(N = 9\)). Ranking all nine gives rank-sums \(R_A = 14,\ R_B = 24,\ R_C = 7\). Then
\(H = \dfrac{12}{9\cdot10}\!\left(\dfrac{14^2}{3}+\dfrac{24^2}{3}+\dfrac{7^2}{3}\right) - 3(10) = 6.49\). Since \(6.49 > \chi^2_{2,\,0.05} = 5.99\), the groups differ significantly. (With only three observations per group the \(\chi^2\) approximation is rough; the exact null distribution over all 1680 allocations gives \(P(H \ge 6.49) = 18/1680 = 0.011\), and the same conclusion.)
The Kolmogorov–Smirnov test checks goodness of fit by comparing the empirical CDF \(F_n(x)\) with a fully specified theoretical CDF \(F_0(x)\) (one-sample), using the largest vertical gap:
Reject \(H_0\) (data follow \(F_0\)) if \(D\) exceeds the tabulated critical value \(D_{\alpha,n}\). Unlike the \(\chi^2\) goodness-of-fit test, K–S needs no class grouping and works well for small, continuous samples. (A two-sample version compares two empirical CDFs.)
Test whether 0.15, 0.32, 0.48, 0.61, 0.83 come from Uniform\((0,1)\). Comparing the step ECDF with \(F_0(x) = x\) gives \(D = 0.19\). Since \(0.19 < D_{0.05,\,5} = 0.563\), \(H_0\) is not rejected — the data are consistent with the uniform.
Eleven problems: two on the one-sample sign test, two on the paired sign test, two on the runs test for randomness, three on the two-sample runs test and two on the median test. Each states \(H_0\), turns the data into signs, runs or counts, and decides at the 5% level. Where a sample is small the decision is taken from the exact null distribution (binomial, runs or hypergeometric), which is what the printed tables tabulate.
Twenty employees' scores on a skills test: 71, 68, 82, 90, 63, 77, 80, 66, 88, 79, 85, 70, 74, 72, 75, 80, 76, 77, 73, 81. Test the hypothesis that the median score is 75.
(1) \(H_0: M = 75\). (2) \(H_1: M \ne 75\). Two-sided, 5%.
(3) The signs of \(x_i - 75\), in order:
− − + + − + + − + + + − − − 0 + + + − +
11 plus, 8 minus and 1 zero (the score 75 itself), which is dropped: \(n = 19\). The rarer sign occurs \(u = 8\) times, and
\[ p = P(S \le 8) = \sum_{i=0}^{8}\binom{19}{i}\left(\tfrac12\right)^{19} = 0.3238 . \](4) \(2p = 0.6476 > 0.05\), so \(H_0\) is not rejected: the data are consistent with a median of 75.
Of 120 households surveyed, 42 have monthly income below ₹15,000 and 78 above. Is ₹15,000 the median income?
(1) \(H_0: M = 15000\). (2) \(H_1: M \ne 15000\).
(3) \(n = 120\) is large, so the normal form applies, with \(u = 42\):
\[ z = \frac{u - n/2}{\sqrt{n/4}} = \frac{42 - 60}{\sqrt{30}} = \frac{-18}{5.4772} = -3.286 . \](4) \(|z| = 3.286 > 1.96\), so \(H_0\) is rejected: ₹15,000 is not the median; more households are above it than below. (The exact binomial p-value, \(2P(S \le 42) = 0.0013\), agrees.)
16 tasters rated two blends of tea on a 1–5 scale. Is there a difference between the blends?
| Taster | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Blend A \(x\) | 3 | 2 | 4 | 3 | 2 | 3 | 4 | 2 | 3 | 3 | 1 | 2 | 4 | 3 | 2 | 3 |
| Blend B \(y\) | 4 | 4 | 4 | 5 | 3 | 2 | 5 | 2 | 4 | 5 | 3 | 1 | 4 | 5 | 4 | 2 |
| sign of \(x - y\) | − | − | 0 | − | − | + | − | 0 | − | − | − | + | 0 | − | − | + |
(1) \(H_0\): no difference, \(P(x > y) = \tfrac12\). (2) \(H_1\): a difference. Two-sided.
(3) 3 plus, 10 minus, 3 zeros; drop the zeros: \(n = 13\), \(u = 3\) plus signs. For Binomial\((13, \tfrac12)\), \(P(S \le 2) = 0.0112\) and \(P(S \le 3) = 0.0461\), so the largest \(x_1\) with \(P(S \le x_1) \le 0.025\) is \(x_1 = 2\), and by symmetry \(x_2 = 13 - 2 = 11\).
(4) \(2 < u = 3 < 11\): \(H_0\) is not rejected at 5%. The exact two-sided p-value is \(2P(S \le 3) = 0.092\): suggestive, but not significant.
Thirty students took two tests:
| Student | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Test I | 120 | 168 | 139 | 101 | 134 | 177 | 156 | 133 | 139 | 140 |
| Test II | 132 | 159 | 121 | 110 | 178 | 201 | 160 | 112 | 153 | 153 |
| sign | − | + | + | − | − | − | − | + | − | − |
| Student | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| Test I | 106 | 103 | 154 | 133 | 147 | 103 | 167 | 154 | 113 | 156 |
| Test II | 108 | 126 | 155 | 178 | 145 | 129 | 170 | 132 | 149 | 170 |
| sign | − | − | − | − | + | − | − | + | − | − |
| Student | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| Test I | 141 | 174 | 159 | 140 | 168 | 108 | 142 | 151 | 104 | 114 |
| Test II | 121 | 212 | 134 | 170 | 182 | 150 | 184 | 134 | 108 | 139 |
| sign | + | − | + | − | − | − | − | + | − | − |
Can the students' performance be taken as the same in both?
(1) \(H_0\): no difference. (2) \(H_1\): a difference.
(3) 8 plus signs, no zeros: \(u = 8\), \(n = 30 \ge 25\), so
\[ z = \frac{8 - 30/2}{\sqrt{30/4}} = \frac{-7}{2.7386} = -2.556 . \](4) \(|z| = 2.556 > 1.96\), so \(H_0\) is rejected: the scores differ, Test II being higher for 22 of the 30 students. The exact binomial check, \(2P(S \le 8) = 0.0161\), agrees.
A shop's sales (₹ hundreds) on 16 consecutive days were 212, 187, 236, 241, 198, 205, 251, 229, 193, 217, 247, 239, 201, 226, 258, 210. Test the randomness of the sequence.
(1) \(H_0\): the order is random. (2) \(H_1\): it is not.
(3) In ascending order the 8th and 9th values are 217 and 226, so \(M = (217 + 226)/2 = 221.5\). Writing A for \(\le 221.5\) and B for \(> 221.5\) in the original order:
AA BB AA BB AA BB A BB A
\(r = 9\) runs, \(n_1 = 8\) A's and \(n_2 = 8\) B's. From the exact distribution of §2, \(r_1 = 4\) and \(r_2 = 14\).
(4) \(4 < 9 < 14\), so \(H_0\) is not rejected: the sequence may be regarded as random. 9 is close to the expected \(2(8)(8)/16 + 1 = 9\).
A coin tossed 40 times gives 27 heads, in 14 runs. Is the sequence random, and is the coin fair?
Randomness. \(H_0\): the order of heads and tails is random. \(n_1 = 27\), \(n_2 = 13\), \(r = 14\); \(n_1 > 20\), so the normal form:
\[ E(r) = \frac{2(27)(13)}{40} + 1 = 18.55, \] \[ V(r) = \frac{2(27)(13)\,[2(27)(13) - 27 - 13]}{40^2 \times 39} = \frac{702 \times 662}{62400} = 7.447 , \] \[ z = \frac{14 - 18.55}{\sqrt{7.447}} = \frac{-4.55}{2.729} = -1.667 . \]\(|z| = 1.67 < 1.96\): the order may be regarded as random.
Fairness is a different question. The runs test looks only at the order of the results, never at how many heads there are, so it cannot say whether the coin is fair. That is a test of \(p = \tfrac12\) on the count of heads (a sign test):
\[ z = \frac{27 - 40/2}{\sqrt{40/4}} = \frac{7}{3.162} = 2.214 . \]\(|z| = 2.21 > 1.96\) (exact two-sided p = 0.038): at 5% the coin is judged biased towards heads, although its sequence shows no departure from randomness. A conclusion such as “the runs test accepts, so the coin is fair” would answer a question the test never asked.
Typing speeds (words per minute) of 6 typists in office A: 48, 41, 59, 66, 53, 61; of 7 typists in office B: 54, 63, 45, 64, 57, 62, 70. Do the two sets of speeds follow the same distribution?
(1) \(H_0\): the two populations have the same distribution. (2) \(H_1\): they do not.
(3) Combined in ascending order:
| 41 | 45 | 48 | 53 | 54 | 57 | 59 | 61 | 62 | 63 | 64 | 66 | 70 |
| A | B | A | A | B | B | A | A | B | B | B | A | B |
A B AA BB AA BBB A B: \(r = 8\) runs, \(n_1 = 6\), \(n_2 = 7\). The critical values are \(r_1 = 3\), \(r_2 = 12\).
(4) \(3 < 8 < 12\): \(H_0\) is not rejected; the two offices' speeds may follow the same distribution.
A kabaddi team's wins and losses in order: W L W L WW L W L W LL W L W L W L WW L W L W L W L. Is the order random?
This is the runs test for randomness of §2: one sequence, two kinds of letter.
(1) \(H_0\): the order is random. (2) \(H_1\): it is not.
(3) \(n_1 = 14\) W's, \(n_2 = 13\) L's, \(r = 24\) runs. The exact critical values are \(r_1 = 9\), \(r_2 = 20\).
(4) \(r = 24 \ge r_2\), so \(H_0\) is rejected: the results alternate more often than chance allows (\(P(r \ge 24) = 0.0001\), two-sided p = 0.0002).
Crushing strengths (N/cm², in tens) of bricks fired at two kiln temperatures. Sample I (18): 418, 452, 397, 471, 436, 409, 455, 428, 444, 391, 462, 433, 405, 448, 421, 459, 440, 414. Sample II (23): 402, 437, 395, 426, 451, 384, 412, 430, 399, 445, 388, 419, 407, 433, 392, 424, 410, 448, 396, 415, 403, 427, 390. Is the strength the same at both temperatures? (Use the runs test.)
(1) \(H_0\): same distribution at both temperatures. (2) \(H_1\): not.
(3) Combined in ascending order, A = Sample I, B = Sample II, with Sample I listed first within a tie:
BBB A BBB A BBB A B A BB A B A B A BBB A B A B A B AA B A BB AAAAA
\(r = 26\), \(n_1 = 18\), \(n_2 = 23\). As \(n_2 > 20\), use the normal form:
\[ \begin{gathered} E(r) = \frac{2(18)(23)}{41} + 1 = 21.195, \qquad V(r) = 9.691, \\ z = \frac{26 - 21.195}{\sqrt{9.691}} = 1.543 . \end{gathered} \](4) \(|z| = 1.54 < 1.96\): \(H_0\) is not rejected; the strength may be taken as the same.
Ties. The values 433, 448 occur in both samples, and the order within each tie is arbitrary. Over every possible ordering, \(r\) runs from 24 to 26, and \(z\) from \(0.9\) to \(1.54\) (§7). Every one of them leaves \(H_0\) standing, so here the ties do not matter.
Waiting times (minutes) of customers at counter A: 34, 38, 29, 41, 36, 27, 39, 33, 37; at counter B: 30, 35, 26, 31, 28, 32. Do the two samples come from the same population?
(1) \(H_0\): same population. (2) \(H_1\): not. Two-sided.
(3) With 15 values the median is the 8th in order, \(M = 33\).
| Counter A | Counter B | Total | |
|---|---|---|---|
| \(\ge 33\) | 7 | 1 | 8 |
| \(< 33\) | 2 | 5 | 7 |
| Total | 9 | 6 | 15 |
The samples are small, so use the exact hypergeometric. The probability of this table alone is
\[ P(m_1 = 7) = \frac{\binom{9}{7}\binom{6}{1}}{\binom{15}{8}} = \frac{216}{6435} = 0.0336, \]and the p-value adds the more extreme tables:
\[ P(M_1 \ge 7) = \frac{216 + 9}{6435} = 0.035 . \](4) Doubled for a two-sided test, the p-value is \(0.0699\) > 0.05: \(H_0\) is not rejected; the samples may come from the same population. The p-value is the tail sum, not the single term 0.0336 (§5).
The data of Worked Problem 9. Do the two samples come from the same population?
(1) \(H_0\): same population. (2) \(H_1\): not.
(3) With 41 values the median is the 21st in order, \(M = 421\).
| Sample I | Sample II | Total | |
|---|---|---|---|
| \(\ge 421\) | 12 (\(a\)) | 9 (\(b\)) | 21 |
| \(< 421\) | 6 (\(c\)) | 14 (\(d\)) | 20 |
| Total | 18 | 23 | 41 |
Both samples exceed 10, so
\[ \chi^2 = \frac{N(ad - bc)^2}{(a+b)(c+d)(a+c)(b+d)} = \frac{41(12 \times 14 - 9 \times 6)^2}{21 \times 20 \times 18 \times 23} = 3.0644 . \](4) \(3.0644 < \chi^2_{0.05,1} = 3.84\): \(H_0\) is not rejected, as by the runs test in Worked Problem 9. (With Yates' correction \(\chi^2 = 2.061\).)
| Question | Test | Parametric counterpart |
|---|---|---|
| Is a sequence random? | One-sample runs test | — |
| Test population median (one sample) | Sign / Wilcoxon signed-rank | One-sample t |
| Paired samples | Sign / Wilcoxon signed-rank | Paired t |
| Two independent medians | Median test | Two-sample t |
| Two independent samples (general) | Mann–Whitney U / Wald–Wolfowitz | Two-sample t |
Where this course has taken you. Five units, one narrowing question. Unit 1 estimated a parameter; Unit 2 turned estimation into a decision; Unit 3 made that decision when the sample was large enough for the CLT; Unit 4 when it was not, at the cost of assuming a normal population; and this unit when even normality is unavailable. Each step gave something up and bought robustness with it.
What is not here: the parametric way of comparing three or more groups, which is Analysis of Variance (its rank-based counterpart, Kruskal–Wallis, is section 8 above). To pick a test by what you are asking rather than by unit number, use the test chooser.