Runs Test Calculator
Paste a sequence of numbers, or of two symbols such as heads and tails, and get the Wald–Wolfowitz runs test: the number of runs, the number expected under randomness, z, and an exact p-value for small samples or a normal approximation for large ones. Your sequence is drawn split into its runs, and every step of the working is shown. Free, no sign-up.
0 items
Enter a sequence of at least two values to test.
How to Use the Runs Test Calculator
- 1. Choose the sequence type. Pick Numbers for measurements in the order they were collected, or Two categories for a sequence of two symbols such as H and T, or yes and no.
- 2. Paste the sequence in order. The order is the whole point of this test — do not sort the values. For numbers, choose how to split them: at the median (the default), the mean, or a value of your own.
- 3. Choose the alternative. Two-sided asks whether the sequence is non-random in any way. "Too few runs" looks for clustering or trends; "too many runs" looks for alternation.
- 4. Read the result. Compare the observed runs with the expected number, check the p-value, and look at the drawn runs. Copy the APA line when you are done.
What the Runs Test Measures
A run is an unbroken stretch of the same symbol: in H H T T T H, there are three runs. If the order of n₁ symbols of one kind and n₂ of the other is random, the number of runs R should be close to μ = 2n₁n₂/N + 1, where N = n₁ + n₂. Fewer runs than that means like symbols are bunched together — a trend, a drifting mean, or serial dependence. More runs means the symbols alternate more than chance would allow, which can signal overcorrection or a systematic oscillation.
For small samples the calculator uses the exact distribution of R, which counts the arrangements with each number of runs: P(R = 2k) = 2·C(n₁ − 1, k − 1)·C(n₂ − 1, k − 1) / C(N, n₁), and a similar sum for odd R. The two-sided p-value is twice the smaller tail, capped at 1. When either group has more than 20 values, it uses the normal approximation z = (R − μ)/σ with σ² = 2n₁n₂(2n₁n₂ − N) / (N²(N − 1)). Both p-values are always shown, so you can see how close they are.
Numeric data are turned into two symbols by comparing each value with a cutoff, normally the median so the two groups are about equal. Values exactly equal to the cutoff have no side, so they are dropped — the usual convention — and the calculator reports how many it removed.
Worked Example: Twenty Measurements in Order
Click Try an example to load 20 measurements in the order they were taken. The median is 14.5, which puts 10 values above it and 10 below.
Runs test, step by step
Sequence: − + − + + − − + − + + − − + + − + − + −
n₁ = 10, n₂ = 10, N = 20, runs R = 15
μ = 2 × 10 × 10 / 20 + 1 = 11; σ² = 4.737, σ = 2.176; z = (15 − 11) / 2.176 = 1.84
Exact: P(R ≥ 15) = .0513, so two-sided p = .1025 (normal approximation: .066)
In APA style: a Wald–Wolfowitz runs test on the median split did not reject randomness, R = 15, n₁ = 10, n₂ = 10, exact p = .103. The sequence alternates somewhat more than expected, but not more than chance could produce in 20 values. Note how the normal approximation (.066) understates the exact p-value here — a reason to prefer the exact test when the groups are small.
Assumptions and Limits
- It tests order, not distribution. The runs test says nothing about whether values are normal or equally likely; use a normality test or a goodness-of-fit test for that.
- Splitting loses information. Turning numbers into above/below discards how far each value is from the cutoff, so the test is blind to patterns that do not cross it.
- Power is modest. It detects clustering and alternation but misses other kinds of non-randomness, such as a periodic pattern that changes sides evenly.
- Small samples need the exact test. With groups of five or fewer values the normal approximation can mislead, so rely on the exact p-value.
Frequently Asked Questions
- What is the runs test used for?
- It checks whether a sequence of two kinds of outcomes appears in random order. Researchers use it to see whether residuals or measurements show a trend, whether a series of hits and misses is streakier than chance, or whether a coin-toss or random-number sequence looks fair.
- What does a significant runs test mean?
- That the arrangement of the symbols is unlikely under randomness. Too few runs points to clustering, such as a trend or autocorrelation; too many points to systematic alternation. The test does not say what caused the pattern, so look at the sequence plot of the runs.
- How do I run the test on numerical data?
- Split the values into above and below a cutoff, usually the median, keeping the original order, and count the runs. This calculator does the split for you and drops any value equal to the cutoff. Report the cutoff you used, because a different cutoff can give a different result.
- When should I use the exact test and when the normal approximation?
- Use the exact p-value when both groups have 20 or fewer values — the range of the classical tables. Above that the normal approximation is accurate, and the calculator switches to it automatically. A continuity correction is optional and makes the normal p-value slightly more conservative.
- How many observations do I need?
- At least a few of each kind. With very small groups, even the most extreme arrangement may not be able to reach p < .05, so a non-significant result tells you little. A rough rule is to have at least 10 values in each group to have meaningful power.
- How do I report a runs test in APA style?
- Name the test and the cutoff, then give the runs, the group sizes, and the p-value: R = 15, n₁ = 10, n₂ = 10, exact p = .103. For large samples add the z statistic, for example z = 1.84, p = .066.