# Wald-Wolfowitz runs test

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The runs test (also called Wald-Wolfowitz test) is a non-parametric test that checks the randomness hypothesis of a two-valued data sequence.

A 'run' is a sequence of adjacent equal elements. For example, the sequence "++++−−−+++−−++++++−−−−" is divided in six runs, three of which consist of +s and the others of −s. If +s and −s alternate randomly, the number of runs is a random variable whose distribution has:

• mean ${\displaystyle \mu ={\frac {2\ N_{+}\ N_{-}}{N}}+1\,,}$ where ${\displaystyle N=N_{+}+N_{-}}$
• variance ${\displaystyle \sigma ^{2}={\frac {2\ N_{+}\ N_{-}\ (2\ N_{+}\ N_{-}-N)}{N^{2}\ (N-1)}}={\frac {(\mu -1)(\mu -2)}{N-1}}}$

If there are too many runs more or less than foreseen, the data are likely to alternate in a nonrandom order.

Runs tests can be used to test:

1. the randomness of a distribution, by taking the data in the given order and marking with + the data greater than the median and with − the rest;
2. whether a function fits well to a data set, by marking the data exceeding the function value with + and the other data with −. For this use, the runs test, which takes into account the signs but not the distances, is complementary to the chi square test, which takes into account the distances but not the signs.

The Kolmogorov-Smirnov test is more powerful, if it can be applied.