Skip to content
Calcrivo

Random Number Quality Calculator

Run the NIST SP 800-22 monobit frequency test on a bitstream sample and estimate its min-entropy per bit.

Inputs

bits
bits

Monobit p-value

0.6171

Test Statistic s_obs

0.5000

Proportion of 1 Bits

50.0250%

Min-entropy per Bit

0.9993bits

Expected 1-bit Count Range

498712 – 501288 ones at 99% confidence

Assessment

PASS — the bitstream is consistent with a fair random source

Step by step

  1. Values used

    Bits in the sample = 1,000,000 bits; Number of 1 bits observed = 500,250 bits; Significance level α = 0.0100

  2. Random Number Quality

    s_obs = |ones − zeros| ÷ √n and p-value = erfc(s_obs ÷ √2); the stream passes when p ≥ α.

  3. Min-entropy estimate

    min-entropy per bit = −log₂(max(p₁, 1 − p₁)), the most-likely-outcome bound.

  4. Monobit p-value

    = 0.6171

  5. Test Statistic s_obs

    = 0.5000

  6. Proportion of 1 Bits

    = 50.0250

  7. Min-entropy per Bit

    = 0.9993 bits

  8. Expected 1-bit Count Range

    = 498712 – 501288 ones at 99% confidence

  9. Assessment

    = PASS — the bitstream is consistent with a fair random source

How it works

The monobit test is the first of the NIST SP 800-22 battery: it checks whether the count of ones sits inside the normal distribution expected of a fair coin, with standard deviation √n ÷ 2. Min-entropy is a stricter measure than Shannon entropy because it assumes the attacker always guesses the most likely value. A biased or stuck entropy source silently weakens every key, nonce and token derived from it, and monobit failure is the cheapest early warning that a hardware RNG or a virtualised entropy pool has degraded.

Formulas

Random Number Quality

s_obs = |ones − zeros| ÷ √n and p-value = erfc(s_obs ÷ √2); the stream passes when p ≥ α.

n
Sample size in bits
s_obs
Normalised absolute imbalance between 1s and 0s
α
Significance level, conventionally 0.01

Min-entropy estimate

min-entropy per bit = −log₂(max(p₁, 1 − p₁)), the most-likely-outcome bound.

Frequently Asked Questions

How is Random Number Quality calculated?

s_obs = |ones − zeros| ÷ √n and p-value = erfc(s_obs ÷ √2); the stream passes when p ≥ α. The monobit test is the first of the NIST SP 800-22 battery: it checks whether the count of ones sits inside the normal distribution expected of a fair coin, with standard deviation √n ÷ 2. Min-entropy is a stricter measure than Shannon entropy because it assumes the attacker always guesses the most likely value.

Why does Random Number Quality matter?

A biased or stuck entropy source silently weakens every key, nonce and token derived from it, and monobit failure is the cheapest early warning that a hardware RNG or a virtualised entropy pool has degraded.

What values do I need to enter?

This calculator takes 3 inputs: Bits in the sample, Number of 1 bits observed, Significance level α. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.

Is passing monobit enough?

No. It only detects an imbalance in the overall count — an alternating 0101… stream passes perfectly. Run the full SP 800-22 battery (runs, longest-run, spectral, serial) and treat monobit as a smoke test.

What sample size do I need?

SP 800-22 recommends at least 100 bits for monobit, but a meaningful assessment needs 10⁶ bits or more so the test can detect small biases.

You might also need