Runs Test for Randomness Calculator Formula
Understand the math behind the runs test for randomness calculator. Each variable explained with a worked example.
Formulas Used
Expected Runs
expected_runs = 1 + (2 * n1 * n2) / (n1 + n2)Std Dev
std_runs = sqrt((2 * n1 * n2 * (2 * n1 * n2 - n1 - n2)) / (pow(n1 + n2, 2) * (n1 + n2 - 1)))Z Statistic
z_stat = (runs - (1 + (2 * n1 * n2) / (n1 + n2))) / sqrt((2 * n1 * n2 * (2 * n1 * n2 - n1 - n2)) / (pow(n1 + n2, 2) * (n1 + n2 - 1)))Variables
| Variable | Description | Default |
|---|---|---|
n1 | Count Type A | 15 |
n2 | Count Type B | 10 |
runs | Number of Runs | 8 |
How It Works
Wald-Wolfowitz Runs Test
mu = 1 + 2*n1*n2/(n1+n2)
Tests randomness of binary sequences.
Worked Example
15 As, 10 Bs, 8 runs.
n1 = 15n2 = 10runs = 8
- 01Expected = 13
- 02Z = -2.15, not random
Ready to run the numbers?
Open Runs Test for Randomness Calculator