Statistical Methods

Measure contiguous active runs in a binary sequence

Define the task

Define what active means before converting observations to zeros and ones. A threshold crossing, device-on interval and completed task are different events even if all use binary coding. Decide whether a missing observation breaks a run, remains unknown or is handled by another prespecified rule. Never silently encode missing values as zero.

Carry out the check

In one dimension, adjacent active samples form a connected component. Start a new run when a one follows a zero or the beginning of the sequence; close it at the next zero or end. Record start index, end index and sample count. If each sample represents a full equal-duration interval, multiply count by that duration. If values are instantaneous observations, first-to-last timestamp span is different and does not establish continuous duration.

Worked hypothetical example

For hypothetical states 0, 1, 1, 0, 1 at two seconds per represented interval, active runs are indices 1–2 and 4–4. Their counts are 2 and 1, represented durations are 4 and 2 seconds, and total active duration is 6 seconds. The instantaneous timestamp span of the first run would instead be 2 seconds. Report which convention is used, especially at the start and end of the recording. No duration uncertainty or event classification is inferred by the calculator.

Method checked 15 November 2026 against SciPy documentation: label.

Open the binary active run duration audit.

Download the active run duration record.

Related reading

Reading path: Analyze data. Guide 146 of 152. Choose any guide to suit your project.

Statistical Methods

Audit clustering in a binary sequence with run counts

Count contiguous blocks of two prespecified labels and compare their number with the random-order expectation.

Statistical Methods

Fit a nondecreasing sequence with isotonic regression

A worked guide to the assumptions and checks: Fit an ordered sequence under a monotonicity constraint.

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