# Wald-Wolfowitz runs test

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:

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:

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