Random Number Quality Calculator
Run the NIST SP 800-22 monobit frequency test on a bitstream sample and estimate its min-entropy per bit.
About Random Number Quality Calculator
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.
Worked example
With the default values below, Random Number Quality Calculator returns Monobit p-value of 0.6171. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Bits in the sampleminimum 100 bits
- 1,000,000 bits
- Number of 1 bits observedminimum 0 bits
- 500,250 bits
- Significance level αaccepts 0–0.1
- 0.01
Results
- Monobit p-value
- 0.6171
- Test Statistic s_obs
- 0.5000
- Proportion of 1 Bits
- 50.0250%
- Min-entropy per Bit
- 0.9993 bits
- 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
- 1Values used
- 2Random Number Quality
- 3Min-entropy estimate
- 4Monobit p-value= 0.6171
- 5Test Statistic s_obs= 0.5000
- 6Proportion of 1 Bits= 50.0250
- 7Min-entropy per Bit= 0.9993 bits
- 8Expected 1-bit Count Range= 498712 – 501288 ones at 99% confidence
- 9Assessment= PASS — the bitstream is consistent with a fair random source
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
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.
Related Calculators
- Randomness Entropy Calculator
- Hash Collision Probability Calculator
- Initialization Vector (IV) Calculator
- AES Key Strength Calculator
- Cryptography Health Score Calculator
- Quantum Security Readiness Calculator
- RSA Key Size Calculator
- Argon2 Memory Calculator
- Argon2 Parallelism Calculator
- Argon2 Time Cost Calculator
You might also need
- Initialization Vector (IV) CalculatorCommonly used together
- Randomness Entropy CalculatorCommonly used together
- Hash Collision Probability CalculatorCommonly used together
- RSA Key Size CalculatorAlso in Cryptography
- Quantum Security Readiness CalculatorAlso in Cryptography
- AES Key Strength CalculatorAlso in Cryptography
