# Runs Test Calculator (Wald-Wolfowitz)

Free Wald-Wolfowitz runs test calculator. Enter a binary sequence to test for randomness using the number of runs, z-score, and p-value.

## What this calculates

Test whether a binary sequence is random using the Wald-Wolfowitz runs test. A run is a consecutive sequence of identical values. Too few or too many runs compared to what is expected under randomness indicates a non-random pattern.

## Inputs

- **Sequence Length** — min 4, max 20 — Number of values in the sequence (4-20).
- **V1** — min 0, max 1 — Binary value: 0 or 1.
- **V2** — min 0, max 1 — Binary value: 0 or 1.
- **V3** — min 0, max 1 — Binary value: 0 or 1.
- **V4** — min 0, max 1 — Binary value: 0 or 1.
- **V5** — min 0, max 1 — Binary value: 0 or 1.
- **V6** — min 0, max 1 — Binary value: 0 or 1.
- **V7** — min 0, max 1 — Binary value: 0 or 1.
- **V8** — min 0, max 1 — Binary value: 0 or 1.
- **V9** — min 0, max 1 — Binary value: 0 or 1.
- **V10** — min 0, max 1 — Binary value: 0 or 1.
- **V11** — min 0, max 1 — Binary value: 0 or 1.
- **V12** — min 0, max 1 — Binary value: 0 or 1.
- **V13** — min 0, max 1 — Binary value: 0 or 1.
- **V14** — min 0, max 1 — Binary value: 0 or 1.
- **V15** — min 0, max 1 — Binary value: 0 or 1.
- **V16** — min 0, max 1 — Binary value: 0 or 1.
- **V17** — min 0, max 1 — Binary value: 0 or 1.
- **V18** — min 0, max 1 — Binary value: 0 or 1.
- **V19** — min 0, max 1 — Binary value: 0 or 1.
- **V20** — min 0, max 1 — Binary value: 0 or 1.

## Outputs

- **Number of Runs (R)** — Observed number of runs in the sequence.
- **Expected Runs E(R)** — Expected number of runs under randomness.
- **Std Deviation of R** — Standard deviation of the runs distribution.
- **Z-Score** — Standardized test statistic.
- **P-Value (approx)** — Two-tailed p-value from normal approximation.
- **Result** — formatted as text — Whether the sequence appears random.

## Details

The Wald-Wolfowitz runs test is a non-parametric test for detecting non-randomness in a sequence of two types of elements (coded as 0 and 1). A 'run' is a maximal subsequence of identical values. For example, the sequence 1 1 0 0 1 0 has four runs: (1 1), (0 0), (1), (0).

Under the null hypothesis of randomness, the expected number of runs is E(R) = (2n1n2)/(n1+n2) + 1, where n1 and n2 are the counts of each type. The variance is Var(R) = (2n1n2*(2n1n2 - n1 - n2)) / ((n1+n2)^2 * (n1+n2 - 1)). For moderate sample sizes, the standardized statistic Z = (R - E(R)) / sqrt(Var(R)) is approximately standard normal.

Too few runs suggest clustering or positive autocorrelation (similar values tend to group together). Too many runs suggest alternation or negative autocorrelation. The runs test is widely used in quality control, time series analysis, and testing the randomness of residuals from regression models.

## Frequently Asked Questions

**Q: What does the runs test measure?**

A: The runs test measures whether a binary sequence shows a pattern that is unlikely under true randomness. Too few runs suggest clustering (like long streaks), while too many runs suggest systematic alternation.

**Q: Can I use the runs test for non-binary data?**

A: Yes, but you must first convert the data to binary form. A common approach is to code values above the median as 1 and values at or below as 0. This converts any numerical sequence into a binary sequence suitable for the runs test.

**Q: How many observations do I need for the runs test?**

A: The normal approximation works reasonably well when both n1 and n2 are at least 10. For smaller samples, exact critical values from binomial tables should be used. This calculator uses the normal approximation.

---

Source: https://vastcalc.com/calculators/statistics/runs-test
Category: Statistics
Last updated: 2026-04-21
