The Runs Test for Randomness
A test that counts consecutive streaks of the same sign in a sequence — too few or too many runs both signal that the sequence isn't random, just in opposite ways.
Take a sequence of up (+) and down (−) daily returns and ask: is this genuinely random, or is there hidden structure — streakiness (momentum) or excessive flip-flopping (mean reversion)? Counting the actual number of "runs" — maximal streaks of the same sign — and comparing it to how many runs a truly random coin-flip sequence would typically produce answers this without needing to model the returns at all.
A sequence of length with pluses and minuses has an expected number of runs under randomness of , with a known variance formula alongside it, so a z-score comparing the observed run count to gives a standard hypothesis test.
A worked example
Twenty days of sign returns: + + + − − − + + + − − − + + + − − − + +. That's only 7 runs in 20 observations with roughly 12 pluses and 8 minuses — far fewer than the roughly 10-11 runs expected under randomness. Too few runs means the signs cluster into long streaks: a momentum pattern, not noise. Conversely, a sequence that alternates almost every single day (+ − + − + − ...) would show far more runs than expected, which is the signature of mean reversion, not randomness either.
The runs test compares the observed number of same-sign streaks to the count expected under pure randomness — too few runs indicates momentum-like clustering, too many indicates mean-reversion-like alternation, and either departure rejects the hypothesis that the sequence is random.
Practice in interviews
Further reading
- Wald & Wolfowitz, On a Test Whether Two Samples are from the Same Population