Qm
Core

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 nn with n1n_1 pluses and n2n_2 minuses has an expected number of runs under randomness of μR=2n1n2n1+n2+1\mu_R = \frac{2 n_1 n_2}{n_1+n_2} + 1, with a known variance formula alongside it, so a z-score comparing the observed run count to μR\mu_R 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.

Streaky (too few runs): + + + − − − + + + − − − + + + Alternating (too many runs): + − + − + − + − + − + − + −
Both patterns are non-random, but in opposite directions: a runs test catches either extreme against the number expected from a genuine coin-flip sequence.

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.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. Ask and answer about this concept. Off-topic gets removed.
  2. No homework dumps. Show what you tried first.
  3. Corrections are welcome. Cite a source when you claim an error.

Loading discussion…

Related concepts

Practice in interviews

Further reading

  • Wald & Wolfowitz, On a Test Whether Two Samples are from the Same Population
ShareTwitterLinkedIn