Why Pseudorandom Isn't Random: The Math of Reversible, Finite-State Generative Art
I used to do everything with Math.random() and a seeded PRNG, the same way most generative art platforms do. Art Blocks, fxhash, most custom pipelines — they all start from a pseudorandom number generator. Whenever the question of "true" randomness came up, the answer was always the same: it passes statistical tests, it is random enough for art.
For aesthetics, that is true. For uniqueness, it is false — and that is the part that matters when you are promising someone a one-of-one. "Random enough" is a category error, and the math behind it is not complicated. Every PRNG is deterministic, every PRNG is reversible, and every PRNG has a finite state space. A quantum measurement breaks all three.

What a PRNG actually is
A pseudorandom generator is a deterministic function with internal state:
state_{n+1} = f(state_n)
output_n = g(state_n)
That is the whole machine. The generators you actually meet in generative art:
- xorshift / xoshiro — 64 to 256 bits of state, period 2^64 to 2^256.
- PCG — 64 to 128 bits of state, better statistical properties than raw xorshift.
- ChaCha20 / AES-CTR — 256-bit keys, cryptographic security.
- JavaScript
Math.random()— xorshift128+ in V8, 128 bits of state. Python'srandommodule uses Mersenne Twister with 19,937 bits.
The stock defense is that the output is computationally indistinguishable from random: no efficient algorithm can tell it apart without knowing the seed. True, and irrelevant here. Indistinguishable is a weaker property than actually random. Given the seed, the entire sequence is predetermined. There is no uncertainty in a PRNG, only the appearance of it.
The reversibility problem
Every PRNG is reversible, and the state spaces are smaller than they look:
- xorshift128+ — two consecutive 64-bit outputs reconstruct the full 128-bit state.
- Mersenne Twister — 624 consecutive 32-bit outputs reveal the state, after which every past and future value is computable.
- PCG — a handful of outputs, depending on the variant.
- ChaCha20 — computationally infeasible, but because of the 256-bit key, not because of any law of physics.
Once you have the state you can run the generator backward, recover every previous output, and often recover the seed itself — which in practice is frequently a timestamp plus a process ID, not 128 bits of entropy. This is not theoretical; reverse-engineering tools for xorshift and PCG exist and work. Take a few outputs from a seeded generative collection and you can often regenerate the entire series.
For most art that does not matter. For a piece whose entire claim is that it exists exactly once, it is the whole ballgame: if the process can be replicated, uniqueness rests on social agreement rather than on anything in the math.
State space versus output space
A PRNG's output space cannot exceed its state space. A 128-bit generator can produce at most 2^128 distinct sequences, no matter how long you run it; a 256-bit generator, at most 2^256. With a uniform random seed, the min-entropy of the output is bounded by the size of the state — and with a timestamp seed it is far lower than that.
Min-entropy is the right measure here because it is a worst-case bound:
H_inf(X) = -log2(max_x P[X = x])
It answers "how unpredictable is the most likely outcome", which is exactly the question you care about when reasoning about rare events and collisions. For a PRNG with an S-bit state seeded uniformly, H_inf ≤ S. For ChaCha20 with a 256-bit key, the bound is 256 bits — respectable, and still a bound set by the key, not by physics.
What a measured qubit gives you
Prepare a qubit in an equal superposition and measure it. The Born rule gives the probability of each outcome: for the state (|0⟩ + |1⟩)/√2, it is 50/50. The properties that matter:
- No hidden variables. Bell's theorem, and the experimental violations of Bell inequalities, rule out local hidden-variable explanations of the correlations.
- No algorithm. The outcome is not computed anywhere; it is a physical event.
- Irreproducible. Measurement collapses the state. Re-running the circuit produces a new distribution; the old one is gone.
- One bit per qubit per shot, at most. For a perfectly prepared |+⟩, the min-entropy is exactly one bit per measurement.
That last point deserves precision, because it is where most "quantum randomness" marketing goes wrong. A 12-qubit register measured in the computational basis has at most 12 bits of outcome entropy per shot — and only if all 4,096 outcomes were equally likely. The CNOT layer correlates qubits, which reduces the number of distinct outcomes. In our circuit, six independent Bell pairs means 64 equally likely bitstrings, so the per-shot bound is about six bits, not twelve.
Six bits per shot times thousands of shots is still a large amount of physical entropy to compress into a 256-bit seed. The honest statement is that the seed inherits entropy from a physical process with a per-shot bound set by the circuit and the hardware, not that it contains "49,152 bits" or that it is "larger than the number of atoms in the universe". Overclaiming is how this topic loses credibility.
Building the generator, from one qubit up
The simplest QRNG is one qubit and one gate:
from qiskit import QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0) # (|0> + |1>) / sqrt(2)
qc.measure(0, 0)
One shot gives one bit, 50/50, with no seed behind it. Eight qubits with a Hadamard on each give a full byte per shot: 256 equally likely outcomes, uniform by construction. That is a perfectly good QRNG and it is about ten lines of code.
For the collection we used a 12-qubit version with CNOT gates between pairs, which adds correlation to the output distribution:
def build_seed_circuit(num_qubits=12):
qc = QuantumCircuit(num_qubits, num_qubits)
for i in range(num_qubits):
qc.h(i)
for i in range(0, num_qubits - 1, 2):
qc.cx(i, i + 1)
qc.measure(range(num_qubits), range(num_qubits))
return qc
Running it on real hardware, with the bits that actually bite:
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
service = QiskitRuntimeService(channel="ibm_quantum_platform")
backend = service.least_busy(simulator=False, min_num_qubits=12)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa = pm.run(build_seed_circuit())
sampler = SamplerV2(mode=backend)
job = sampler.run([isa], shots=4096)
counts = job.result()[0].data.c.get_counts() # register is 'c', not 'meas'
Two version traps: the channel name changed from ibm_quantum to ibm_quantum_platform, and SamplerV2 reads the c classical register where SamplerV1 used meas. Code copied from older tutorials fails — sometimes loudly at authentication, sometimes silently with an empty result.
From counts to a seed
The raw output is a dictionary of bitstrings and counts. Hash the whole distribution, not a single shot, and serialize it deterministically:
import hashlib
def measurements_to_seed(counts, shots):
serialized = "".join(
f"{bitstring}:{count}"
for bitstring, count in sorted(counts.items())
)
domain = f"QGENESIS:v1:shots={shots}:{serialized}"
return hashlib.sha256(domain.encode()).hexdigest()
Sorting matters because dictionary order is not guaranteed across runs; without it, the same counts could produce a different seed. The domain string separates this use of SHA-256 from any other, so a seed can never be confused with a hash of something else.
The 256-bit output then initializes a deterministic generator — xorshift128+ expanded through SHA-512 — which drives every visual decision. That is the hybrid at the center of the project: the art is fully reproducible from the seed, and the seed could not have been predicted before the circuit ran.
What the statistics can and cannot tell you
"Trust me, it's quantum" is not a methodology. But the tests people cite are often weaker than they sound, so it is worth being precise about what they establish.
Chi-squared uniformity
import numpy as np
from scipy import stats
def chi_squared(counts, num_qubits, shots):
outcomes = 2 ** num_qubits
observed = np.zeros(outcomes)
for bitstring, count in counts.items():
observed[int(bitstring, 2)] = count
expected = shots / outcomes
chi2, p = stats.chisquare(observed, f_exp=[expected] * outcomes)
return chi2, p
With 4,096 shots over 4,096 possible outcomes, the expected count per bin is one. Chi-square assumes expected counts of roughly five or more per bin, so this test is statistically invalid as written — a trap that appears in a lot of QRNG tutorials. To use it meaningfully, aggregate outcomes into fewer bins (256 bins gives 16 expected counts each) before testing.
Shannon entropy
def shannon_entropy(counts):
total = sum(counts.values())
return -sum(
(c / total) * np.log2(c / total)
for c in counts.values() if c > 0
)
Entropy measures how spread the distribution is. It is useful for detecting gross bias, but it does not prove the source is quantum — a good PRNG passes it trivially.
Bit bias
Check each bit position across all shots. A fair qubit gives roughly 50/50; a miscalibrated one does not. This catches readout errors that entropy averages can hide.
None of these tests proves quantumness. What they prove is that the pipeline is not obviously broken. Demonstrating that the entropy is genuinely quantum requires a Bell test or a certified device — a much higher bar than a blog post, and one worth stating plainly instead of implying that a chi-square p-value settles it.
The honest caveat
For making something look nice, any competent PRNG is fine, and I would never claim otherwise. The difference shows up at the boundary where uniqueness is the promise. If the whole value proposition is that a piece exists exactly once, the entropy at the source is the thing worth auditing — and "it passes statistical tests" is not an audit, it is a description of the output.
That is the argument in one sentence: a PRNG can produce a stream you cannot practically distinguish from random, and a quantum measurement produces an outcome that was not determined before it happened. Those are different claims, and only one of them survives someone asking how the seed was made.
The circuit, the seed derivation and the RNG are documented in the architecture post, and the reason the collection ran on two hardware vendors is in the Origin vs IBM comparison.
Comments
Post a Comment