Tool
NIST randomness test suite
Eight tests from NIST SP800-22 Rev.1a running in your browser on bit streams from five chaotic PRNGs plus Math.random()and a deliberately biased baseline. Pass = p ≥ 0.01 (the standard NIST significance level).
r > 3.57 is chaotic; r = 4 is the canonical full chaos. Try r = 3.7 to see weaker mixing.
Overall score: 4 / 8 tests passed at α = 0.01
| Test | p-value | Verdict (α = 0.01) | What it checks |
|---|---|---|---|
| Frequency (monobit) | 0.057433 | PASS | Are 0s and 1s balanced overall? |
| Block frequency (M = 128) | 0.020173 | PASS | Is the 1-density similar in every 128-bit window? |
| Runs | 0.000000 | FAIL | Are runs of identical bits the right length? |
| Longest run (block = 8) | 0.000000 | FAIL | Max run of 1s within each 8-bit block. |
| Cumulative sums | 0.112266 | PASS | Max excursion of the ±1 walk should match a Brownian-bridge tail. |
| Serial (m = 3) | 0.000000 | FAIL | Are all 3-bit patterns equally likely? |
| Approximate entropy (m = 3) | 0.000000 | FAIL | Bandt-Pompe-style block entropy. |
| DFT spectral (first 2048 bits) | 0.239553 | PASS | Periodic structure in the bit stream? |
Toy NIST SP800-22 scoreboard
Four of the simplest tests: monobit frequency, runs, longest-run (block = 8), and approximate-entropy (block = 3). p-value < 0.01 rejects the random null. The deliberately biased source should fail multiple tests; a well-tuned chaotic PRNG should pass.
Caveat: passing these toy tests is necessary but not sufficient for cryptographic use.
What the tests check
- Frequency (monobit) — proportion of 1s ≈ 1/2.
- Block frequency — same, but per 128-bit window (catches non-stationarity).
- Runs — total number of runs of identical bits should match the expected binomial value.
- Longest run within block — distribution of max-runs-of-1s within 8-bit windows.
- Cumulative sums — the partial-sum random walk's max excursion should follow a Brownian-bridge distribution.
- Serial (m = 3) — every 3-bit pattern should occur with frequency 1/8.
- Approximate entropy (m = 3) — block-entropy difference between m and m + 1; small for periodic, large for random.
- Discrete Fourier transform (spectral) — power concentrated below the 95% threshold should account for ≈ 95% of frequencies. Detects periodicity.
Caveat: passing these 8 tests is necessary but not sufficient for cryptographic use. NIST's full SP800-22 suite has 15 tests; cryptographic certification adds dieharder, TestU01 BigCrush, and theoretical analysis.
Cross-link: an embedded version of this board is on /applications/cryptography alongside the chaotic image-cipher demo.
FAQ