tools · statistics NIST SP 800-22 Rev. 1a

NIST-style
RNG testing kit.

Pick a generator, set a sample size, hit run. The kit evaluates the stream against four classical tests — chi-squared equidistribution, Benford's Law, and the Monobit and Runs tests from NIST SP 800-22 Rev. 1a — and shows you what the numbers actually say.

Configure

step 01

JSON input is treated as an array of floats in $[0, 1)$. Bigger samples mean tighter chi-squared estimates but slower runs.

Results

step 02

Run a test to see chi-squared, Benford, Monobit, and Runs results here.

What the tests actually mean

notes

Frequency / equidistribution. Bin the samples uniformly across $[0, 1)$ and compare bin counts to expectation via chi-squared. A truly uniform RNG won't sit at exactly $\chi^2 = 0$ — the test uses $df = \text{numBins} - 1$ and the critical value at $\alpha = 0.05$. Falling below critical is "consistent with uniform"; way above means the bins are too uneven to be chance.

Benford's Law. The leading significant digit of many natural-data populations follows $P(d) = \log_{10}(1 + 1/d)$. Uniform PRNGs in $[0, 1)$ also approximately follow Benford's distribution because of the geometric way leading digits emerge from rescaling. We extract the first non-zero digit (so $0.0473 \rightarrow 4$, not $0$) and check the fit.

Monobit test (SP 800-22 §2.1). Treat each sample as 32 bits and check that the proportion of $1$s and $0$s is consistent with a fair coin. Reports a $p$-value via $\operatorname{erfc}$; passes at $p \ge 0.01$.

Runs test (SP 800-22 §2.3). Counts the number of bit-runs (maximal sequences of identical bits). Too few runs ⇒ the bits cluster (slow oscillation); too many ⇒ they over-alternate. Both indicate non-randomness. Passes at $p \ge 0.01$.

Caveat. These are simplified, browser-side analogs of a small subset of SP 800-22's full test battery. A passing run here is necessary but not sufficient evidence of cryptographic suitability. A single failing run is also not proof of a broken RNG — repeat the test and look at the distribution of $p$-values across many runs.