⚛️ Quantum Random Number Generator Clinical Trial Randomization
This simulation uses a quantum random number generator for the randomization of clinical trials.
True Randomness from Physics — How a QRNG Actually Generates a Bit
The defining claim of a quantum random number generator is not merely "hard to predict" but "physically undetermined until measured." Where a classical (pseudo-random) generator produces a fully deterministic sequence from a seed — reproducible by anyone who knows the seed and algorithm — a QRNG bit is, under the standard interpretation of quantum mechanics, genuinely indeterminate prior to measurement, giving it an information-theoretic (not merely computational) guarantee of unpredictability.
- 50/50 beamsplitter: Photon-path QRNG (single-photon detector path A/B)
- Homodyne detection: Vacuum-fluctuation QRNG (quadrature noise of vacuum state)
- Geiger-counter timing: Radioactive-decay QRNG (decay-interval parity bit)
- ID Quantique Quantis: Commercial vendor example (Geneva; photon-path QRNG, since 2001)
Three physical entropy sources used in production QRNGs
Photon-path (beamsplitter) QRNG: • A single photon is sent toward a 50/50 beamsplitter; quantum mechanics guarantees the photon's detection at output port A vs. port B is fundamentally probabilistic (not merely practically unpredictable) for an ideal single-photon source and detector • Detector click at A → bit 0; click at B → bit 1 • Commercialized by ID Quantique (Geneva, spin-out of University of Geneva physics group) since 2001 as the Quantis QRNG product line; also implemented by PicoQuant and several university physics labs • Practical bit rates: tens of Mbps for chip-scale integrated photonic implementations
Vacuum-fluctuation (homodyne) QRNG: • Rather than counting discrete photons, this approach performs homodyne detection on the quantum vacuum state itself — the electromagnetic field's zero-point fluctuations, which have a genuinely random Gaussian-distributed amplitude even in the complete absence of photons • A local oscillator laser beat against the vacuum field on a balanced photodetector yields a continuously fluctuating voltage that is digitized and processed into random bits • Notable implementation: the Australian National University (ANU) QRNG, a free public web-accessible generator continuously streaming vacuum-fluctuation-derived random numbers since 2010, widely cited in academic randomness research
Radioactive-decay timing QRNG: • Measures the time intervals between successive decay events of a radioactive source (e.g., a small Cs-137 or similar sample) detected by a Geiger-Müller tube; nuclear decay timing is governed by exponential-distribution quantum randomness (the same indeterminacy underlying half-life statistics) • Historically one of the earliest hardware RNG designs (HotBits, generated at Fourmilab since 1996); slower bit rates than photonic approaches but conceptually simple and independently verifiable
Why "physical unpredictability" matters specifically for clinical trials: • A classical PRNG's sequence is fully determined by its seed — if a study coordinator or an unblinded statistician's seed value is ever guessed, logged, or reused, the entire remaining allocation sequence becomes predictable, undermining allocation concealment • A QRNG has no seed to compromise: each bit is generated fresh from an ongoing physical process, so predicting bit N+1 from bits 1..N is not a computational problem to be solved — it is, under standard quantum mechanics, information that does not yet exist
From Noisy Quantum Measurements to Clean, Uniform Random Bits
No physical measurement apparatus is perfectly ideal: detector inefficiency, dark counts, dead time, and residual classical electronic noise all introduce small biases into the raw bit stream from any of the three sources in Stage 1. Before random bits can be trusted for allocation, they must be rigorously characterized for worst-case unpredictability and then compressed through a randomness extractor into a shorter, statistically uniform output.
- NIST SP 800-90B: Min-entropy estimation standard (entropy source validation)
- Toeplitz-matrix hashing: Standard extractor (linear, provably universal hashing)
- ~2:1 to 10:1: Typical raw→output compression (depends on measured min-entropy)
- >0.997 bits/bit: Target output min-entropy (near-ideal uniformity after extraction)
Min-entropy estimation and randomness extraction pipeline
Why raw quantum bits are not immediately usable: • Detector asymmetry (port A and port B of a beamsplitter rarely have exactly equal click probability due to manufacturing tolerance) introduces a small, systematic bias — e.g., P(0)=0.503, P(1)=0.497 rather than the ideal 0.5/0.5 • Dead time and afterpulsing in single-photon detectors introduce short-range correlations between successive bits • Classical electronic noise (amplifier noise, ADC quantization) mixes with the genuine quantum signal in vacuum-fluctuation designs, meaning not all measured entropy is provably quantum in origin
Min-entropy estimation (NIST SP 800-90B): • Min-entropy H_∞ = -log2(max probability of any single output value) is the conservative, worst-case measure of unpredictability used in cryptographic and high-assurance randomness standards — far stricter than Shannon entropy, which can overstate usable randomness when a stream has a few highly likely outcomes • SP 800-90B prescribes a battery of estimators (most common value, collision, Markov, compression-based estimators) run on a raw noise sample; the reported min-entropy is the MINIMUM across all estimators, providing a defensible lower bound even under adversarial assumptions about the source • A validated QRNG entropy source typically reports min-entropy in the 0.90–0.997 bits per raw bit range, depending on source type and conditioning
Randomness extraction (Toeplitz hashing): • A Toeplitz matrix-based extractor multiplies a block of raw bits by a random (but fixed, publicly known) Toeplitz matrix over GF(2), producing a shorter output block • This construction is a proven "strong extractor": provided the input min-entropy exceeds a calculable threshold, the output is statistically indistinguishable from a uniform random string, even if an adversary knows the extractor matrix • Output length is chosen conservatively below the estimated min-entropy of the input block (leftover hash lemma), trading raw bit-rate for provable near-perfect uniformity — a typical compression ratio is 2:1 to 10:1 depending on source quality
This conditioning step is what separates a "physics demo" from a certifiable clinical-grade random number generator: the entropy source provides the physical unpredictability, but the extractor provides the mathematically provable uniformity guarantee that downstream statistical tests (Stage 3) and regulators expect.
The NIST SP 800-22 Test Suite — Proving the Bits Look and Behave Random
Entropy estimation characterizes the SOURCE; statistical testing characterizes the OUTPUT stream actually delivered to the randomization system. The NIST Statistical Test Suite (SP 800-22, "A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications") is the de facto standard battery used to detect any residual structure, bias, or predictability before a bitstream is approved for use — applied identically whether the source is quantum-physical or a classical PRNG, allowing direct, apples-to-apples comparison.
- 15 tests: NIST SP 800-22 test count (frequency, runs, spectral, entropy, etc.)
- p-value ≥ 0.01: Pass threshold (per test) (standard significance level)
- ≥10^6 bits: Minimum sample size (per NIST recommendation for most tests)
- Mersenne Twister (MT19937): Comparator PRNG (common classical baseline)
What the 15 NIST tests check, and why QRNG vs. PRNG comparison matters
Representative tests within the NIST SP 800-22 suite:
• Frequency (Monobit) Test: checks that the proportion of 0s and 1s in the sequence is close to 1/2 • Frequency Test within a Block: checks local balance of 0s/1s within M-bit sub-blocks, catching biases that a global count would average out • Runs Test: checks that the number of uninterrupted sequences ("runs") of identical bits matches what pure randomness predicts — too few or too many runs both indicate structure • Discrete Fourier Transform (Spectral) Test: detects periodic patterns by checking for excessive peak heights in the bitstream's frequency spectrum • Approximate Entropy Test: compares the frequency of overlapping m-bit and (m+1)-bit patterns to detect irregularity deficits • Cumulative Sums (Cusum) Test: treats bits as +1/-1 steps of a random walk and checks the walk does not deviate from zero more than randomness predicts • Additional tests: Block Frequency, Non-overlapping/Overlapping Template Matching, Rank, Universal (Maurer's), Random Excursions, Random Excursions Variant, Serial, Linear Complexity — 15 total, each producing a p-value
Interpreting results: • Each test's null hypothesis is "the sequence is random"; a p-value below 0.01 (a common threshold) rejects randomness for that specific test at that specific sample • A single failed test on one sample is not necessarily disqualifying — NIST guidance recommends running the suite across multiple independent samples and checking that the PROPORTION of passing samples and the p-value DISTRIBUTION itself look uniform, since ~1% of samples are expected to fail any individual test purely by chance even for a perfect source • Complementary suites — Dieharder (an extended, more stringent battery) and TestU01's "BigCrush" (the most demanding widely-used suite, capable of detecting the subtle linear structure in some classical PRNGs) — are often run alongside NIST SP 800-22 for extra assurance
QRNG vs. Mersenne Twister (MT19937), the ubiquitous classical PRNG baseline: • MT19937, used by default in Python, R, and many statistical packages, passes NIST SP 800-22 and even Dieharard comfortably — its OUTPUT is statistically excellent • Its weakness is not statistical but structural: observing 624 consecutive 32-bit outputs allows full reconstruction of its internal state, after which every future output is exactly predictable — a property statistical tests alone cannot detect, since it concerns predictability given INTERNAL knowledge of the generator, not statistical properties of the output stream in isolation • This is precisely the property that matters for allocation concealment: a QRNG has no analogous internal state to reconstruct, because each bit derives from an independent physical measurement rather than a deterministic state-transition function
Turning Validated Random Bits into a Clinical Trial Allocation Sequence
Statistically clean random bits are a raw material, not a finished randomization scheme. Clinical trials require structured randomization — permuted-block designs to maintain approximate treatment balance throughout enrollment, and stratification by prognostic factors (site, age, biomarker status) to prevent chance imbalances from confounding the treatment comparison — all seeded, but not fully determined, by the underlying random bitstream.
- Permuted block: Design (random + varying block sizes)
- 2, 4, 6, 8: Common block sizes (randomly varied to prevent prediction)
- Site, age, biomarker: Typical strata (ensures balance within subgroups)
- ICH E9(R1) 2019: Guiding standard (statistical principles for clinical trials)
Permuted-block randomization mechanics and stratification
Simple randomization (coin-flip equivalent) risks severe imbalance: • Flipping a fair coin for each of 20 patients has a non-trivial probability of landing e.g. 13-to-7 rather than 10-to-10 — problematic in smaller trials or with interim analyses where imbalance itself can bias early conclusions
Permuted-block randomization solves this: • Patients are randomized in blocks of a fixed size (e.g., block size 4 for a 1:1 two-arm trial produces exactly 6 possible orderings of 2 A's and 2 B's: AABB, ABAB, ABBA, BAAB, BABA, BBAA) • The validated random bitstream selects which of the possible block permutations to use next; the block is then a fixed queue of upcoming assignments • Guarantees that after every complete block, the treatment groups are perfectly balanced — bounding the maximum possible imbalance at any point in enrollment to roughly half a block
Random (varying) block sizes — the key concealment safeguard: • If every block has a FIXED, publicly known size (say, always 4), an unblinded or observant investigator can deduce the final assignment in each block after seeing the first 3 — e.g., after AAB, the 4th must be B • Varying block sizes randomly (e.g., randomly choosing among 2, 4, 6, 8 for each successive block, itself decided from the random bitstream) removes this predictability, a design feature explicitly recommended in ICH E9 guidance and FDA/EMA statistical review practice
Stratified randomization: • Within each combination of stratification factors (e.g., "Site 3, age ≥65, biomarker-positive"), an independent permuted-block sequence is run • Prevents a plausible-but-damaging scenario: pure unstratified randomization producing, by chance, most biomarker-positive patients in the control arm — which would confound the treatment effect with a known prognostic factor • Practical limit: too many strata relative to sample size creates many small, incompletely filled blocks ("stratified randomization curse of dimensionality") — trial statisticians typically limit to 2–4 stratification factors
ICH E9(R1) (2019) explicitly frames randomization and blinding as central to valid causal inference in the estimand framework, requiring that the randomization method be pre-specified in the statistical analysis plan and that allocation concealment be maintained until the moment of enrollment.
IWRS Delivery, Allocation Concealment, and the Regulatory Case for QRNG
The final step connects the validated, pre-generated random sequence to actual trial operations through an Interactive Web Response System (IWRS) or Interactive Voice Response System (IVRS): the coordinator enrolling a patient requests "next allocation," and the system reveals — but never allows prediction of — the next assignment from the pre-validated sequence, with every event permanently and immutably logged for regulatory audit.
- IWRS / IVRS: Delivery system (web/voice randomization interface)
- Reveal-on-enrollment only: Concealment principle (never pre-computed or visible in advance)
- ICH E9 / E9(R1): Governing guidance (statistical principles for clinical trials)
- Full traceability: Audit requirement (FDA 21 CFR Part 11 electronic records)
From validated sequence to enrolled patient, and why regulators care about the entropy source
Operational flow at the site: 1. The pre-generated, NIST-validated, block/stratified random allocation sequence is loaded into the trial's IWRS/IVRS before the trial opens, typically managed by an independent, unblinded statistician or a third-party randomization vendor — never visible to site investigators 2. A coordinator enrolling an eligible, consented patient logs into the IWRS, enters the patient's stratification data (site, relevant covariates), and requests the next allocation 3. The system looks up the next unused entry in that stratum's pre-generated sequence and reveals only that single assignment — the coordinator cannot see upcoming assignments, past unused ones, or the generation method itself 4. Every request, timestamp, user, and resulting allocation is written to an immutable audit log meeting FDA 21 CFR Part 11 electronic-records requirements (attributable, legible, contemporaneous, original, accurate)
Why regulators and sponsors are increasingly interested in QRNG specifically: • ICH E9 statistical principles require that randomization "should generate a randomization schedule for allocating trial subjects to treatment groups... to minimize bias" and explicitly flag PREDICTABILITY of the allocation sequence as a source of selection bias if investigators can anticipate assignments • A classical PRNG's seed, if it were ever exposed (misconfigured logging, insider threat, software vulnerability), would compromise the ENTIRE remaining allocation sequence retroactively-provably; a QRNG has no analogous single point of compromise, since each bit is an independent physical measurement rather than a function of a reproducible internal state • This distinction matters most for trials with especially high stakes around allocation integrity — oncology trials with strong prognostic covariates, trials in regions with documented history of randomization fraud, and any trial where unblinding a single seed would have outsized financial or scientific consequences
Vendor and research landscape: • ID Quantique (Geneva) markets Quantis QRNG hardware explicitly for regulated/high-assurance applications including clinical and financial randomization • Several academic medical statistics groups have published proof-of-concept integrations of ANU-style vacuum-fluctuation QRNG feeds into IWRS randomization modules, though as of the mid-2020s the overwhelming majority of live trials still use certified classical PRNGs (typically Mersenne Twister or cryptographic PRNGs like AES-CTR-DRBG) — QRNG adoption in trial randomization remains an emerging, not yet mainstream, practice, motivated more by defense-in-depth and audit-narrative strength than by any documented case of a classical PRNG actually being compromised in a real trial
No published clinical trial to date has been shown to have had its Mersenne-Twister-based randomization sequence actually predicted or exploited — the case for QRNG in trial randomization today rests on eliminating a theoretical attack surface and strengthening the audit narrative for allocation integrity, rather than remediating a documented historical failure.
This simulation uses a quantum random number generator for the randomization of clinical trials.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install