- Introduced by
- Abraham Wald & Jacob Wolfowitz
- Year
- 1940
- Type
- Nonparametric randomness test
What does it do?
The Wald-Wolfowitz runs test is a nonparametric hypothesis test that checks whether a sequence of observations, coded as two symbols, is randomly ordered or shows systematic structure.
It counts the runs, meaning the unbroken blocks of identical symbols, and compares that count with the number expected under random arrangement. The test is usually attributed to Abraham Wald and Jacob Wolfowitz (1940).
The intuition behind the method
Imagine a sequence of coin-flip outcomes written as a row of heads (H) and tails (T). A perfectly random sequence would alternate somewhat unpredictably, producing neither very long streaks nor a rigid alternating pattern. The runs test formalises this intuition: it counts how many unbroken consecutive groups (runs) of the same symbol appear. Too few runs suggest clustering — the same symbol persists longer than chance would expect. Too many runs suggest oscillation — the symbols alternate more than chance would expect. Either extreme is evidence against randomness.
History
The test is commonly traced to Abraham Wald and Jacob Wolfowitz, whose 1940 paper appeared in the Annals of Mathematical Statistics. The database record for that paper carries a title on comparing two samples, and its abstract is not available here. Attribution of the one-sample run-count distribution to this paper should be checked against the original work before citing.
When to use it
Choose the runs test when you need to check whether a single sequence of observations is randomly ordered before applying methods that assume independence. Typical sequences are residuals from a model fitted in time order, a quality-control stream, or responses listed in the order they were collected. Each observation must be assignable to one of two categories, either literally (binary data) or by dichotomising a continuous variable at a threshold such as the median. The test needs a reasonable minimum number of observations; the facts give 10. Fix the symbol coding before testing, including the rule for observations equal to the threshold, and apply that rule consistently. Do not use it when the data have more than two natural categories without a justified dichotomisation, when the order of observations has no meaning, or when you need to test a specific form of dependence, such as autocorrelation at particular lags. The related Ljung-Box and Durbin-Watson tests are more targeted for those questions. No normality or other distributional assumption is needed.
Limitations and considerations
- Results depend on how continuous data are dichotomised. A different threshold changes the symbol sequence, and therefore the run count and the verdict.
- The normal approximation for Z is unreliable when either symbol count is small, so exact critical values should be used in that case.
- The test detects departure from random ordering in general. It does not identify the specific type of dependence or any trend.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The null distribution of the run count depends only on the two symbol counts, so no distributional assumption about the underlying values is needed.
- It applies directly to binary outcomes, and to continuous data once they are dichotomised at a chosen threshold.
- The run count shows the direction of departure: fewer runs than expected indicate clustering, and more runs than expected indicate alternation.
Applications
- Checking whether residuals from a regression model are randomly ordered or show autocorrelation.
- Quality-control monitoring: testing whether defective and non-defective items in a production line are randomly distributed.
- Survey methodology: verifying that the order in which respondents completed a questionnaire is unrelated to their answers.
- Time-series preprocessing: confirming the independence assumption before fitting models that require it.
How it works
How it works
The null hypothesis states that the sequence is random, meaning that each observation is independent of the ones before it. The alternative hypothesis states that the sequence is not random, which covers both excessive clustering and excessive alternation.
Formula
H_0:\text{ the sequence is random}\quad H_1:\text{ the sequence is not random}Each observation is coded as one of two symbols, for example above or below the median for continuous data, or the two literal categories for binary data. A run is a maximal unbroken block of identical symbols, and R is the total number of runs. Under the null hypothesis, the mean μ_R and variance σ_R² of R depend only on the two symbol counts n₁ and n₂, as given in the formula. For large samples, Z = (R − μ_R) / σ_R is approximately standard normal.
Formula
Z = \dfrac{R - \mu_R}{\sigma_R},\quad \mu_R = \dfrac{2n_1 n_2}{n_1+n_2}+1,\quad \sigma_R^2 = \dfrac{2n_1 n_2(2n_1 n_2 - n_1 - n_2)}{(n_1+n_2)^2(n_1+n_2-1)}If the p-value falls below the 0.05 significance level stated in the formula, the null hypothesis of randomness is rejected, indicating non-random ordering. Because the alternative covers both clustering and alternation, the test is two-sided: the p-value is taken from both tails of the standard normal distribution for Z. When either symbol count is small, the normal approximation may be inaccurate, so exact critical values for the observed counts should be used instead, from reference tables or statistical software.
Formula
\text{reject } H_0 \text{ if } p < 0.05 \text{ (two-sided, since } H_1 \text{ covers clustering and alternation)}Common pitfalls
- Applying the normal approximation when one symbol count is small, instead of using exact critical values.
- Reading a non-significant result as evidence of independence. The test can have low power against dependencies that leave the run count largely unchanged.
- Dichotomising at the median discards information about magnitude, so patterns in the size of values can be hidden from the test.
Frequently asked questions
How do I apply the runs test to continuous data?
Dichotomise the series at a natural threshold — most commonly the sample median. Observations above the median are coded with one symbol and observations at or below it with the other. The runs test then proceeds on this binary sequence. The choice of threshold matters: using the median is conventional, but another theoretically motivated cut-point may be more appropriate in specific contexts.
When should I use the exact distribution rather than the normal approximation?
When either symbol count (n₁ or n₂) is small, the normal approximation can be inaccurate. In that case use exact critical values for the observed counts (n₁, n₂) from reference tables or statistical software rather than the normal approximation. No single small-sample cut-off is given here; the minimum sample size of 10 in the facts is an overall guide only.
What does a significant result actually tell me?
A significant runs test tells you that the ordering of the sequence is unlikely to be random. It does not tell you what the structure is. Too few runs indicate clustering (positive autocorrelation or trend); too many indicate alternation (negative autocorrelation). Examining the run count relative to its expected value points toward which type of non-randomness is present.
Is the runs test the same as the Wald-Wolfowitz two-sample test?
They share the same theoretical framework and authors, but they address different questions. The one-sample runs test examines whether a single sequence is randomly ordered. The two-sample Wald-Wolfowitz test combines two samples into one ranked sequence and counts runs to test whether both samples come from the same population — analogous in spirit to the Mann-Whitney U test.
Related methods
Sources
Wald, A. & Wolfowitz, J. (1940). On a test whether two samples are from the same population. Annals of Mathematical Statistics, 11(2), 147–162.
Open DOI reference