Explore modules

Exact Conditional Runs Test

Count binary runs and compare their order with every arrangement having the same totals.

Free theory article

Count binary runs and compare their order with every arrangement having the same totals.

Concept & interpretation

A run is a maximal consecutive block of identical symbols in an ordered sequence. For a binary sequence of zeroes and ones, analyzing the number of runs provides a non-parametric test for randomness. If the symbols are arranged randomly, the number of runs will typically fall within a predictable range.

Interactive Experiment

Open the Exact Conditional Runs Test module to test arbitrary short binary sequences.

  1. Enter the sequence 000111 in the Sequence input. Verify that the expected runs (conditionalMean) is 4 and the p-value is exactly 1/5 (0.2).
  2. Change the sequence to an alternating pattern: 010101. The number of runs is now 6. Notice that the distance from the mean is still 2, so the p-value remains 1/5.
  3. Enter a sequence like 001011. This produces exactly 4 runs, perfectly matching the conditional mean. The p-value becomes 1, as all outcomes are at least as extreme as a distance of 0.
Read the full free theory article