The OpenD Programming Language

runsTest

Wald-wolfowitz or runs test for randomness of the distribution of elements for which positive() evaluates to true. For example, given a sequence of coin flips [H,H,H,H,H,T,T,T,T,T] and a positive() function of "a == 'H'", this test would determine that the heads are non-randomly distributed, since they are all at the beginning of obs. This is done by counting the number of runs of consecutive elements for which positive() evaluates to true, and the number of consecutive runs for which it evaluates to false. In the example above, we have 2 runs. These are the block of 5 consecutive heads at the beginning and the 5 consecutive tails at the end.

Alternatives are Alt.less, meaning that less runs than expected have been observed and data for which positive() is true tends to cluster, Alt.greater, which means that more runs than expected have been observed and data for which positive() is true tends to not cluster even moreso than expected by chance, and Alt.twoSided, meaning that elements for which positive() is true cluster as much as expected by chance.

double
runsTest
(
alias positive = "a > 0"
T
)
if ()

Bugs

No exact calculation of the P-value. Asymptotic approximation only.

References: http://en.wikipedia.org/wiki/Runs_test

Meta