# Wald-Wolfowitz runs test

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
34,200pages on
this wiki

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

A 'run' is a sequence of adjacent equal symbols. I.e. the following sequence: ++++---+++--++++++---- is divided in six runs, three of them are made out of + and the others are made out of -. If +s and -s alternate with each other in a random order, the number of runs is a random var whose distribution has:

mean: $\mu=\frac{2\ N_+\ N_-}{N}+1$ , with $N=N_++N_-$
Variance: $\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.

Run-test can be used to:

1. test the randomness of a distribution, by taking the data in the same order they have been taken and marking with + the ones above the median and with - the ones below the median.
2. test whether a function fits well a data set, by marking with + the data above the function and with minus the data below the function.

For this use, runs test, that takes into account the signs but not the distance, is considered complementary to chi square test, that takes into account the distance but not the signs.

Kolmogorov-Smirnov test and chi-square test are more powerful, if they can be applied.