Statistical Methods

Audit clustering in a binary sequence with run counts

Define the two labels

A run is a contiguous block of the same label. Specify how measurements become labels, including a rule for values equal to a cut point. For naturally binary outcomes use the recorded categories directly. Preserve acquisition order and separate unrelated series.

Condition on the totals

Count the observations of each label and then the number of runs. Under random ordering conditional on the label totals, the expected number of runs is one plus twice their product divided by the sequence length. A deficit of runs suggests clustering, while an excess suggests alternation. This comparison is descriptive unless an appropriate reference distribution is used.

Hypothetical sequence

For A A B B A B, the contiguous blocks are AA, BB, A and B. There are four runs, with three of each label. The expected count is 1 + 2×3×3/6 = 4. A A A B B B has the same totals and only two runs. This small example illustrates what order contributes beyond the marginal counts. It does not justify a normal approximation to a test statistic.

Record unexpected patterns and examine the collection procedure. A deliberate alternating schedule will increase runs by design. Selection of a threshold specifically because it yields few runs alters the interpretation of a subsequent test.

Method checked 9 November 2026. NIST/SEMATECH Engineering Statistics Handbook, 1.3.5.13. Runs Test for Detecting Non-randomness.

Binary sequence run count

Related reading

Reading path: Analyze data. Guide 101 of 102. Choose any guide to suit your project.

Statistical Methods

Choose the Clustering Level for Robust Uncertainty

Align cluster-robust covariance estimation with shared disturbances and the number of independent groups.

Statistical Methods

Audit Binary Prediction Scores

Calculate a binary Brier score from valid aggregate inputs and distinguish overall probability accuracy from calibration.

Browse this reading pathTools for this stageGuides and downloads for this stage