
Ask a computer to pick a random number, and it will do it instantly. But here is a surprise: ordinary computers cannot be truly random. They are machines that follow exact instructions, so every “random” number they produce comes from a calculation.
That raises a good question. If a computer only follows rules, where could real chance come from? One answer comes from quantum physics. This guide explains how the two kinds of randomness differ, how quantum random number generators work, and where each kind makes sense.
How a Normal Computer Fakes Randomness
A classical computer uses a pseudo-random number generator, or PRNG. It starts from a number called a seed and applies a formula over and over. The output looks random, but it is completely determined by the seed.
Here is a toy version so you can see the idea. It uses a simple rule: multiply by 5, add 3, and keep the remainder after dividing by 16.
def lcg(seed, n):
x = seed
out = []
for _ in range(n):
x = (5 * x + 3) % 16
out.append(x)
return out
print(lcg(7, 8))
print(lcg(7, 16)[-1])
Output:
[6, 1, 8, 11, 10, 5, 12, 15]
7
Two things stand out:
- Same seed, same sequence. Run it again with seed 7 and you get exactly the same numbers. Nothing is left to chance.
- It repeats. After 16 steps, the sequence is back at 7 and the cycle starts over. This is called the period.
Real generators use much larger numbers and far better formulas, so their periods are astronomically long. But the basic fact never changes: a PRNG is a rule, not a roll of the dice.
Why Pseudo-Random Is Usually Good Enough
This is not a flaw for most jobs. Many everyday tasks work well with high-quality PRNGs:
- Simulations and scientific modeling
- Shuffling items in software
- Video game effects and testing
Security needs more care. A cryptographically secure generator is built so that no one can predict its next output even after seeing many earlier ones, as long as its seed is unpredictable. Operating systems collect unpredictable events, such as timing from hardware, to create that seed, a source known as entropy. In the US, NIST publishes a series of standards on how to build and test such generators.
The weak point is the seed. If an attacker can guess or reproduce it, the strongest formula in the world is useless.
Where Quantum Physics Comes In
In quantum mechanics, some outcomes are not just hard to predict. According to the standard theory, they are not determined beforehand at all. This gives a possible source of genuine, physical randomness.
To see how, we need two basic ideas. A qubit (quantum bit) is a quantum system with two basic outcomes, 0 and 1, described by amplitudes that set the probability of each. A measurement forces it to give a single answer.
The simplest quantum random bit
Here is the recipe, shown in the language of a quantum circuits tutorial:
- Start a qubit in the state |0⟩.
- Apply a Hadamard gate. Quantum gates explained briefly: a gate is an operation that changes a qubit’s state. The Hadamard gate turns |0⟩ into an equal mix, where the amplitudes give a 50% chance each for 0 and 1.
- Measure the qubit. You get 0 or 1, with equal odds, and the quantum theory says no hidden rule decides which.
An important warning: if you run this circuit on a classical simulator, the results are not truly random. The simulator uses a pseudo-random generator to imitate the measurement. Real quantum randomness only appears when the circuit runs on physical quantum hardware, or when a dedicated device measures a real quantum process.
How Real Quantum Random Number Generators Work
You do not need a full quantum computer to make quantum random numbers. Simpler devices use quantum effects directly. Common ideas include:
- Photon-based devices. A single particle of light hits a half-silvered mirror and goes one way or the other. Detectors record which path it took.
- Photon arrival timing. Detectors measure random gaps between photon arrivals.
- Vacuum or light-noise measurements. Devices measure tiny fluctuations that have quantum origins.
Raw output from any physical device is never perfect. Detectors have biases, and electronics add classical noise. So manufacturers add post-processing, such as mathematical cleaning methods called randomness extractors, and then run statistical tests.
Pseudo-Random vs Quantum Random: A Direct Comparison
| Feature | Pseudo-random generator | Quantum random generator |
|---|---|---|
| Source of randomness | A formula plus a seed | A quantum physical process |
| Predictable if seed is known? | Yes | No, in principle |
| Reproducible? | Yes, which helps in testing | No, which is often the point |
| Speed and cost | Very fast, very cheap | Usually slower and costlier, with special hardware |
| Typical use | Most software, simulations | High-security systems, research |
| Key risk | Weak or guessable seed | Hardware flaws, bias, poor design |
Reproducibility deserves a second look. Scientists often want repeatable results, so they choose PRNGs on purpose. True randomness is not “better” in every situation. It is better where unpredictability matters.
Can We Prove a Number Is Truly Random?
Here is a subtle point. No finite set of statistical tests can prove that a stream of numbers is truly random. Tests can only catch some kinds of patterns. A good PRNG passes them, and a flawed quantum device might fail.
Physicists have a stronger idea called device-independent or certified randomness. It uses entanglement and experiments called Bell tests, work recognized by the 2022 Nobel Prize in Physics. If the results violate a certain inequality, the device must be producing randomness that no classical hidden rule could have predicted. Researchers have demonstrated such certification in laboratory experiments, but it remains specialized and is not part of everyday products.
Also keep in mind that entanglement here is a tool for checking randomness, not a way of sending messages.
What About Real-World Applications of Quantum Computing?
Quantum random number generators are among the simpler quantum technologies, since they do not need large, error-corrected quantum computers. Some are already sold as commercial devices.
This is quite different from the big promises sometimes made about the field. When comparing quantum computing vs classical computing, remember that a quantum random generator is a specialized sensor-like device. It is not a faster processor.
For real-world applications of quantum computing more broadly, many ideas, such as large-scale simulation or factoring, still wait on hardware that does not yet exist. Randomness generation is one of the few practical uses available today.
A Note on Security and the Future
Randomness is the foundation of encryption keys. If keys are predictable, even the best algorithm fails. That is why unpredictable seeds matter so much.
Quantum computers also threaten some current public-key methods, which is a separate issue. Post-quantum cryptography explained in one line: it is a family of new methods that run on ordinary computers and are designed to resist both classical and quantum attacks. These new methods also need good randomness to generate their keys, so the two topics connect.
Common Misunderstandings
- “Computers can generate perfect randomness with software alone.” They generate pseudo-randomness, which is often sufficient but is not truly unpredictable.
- “Quantum random always beats pseudo-random.” Not for every job. Testing and reproducibility often favor PRNGs.
- “A quantum simulator gives true randomness.” It does not. It imitates it.
- “Quantum means unhackable.” A badly built or poorly tested device can still be biased or attacked.
Frequently Asked Questions
Is quantum randomness really random?
According to standard quantum theory, yes, since individual measurement outcomes are not determined in advance. Some interpretations of quantum mechanics discuss deeper explanations, but no experiment has shown that the outcomes can be predicted.
Why not use a quantum generator everywhere?
Cost, speed, and complexity. For most software, a well-designed cryptographic generator seeded from good entropy is secure and practical.
What is entropy in this context?
It is a measure of unpredictability. High-entropy data cannot be guessed easily, and it is the raw material used to seed generators.
Does a random sequence have no patterns at all?
Truly random sequences can contain short streaks and apparent patterns by chance. Seeing a pattern does not by itself show non-randomness, and its absence does not prove randomness either.
Can I build a quantum random generator at home?
Simple hobby projects exist, but building one with reliable, unbiased output takes careful engineering and testing. A cloud-based quantum computer may also be used, though noise and bias must be handled.
How is this connected to learning quantum computing?
It is a great first project. The Hadamard-and-measure circuit above teaches superposition, measurement, and probability in just three lines, which is a gentle start for quantum computing for beginners.
Do quantum random generators need quantum computers?
No. Most use simple optical or electronic devices that exploit quantum effects directly.
Conclusion
Randomness sounds simple, but it hides deep ideas. Ordinary computers produce pseudo-random numbers from formulas, and that works well for most tasks. Quantum devices offer a different source, rooted in physical measurement, which matters where unpredictability is critical.
Neither type is magic. Good design, careful testing, and the right match to the job count more than the label. If you want to explore this hands-on, build the three-line Hadamard circuit, keep in mind that a simulator only imitates chance, and then compare it with what physical hardware can provide.