The Run Test

JavaScript
Given a random sequence, X1,...,XN, of 0's and 1's,
the run test tests the null hypothesis that the variables
are independent Bernoulli with some unknown probability, p, of a 1.
The run test is based on the conditional distribution of the variables,
given the number, m, of 0's and the number, n, of 1's,
and so the null distribution is independent of p.
The run test statistic, Rm,n, is the number of runs in the sequence,
where a run is a consecutive subsequence of the same value.

      Enter m and n and the cutoff point.

     No. of 0's m: 
     No. of 1's n: 
          r-value: 

P(Rm,n <= r) :

The probabilities calculated here are for Rm,n, under the null hypothesis
that all orderings of m 0's and n 1's are equally likely.
Computation time is proportional to r+min(m,n).