Runs test for long 01-sequence
To determine whether a 01-sequence is random or not, we develop a test based on Normalapproximation. We know by e.g. simulation that the number of runs in a 01-sequence is approximately normally distributed. We can thus create a Confidence Interval for which in 95% of the experiments the number of runs will lie in.
We calculate
where equals the number of zeroes and the number of ones.
You can approximate the interval boundaries if with:
Number of runs is normally distributed with the above parameters. Thus Acceptance Domain is defined below.
Test decision:
Accecpt randomness hypothesis if number of runs (concecutive runs of 1s or 0s) is in $$ [\mu-2 \sigma, \mu+2 \sigma]
\mathbb{P}(R \in[\mu-2 \sigma, \mu+2 \sigma])=\mathbb{P}(-2 \leq(R-\mu) / \sigma \leq 2) \rightarrow \Phi(2)-\Phi(-2) \approx 0.954