Skip to the content

Topics Covered

Advantages / Disadvantages Run Test Sign Test Paired Sign Test Wilcoxon Signed-rank Median Test Mann–Whitney U Wald–Wolfowitz Distribution of Runs
On this page
  1. 1. Introduction
  2. 2. One-Sample Runs Test (Test for Randomness)
  3. 3. Sign Test
  4. 4. Wilcoxon Signed-Rank Test
  5. 5. Median Test (Two Independent Samples)
  6. 6. Wilcoxon–Mann–Whitney U Test
  7. 7. Wald–Wolfowitz Runs Test (Two Samples)
  8. 8. Kruskal–Wallis Test (Non-parametric One-way ANOVA)
  9. 9. Kolmogorov–Smirnov (K–S) Test
  10. Worked Problems on Non-parametric Tests
  11. 10. Choosing the Right Non-parametric Test
  12. Key Take-aways

1. Introduction

DEFINITION

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.

Advantages

  1. Make minimal assumptions — useful when distribution is unknown or non-normal.
  2. Applicable to ordinal data (ranks).
  3. Robust to outliers.
  4. Easier to compute and explain.

Disadvantages

  1. Less powerful than parametric tests when the parametric assumptions are met.
  2. Use less information from the data (ranks instead of actual values).
  3. Often not as suitable for complex models.
  4. Tables / exact distributions required for small samples.

Comparison with Parametric Tests

AspectParametricNon-parametric
Distribution assumptionSpecific (often normal)None / minimal
Data typeInterval / ratioOrdinal / nominal also OK
Test statistic based onMeans, variancesRanks, signs, counts
Power (when assumptions hold)HigherLower, 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 outliersSensitiveRobust

Definition and Assumptions

DEFINITION

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

  1. The sample observations are independent.
  2. The variable under study is continuous.
  3. The probability density function is continuous.
  4. Lower-order moments exist.

Advantages

  1. N.P. methods are simple and easy to apply.
  2. They need no complicated sampling theory.
  3. No assumption is made about the form of the parent population.
  4. Socio-economic data are seldom normal, so N.P. tests are widely used in psychometry, sociology and educational statistics.
  5. They apply to data given only as ranks, signs or grades (A, A+, A−, B, …), where parametric methods cannot be applied.
  6. For data measured only on a nominal scale, N.P. tests are the only ones available.

Disadvantages

  1. N.P. tests can be used for nominal or ordinal measurements, but when the assumptions of a parametric test do hold, the parametric test is more powerful.
  2. N.P. methods are designed mainly for testing hypotheses; they give fewer tools for estimating parameters (the median is the usual exception, with distribution-free confidence limits).
  3. There is no N.P. method for testing interactions in analysis of variance unless additivity of the model is assumed.

Parametric and Non-parametric Tests, Side by Side

Parametric testsNon-parametric tests
1. Observationsindependentindependent
2. Variableneed not be continuouscontinuous
3. Form of the frequency functionthe test depends on itthe test does not depend on it
4. Parent populationassumed known, usually normalno assumption about its form
5. Parametersestimated and testedmainly hypotheses about the distribution or its median
6. Nominal or ordinal measurementscannot be usedcan be used
7. Ranks and gradescannot be usedonly N.P. methods apply
8. Measure usedmean and variancemedian
9. Two independent samples\(t\)-testruns test, median test, Mann–Whitney U
10. Paired (matched) samplespaired \(t\)-testsign test, Wilcoxon signed-rank test
11. Efficiencymore efficient, greater powerless efficient, lower power
12. Departures from the assumptionssensitive to themrobust: valid whatever the continuous distribution
13. Conclusionsmore conclusions can be drawnfewer 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.

2. One-Sample Runs Test (Test for Randomness)

PURPOSE

Tests whether a sequence of two types of items (or values above/below the median) is random.

Procedure

  1. Mark each observation as type 1 or type 2 (above/below median).
  2. Count the total runs \(R\) (maximal blocks of same type).
  3. Let \(n_1, n_2\) be counts of each type.
  4. Beyond the runs tables (\(n_1\) or \(n_2 > 20\)), use the normal approximation, which is already fair once both exceed 10: \[ E(R) = \dfrac{2 n_1 n_2}{n_1 + n_2} + 1, \quad \text{Var}(R) = \dfrac{2 n_1 n_2 (2 n_1 n_2 - n_1 - n_2)}{(n_1 + n_2)^2 (n_1 + n_2 - 1)}. \] \[ Z = \dfrac{R - E(R)}{\sqrt{\text{Var}(R)}} \sim N(0, 1). \]
  5. Too few runs ⇒ clustering; too many runs ⇒ alternation.
EXAMPLE 1

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.

EXAMPLE 2

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\).

Runs, Defined and Counted

DEFINITION

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.

Where the Runs Distribution Comes From

DERIVATION

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).

3. Sign Test

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)\).

Procedure

  1. Discard observations equal to \(M_0\) (or paired ties).
  2. Let \(n\) = total number of non-zero signs; \(S\) = number of "+" signs.
  3. Under \(H_0\), \(S \sim \text{Binomial}(n, 0.5)\).
  4. For large \(n\), use normal approximation: \(Z = (S - n/2)/\sqrt{n/4}\).
EXAMPLE 1 (Single sample)

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 %.

EXAMPLE 2 (Paired)

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 %.

Why the Sign Test is Binomial

DERIVATION

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.

4. Wilcoxon Signed-Rank Test

More powerful than the sign test because it uses the magnitudes of differences as well.

Procedure

  1. Compute differences \(d_i = X_i - M_0\) (or paired \(X_i - Y_i\)). Discard zeros.
  2. Rank \(|d_i|\) (smallest = 1).
  3. Attach the sign of \(d_i\) to each rank.
  4. Let \(W^+\) = sum of positive ranks; \(W^-\) = sum of negative ranks. Test statistic \(W = \min(W^+, W^-)\).
  5. For small \(n\), use Wilcoxon tables; for large \(n\): \[ Z = \dfrac{W - n(n+1)/4}{\sqrt{n(n+1)(2n+1)/24}} \sim N(0,1). \]
EXAMPLE 1

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\).

EXAMPLE 2

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.

5. Median Test (Two Independent Samples)

Tests whether two samples come from populations with the same median.

Procedure

  1. Combine both samples and find the grand median \(M\).
  2. Form a 2 × 2 contingency table: counts of values above/below \(M\) for each sample.
  3. Apply the χ² test of independence.
EXAMPLE 1

Sample A (10 obs): 4 above, 6 below grand median. Sample B (10 obs): 6 above, 4 below.

Above MBelow M
A46
B64

Expected = 5 each. \(\chi^2 = 4(1)/5 = 0.80\). df = 1, \(\chi^2_{0.05} = 3.84\) ⇒ do not reject \(H_0\).

EXAMPLE 2

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.

The Exact Median Test for Small Samples

THE SET-UP

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 ISample IITotal
\(\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.

6. Wilcoxon–Mann–Whitney U Test

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).

Procedure

  1. Combine both samples and rank from smallest (1) to largest.
  2. Let \(R_1\) = sum of ranks of sample 1; \(R_2\) = sum of ranks of sample 2. Note \(R_1 + R_2 = N(N+1)/2\) where \(N = n_1 + n_2\).
  3. Compute U statistics: \[ U_1 = R_1 - \dfrac{n_1(n_1 + 1)}{2}, \quad U_2 = R_2 - \dfrac{n_2(n_2 + 1)}{2}. \]
  4. Test statistic \(U = \min(U_1, U_2)\). Compare with table; or for large \(n\): \[ Z = \dfrac{U - n_1 n_2 / 2}{\sqrt{n_1 n_2 (n_1 + n_2 + 1)/12}}. \]
EXAMPLE 1

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\).

EXAMPLE 2

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.

7. Wald–Wolfowitz Runs Test (Two Samples)

Tests whether two independent samples come from the same population. Uses runs in the combined ranked sample.

Procedure

  1. Combine the two samples and arrange in ascending order.
  2. Replace each observation by its sample label (A or B).
  3. Count the number of runs \(R\).
  4. Few runs ⇒ samples differ (each clusters separately).
  5. For large \(n_1, n_2\), use the normal approximation (same formulas as one-sample runs test).
EXAMPLE 1

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.

EXAMPLE 2

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 %.

Ties Between the Samples

A PRACTICAL CAUTION

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).

8. Kruskal–Wallis Test (Non-parametric One-way ANOVA)

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\)).

\[ H = \dfrac{12}{N(N+1)}\sum_{j=1}^{k}\dfrac{R_j^{2}}{n_j} - 3(N+1), \qquad H \overset{H_0}{\sim} \chi^2_{k-1}\ \text{(large samples)}. \]

Reject \(H_0\) (equal locations) when \(H\) exceeds \(\chi^2_{k-1}\) at level \(\alpha\).

EXAMPLE

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.)

9. Kolmogorov–Smirnov (K–S) Test

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:

\[ D = \max_x \big|F_n(x) - F_0(x)\big|. \]

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.)

EXAMPLE

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.

Worked Problems on Non-parametric Tests

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.

A. The Sign Test, One Sample

WORKED PROBLEM 1 — is the median score 75?

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.

WORKED PROBLEM 2 — 42 of 120 households below ₹15,000

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.)

B. The Sign Test, Paired Samples

WORKED PROBLEM 3 — two blends of tea

16 tasters rated two blends of tea on a 1–5 scale. Is there a difference between the blends?

Taster12345678910111213141516
Blend A \(x\)3243234233124323
Blend B \(y\)4445325245314542
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.

0 1 2 3 observed 3 4 5 6 7 8 9 10 11 12 13 number of + signs, u critical values 2 and 11 (5%, two-sided), n = 13 outside the rejection region → do not reject H₀
Fig 5.1 — Worked Problem 3. The exact null distribution of the number of + signs, Binomial(13, \(\tfrac12\)). Each tail holds at most 2.5% only out to 2 and from 11; the observed 3 sits just inside the acceptance region (exact two-sided p = 0.092).
WORKED PROBLEM 4 — thirty students, two tests

Thirty students took two tests:

Student12345678910
Test I120168139101134177156133139140
Test II132159121110178201160112153153
sign−++−−−−+−−
Student11121314151617181920
Test I106103154133147103167154113156
Test II108126155178145129170132149170
sign−−−−+−−+−−
Student21222324252627282930
Test I141174159140168108142151104114
Test II121212134170182150184134108139
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.

C. The Runs Test for Randomness

WORKED PROBLEM 5 — sixteen daily sales

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\).

WORKED PROBLEM 6 — 27 heads in 40 tosses, 14 runs

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.

D. The Two-sample Runs Test

WORKED PROBLEM 7 — typists in two offices

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:

41454853545759616263646670
ABAABBAABBBAB

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.

WORKED PROBLEM 8 — a kabaddi team's season

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).

2 4 6 8 9 10 12 14 16 18 20 22 24 observed 24 26 number of runs, r critical values 9 and 20 (5%, two-sided), n₁ = 14, n₂ = 13 in the rejection region → reject H₀
Fig 5.2 — Worked Problem 8. The exact distribution of the number of runs for 14 W's and 13 L's. Too few runs (9 or fewer) means streaks; too many (20 or more) means the results alternate more than chance allows. The season's 24 runs fall in the upper tail (exact two-sided p = 0.0002).
WORKED PROBLEM 9 — bricks fired at two temperatures

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.

E. The Median Test

WORKED PROBLEM 10 — waiting times at two counters

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 ACounter BTotal
\(\ge 33\)718
\(< 33\)257
Total9615

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).

WORKED PROBLEM 11 — the brick data by the median test

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 ISample IITotal
\(\ge 421\)12 (\(a\))9 (\(b\))21
\(< 421\)6 (\(c\))14 (\(d\))20
Total182341

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\).)

10. Choosing the Right Non-parametric Test

QuestionTestParametric counterpart
Is a sequence random?One-sample runs test—
Test population median (one sample)Sign / Wilcoxon signed-rankOne-sample t
Paired samplesSign / Wilcoxon signed-rankPaired t
Two independent mediansMedian testTwo-sample t
Two independent samples (general)Mann–Whitney U / Wald–WolfowitzTwo-sample t

Key Take-aways

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.

→ Practical Course