🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Quantum Randomness

Quantum ComputingQuantum RandomnessđŸŸĸ Free Lesson

Classical vs Quantum Randomness

Classical randomness: produced by deterministic algorithms (PRNGs) or physical processes. Not certifiably random — the source might have hidden patterns.

Quantum randomness: produced by quantum measurement. Certifiably random — the randomness is guaranteed by the laws of quantum mechanics.

Quantum Random Number Generation (QRNG)

A QRNG produces random bits by measuring a quantum system in superposition:

  1. Prepare a qubit in
  2. Measure in the Z-basis
  3. Result is 0 or 1 with equal probability

The minimum entropy of the output is:

For a perfect qubit: bit per measurement.

Device-Independent QRNG

DI-QNG certifies randomness without trusting the device:

  1. Perform a Bell test (CHSH inequality)
  2. Observe violation
  3. The randomness is certified by the violation magnitude

The amount of certified randomness is:

bits per measurement. At : bits per measurement.

QRNG Implementations

MethodSourceRateQuality
Vacuum fluctuationHomodyne detectionGbpsHigh
Photon countingSingle-photon detectionMbpsHigh
Atomic decayRadioactive sourceskHzPerfect
Beam splittingPhoton arrival timeMbpsHigh

Commercial QRNGs from companies like ID Quantique, Quantis, and Quside achieve Gbps rates with certified randomness.

Applications of QRNG

  1. Cryptography: key generation for one-time pads and QKD
  2. Monte Carlo simulation: unbiased sampling for scientific computing
  3. Lottery and gaming: provably fair random selection
  4. Statistical sampling: random sampling for surveys and experiments
  5. Blockchain: random beacon for consensus protocols

Python: QRNG Simulation

python
import numpy as np

def qrng_measurement(n_bits):
    # Simulate QRNG using Hadamard measurement.
    bits = np.random.randint(0, 2, n_bits)
    return bits

def certifiable_randomness(chsh_value):
    # Compute certifiably random bits from CHSH violation.
    if chsh_value <= 2:
        return 0
    return np.log2((chsh_value + 2) / 4)

bits = qrng_measurement(1000)
empirical_bias = np.mean(bits)
print(f"QRNG output: {empirical_bias:.3f} (ideal: 0.500)")
print(f"Entropy rate: {np.sum([1 if b==0 or b==1 else 0 for b in bits]) / len(bits):.3f} bits/symbol")

for s in [2.0, 2.4, 2.7, 2*np.sqrt(2)]:
    r = certifiable_randomness(s)
    print(f"CHSH={s:.3f}: {r:.3f} certifiable bits")

Randomness Measures

The amount of certifiable randomness from a Bell test:

CHSH (S)Randomness (r)
2.00 bits
2.40.26 bits
2.70.43 bits
2sqrt20.50 bits

QRNG Speed Records

PlatformRateQualityReference
Vacuum fluctuation43 GbpsMin-entropyID Quantique
Photon counting10 GbpsUniformQuantis
Atomic decay100 kbpsPerfectOfficial standards
Beam splitting1 GbpsUniformCustom implementations

Statistical Tests Are Not Certification

A raw stream from a QRNG still has to be validated, and the standard pipeline is easy to misread. NIST SP 800-22 runs fifteen tests — frequency, runs, longest run, discrete Fourier transform, approximate entropy, linear complexity and the rest — over sequences of 1,000,000 bits each, and a source is expected to produce p-values above 0.0001 for at least 960 of 1,000 sequences per test. At 1 Gbps that battery needs under a minute of captured data. TestU01's SmallCrush, Crush and BigCrush go further, and a production QRNG should clear BigCrush without per-device tuning.

Two caveats decide how much the result is worth:

  • Passing is not proof. A well-seeded pseudorandom generator passes every suite in the list, so statistical compliance shows only that no structure was detected at the tested sample sizes. Certifiable randomness requires either a device-independent Bell-test argument or a trusted-model analysis of the physical entropy source.
  • Quote min-entropy, not bias. Uniformity tests report how close the output is to balanced; key derivation needs a conservative lower bound on min-entropy. NIST SP 800-90B estimates it from the most likely output symbol with a statistical confidence correction, and that corrected bound — not the empirical bias — sets the extractor's input.

Extracting Bits From an Imperfect Source

Physical sources are biased and correlated, so the raw stream passes through an extractor before anything trusts it. A two-universal hash, typically a Toeplitz matrix applied modulo 2, maps a block of raw bits with proven min-entropy to a nearly uniform output of

bits, where is the statistical distance from perfect uniformity. Worked example: a vacuum-fluctuation source certifies bits per 128-bit block and the application needs ; then , so at most 60 bits per block are safe to release. Reaching for the other 68 bits does not gain throughput, it spends security margin that has not been proven to exist.

Simpler devices can be cleaned with a von Neumann extractor, which pairs raw bits and keeps the second bit of every unequal pair: (0,1) → 0 and (1,0) → 1. The output is bias-free, but throughput is not free: a source with bit probability keeps only of its bits, so a mildly biased 55/45 source retains 49.5% of the stream. The method also assumes independent samples, which is precisely what a correlated source violates — that is why the hash extractor, not von Neumann, is what ships in commercial devices.

python
import numpy as np

def von_neumann(raw):
    pairs = raw[: len(raw) // 2 * 2].reshape(-1, 2)
    unequal = pairs[:, 0] != pairs[:, 1]
    return pairs[unequal, 1]

def block_chi2(bits, k=8):
    usable = bits[: len(bits) // k * k].reshape(-1, k)
    observed = np.bincount(usable.sum(axis=0), minlength=k + 1)
    expected = len(usable) / (k + 1)
    return np.sum((observed - expected) ** 2 / expected)

rng = np.random.default_rng(0)
raw = rng.binomial(1, 0.55, 400_000)  # biased physical source
clean = von_neumann(raw)
print(f"raw bits: {len(raw)}, extracted: {len(clean)}, retention: {len(clean)/len(raw):.3f}")
print(f"raw bias: {raw.mean():.3f}, clean bias: {clean.mean():.3f}")
print(f"chi2 on 8-bit blocks: {block_chi2(clean):.2f} (critical value 15.51 at 5%)")
p_max = max(raw.mean(), 1 - raw.mean())
print(f"min-entropy per raw bit: {-np.log2(p_max):.3f}")

The retention figure in that run lands near 0.495, matching for , and the chi-square statistic on the cleaned stream stays under the 5% critical value because the extractor removed the bias without disturbing independence.

Summary

Quantum randomness differs from algorithmic randomness in one decisive respect: the output is unpredictable because of measurement, not because nobody has read the generating code. A single-qubit measurement in a superposition yields 1 min-entropy bit per shot; a Bell test with CHSH value certifies bits per round without trusting the hardware, which reaches 0.5 bits only at the Tsirelson bound . Commercial devices push raw rates into the Gbps range with vacuum fluctuations and photon arrival times, and randomness expansion protocols turn a small trusted seed into a longer certified stream. The engineering work lives in validation, min-entropy estimation and extraction — everything after the physics is careful bookkeeping about how many bits may safely leave the device.

Randomness Expansion Protocols

Randomness expansion from a small seed:

  1. Start with random bits (seed)
  2. Perform Bell test with measurements
  3. Generate certifiably random bits

The expansion rate depends on the CHSH violation:

where is the certifiability per measurement. At : bits, giving expansion factor for .

Expanding a seed therefore costs real Bell-test rounds. Producing one extra certified kilobyte from a 256-bit seed at 0.5 bits per round takes about 16,000 successful rounds, and every round that violates the inequality too weakly (or fails the detector loophole checks) contributes nothing. That overhead is why certified expansion remains a laboratory capability while trusted-model QRNGs, which only have to model their own optics, are the ones deployed in products.

Common Mistakes

Treating a stream that passes NIST SP 800-22 as certifiably random

Fix: Statistical suites detect structure, they do not establish provenance; certification needs a Bell-test argument or a trusted-model min-entropy bound for the source

Deriving keys at the raw bit rate of the device

Fix: Release no more than H_min minus 2 log2(1/epsilon) bits per block, using the SP 800-90B confidence correction rather than the empirical bias

Using von Neumann extraction on a correlated or time-multiplexed source

Fix: Pairs are only independent if the samples are; correlated sources need a hash extractor sized from a proven min-entropy bound

Reporting device-independent rates at the Tsirelson bound when the measured violation is much lower

Fix: Plug the measured CHSH value into log2((S+2)/4) per round; a violation of 2.4 certifies 0.26 bits, not 0.5

Key Takeaways

  • Measurement outcomes are unpredictable in a way no pseudorandom generator can match, because the guarantee comes from quantum mechanics rather than from unmodelled code
  • Device-independent protocols certify bits from the size of a CHSH violation: zero bits at S = 2, half a bit per round at the Tsirelson bound S = 2.83
  • Min-entropy per block, not raw uniformity, is what an extractor and a key derivation can safely consume
  • Commercial QRNGs reach Gbps rates from vacuum fluctuations and photon timing, while atomic decay sources trade rate for a cleaner model
  • Randomness expansion and extraction are the layers that turn a physical process into cryptographic material
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-15

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Quantum Computing Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement