Wald-Wolfowitz runs test
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.