Skip to content
Omnikalc

Runs test calculator (Wald-Wolfowitz)

Enter how many items of each kind a sequence contains and how many runs it shows to get the expected number of runs, the z-score and the p-value of the randomness test.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Results

z-score

-1.723

Compatible with a random order
Expected number of runs
11.909
Standard deviation of the runs
2.269
Two-sided p-value
0.0849
No evidence against randomness
Largest possible number of runs
21
Smallest possible number of runs
2

The runs test calculator applies the Wald-Wolfowitz test to a sequence of two kinds of values and tells you whether the order looks random, from the expected number of runs, the z-score and the p-value.

How the calculation works

  • Enter the number of items of each kind.
  • Enter the number of runs you counted.
  • The calculator gives the expected runs, their standard deviation, z, the p-value and the possible range.

Example

A sequence has 12 heads and 10 tails, in 8 runs. The expected number is 2 × 12 × 10 / 22 + 1 = 11.909, with a standard deviation of 2.269. So z = (8 − 11.909) / 2.269 = -1.723 and the two-sided p-value is 0.0849: there is no clear evidence against randomness at the 5 % level, although the runs are a bit fewer than expected.

Why it matters

The calculator helps statistics students, quality controllers who check for drifts in a process, traders who test a series of gains and losses, and researchers who verify that a coin or a generator behaves randomly.

Good to know

The test detects clustering and alternation but not every kind of non-randomness. For measurements, split at the median so that the groups are balanced, and ignore values equal to the median. With fewer than about 10 items in a group, use exact tables rather than the normal approximation. A significant result tells you that the order is unusual, not why. Combine it with a plot of the data in order. A trend or a cycle in a process shows up as too few runs, while an overcorrecting operator causes too many.

The sign test calculator compares paired values, the Wilcoxon signed-rank calculator uses their size, the coin flip calculator gives probabilities of sequences and the binomial calculator computes the chance of a given count.

Frequently asked questions

What is a run?

A run is an unbroken stretch of identical values. The sequence H H T H T T has four runs: HH, T, H and TT. A random sequence has a typical number of runs, and the test compares the observed number with the one expected by chance.

How are the expected number and variance computed?

With n1 and n2 items of each kind and N = n1 + n2, the mean is 2 n1 n2 / N + 1 and the variance 2 n1 n2 (2 n1 n2 − N) / (N² (N − 1)). The z-score uses a normal approximation, which is good when both n1 and n2 exceed about 10.

How do I use it for numbers?

Turn the data into two categories, usually above and below the median, then count the runs of that sequence. A trend gives too few runs, and a strict alternation gives too many.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.