---
title: 'The World Depends on Random Numbers That Aren''t Really Random'
source: 'https://youtube.com/watch?v=uXuQF_PPg5U'
video_id: 'uXuQF_PPg5U'
date: 2026-11-18
duration_sec: 2328
channel: 'Veritasium'
---

# The World Depends on Random Numbers That Aren't Really Random

> Source: [The World Depends on Random Numbers That Aren't Really Random](https://youtube.com/watch?v=uXuQF_PPg5U)

## Summary

This video explores the concept of randomness, tracing its history from early Monte Carlo simulations to modern quantum-based random number generation. It reveals how pseudorandom numbers, which are not truly random, underpin everything from Minecraft's resource placement to casino slot machines, and how their predictability can be exploited. The video concludes with a look at how quantum mechanics provides a source of certified randomness, essential for securing digital communications.

### Key Points

- **Casino Exploit** [00:00] — Gamblers were winning thousands of dollars by exploiting slot machines, seemingly knowing when to press the spin button to win. Investigators found they were using knowledge of the random number generator.
- **Monte Carlo Method Origin** [01:54] — Stanislaw Ulam, while recovering from encephalitis, played solitaire and wondered about the probability of winning. He realized he could simulate the game by playing it many times and observing outcomes, leading to the Monte Carlo method for simulating neutron chain reactions.
- **ENIAC and Pseudorandom Numbers** [05:21] — John von Neumann used the ENIAC computer to run the first Monte Carlo simulations. To generate random numbers, he devised the middle-square method, which squares a seed and takes the middle digits. This method was flawed, as sequences often got stuck in short loops.
- **Monte Carlo Named** [09:08] — The method was named after Monte Carlo, Monaco, due to its association with gambling. Von Neumann wrote to Ulam, 'The results are very promising and the method is clearly a 100% success.'
- **Linear Congruential Generators (LCGs)** [13:32] — LCGs use a linear rule with modular arithmetic to generate sequences. They can produce long sequences but have a fundamental flaw: outputs lie on parallel hyperplanes, making them predictable. IBM's RANDU was a notorious example.
- **Minecraft Exploit** [15:41] — Minecraft used Java's LCG to place resources. By analyzing the algorithm, players could predict diamond locations based on clay patches, leading to a trick that was later patched.
- **Modern Casino Hack** [20:04] — A hacker named Alex reverse-engineered slot machine RNGs, which used LCGs. By analyzing video feeds of spins, his team could predict winning spins and exploit casinos, taking over $250,000 in a week.
- **Cryptographically Secure RNGs** [23:27] — For security, we need unpredictable numbers. Cryptographically secure pseudorandom number generators (CSPRNGs) use a secret key and are designed so that knowing the algorithm and outputs doesn't allow prediction of future outputs.
- **Quantum Randomness** [25:58] — To generate truly unpredictable seeds, computers turn to physical sources. NIST uses quantum entanglement to generate certified randomness, where measurement outcomes are fundamentally unpredictable.
- **Bell Test Certification** [30:22] — NIST's quantum random number generator uses a Bell test to certify that the outputs are truly random. The experiment involves entangled photons and measurement choices made by quasars billions of light-years away, closing the freedom-of-choice loophole.
- **Randomness Extraction** [34:50] — Raw quantum measurements may be biased. NIST uses a technique similar to the von Neumann extractor to distill perfectly fair random bits from the raw data, certifying at least 820 bits of entropy.

### Conclusion

True randomness is a fundamental resource for security and simulation. While pseudorandom numbers are sufficient for many applications, quantum mechanics offers a way to generate certified randomness that is essential for protecting our digital world.

## Transcript

a man holds his phone up to a slot machine He played a few rounds. He won some, lost some, and then he got up and walked away.
but now he was winning on spin after spin. of the casino roughly $10,000 richer.
and California saw the same thing. and then leave, and minutes later, they would return Investigators were brought in,
they all seemed to be working fine. and they noticed something strange. they didn't play like normal gamblers.
They'd hover their hand over the spin button, wait, as if they knew when to press to win. Perhaps there's some way to predict what was coming next
by a computer inside the machine. but the casino provides an ideal venue because theoretically, that computer uses a
So are those numbers actually random? to connect finding diamonds in Minecraft to the development of the entire digital world.
of creating true randomness. that chance plays a surprisingly important role in
It works something like this. Take a core of uranium-235. When a neutron hits a U-235 nucleus, it can cause the nucleus
or three more neutrons. Now, if on average each split triggers more than one more split, you get a runaway chain reaction.
those neutrons take. or does it bounce off or get absorbed By 1945,
of each of these events happening, speed and what it was passing through. and trillions of neutrons,
to calculate one by one. was Stanisław Ulam. But then one morning in January 1946, Ulam woke up
It was encephalitis Luckily he survived, but his recovery was slow. So he spent weeks in a hospital playing a lot of solitaire
of winning a game? but a deck of 52 cards can be shuffled in 52 factorial ways,
of 67 different arrangements. Now, Ulam spent a lot of time trying to work out the answer But then he had a much simpler idea.
to lay it out, say, 100 times and simply observe That would give him some sort So say you win eight games out of a hundred,
of winning are probably around 8%. idea, but for neutrons. he could just start with a hundred neutrons
So say a neutron hits an atom. or a three, it bounces off the nucleus. If I roll a four or a five, it causes the nucleus to split.
And then I just follow what happens to that neutron that it produces using more random numbers In the real simulations, the scientists used probabilities
corresponded to which outcomes. or direction could also change. for its new situation.
and then they kept following what happened. how all those interactions added up. the chain reaction takes off.
But if more are lost than are produced, it fizzles out. So by simulating just a tiny fraction of the possible paths reaction would behave.
by hand seemed impossible. and Los Alamos advisor, John von Neumann, had been working computers, the ENIAC.
how it could follow 100 neutrons of collisions in just five hours. what would happen to a neutron.
they used books of random digits like this one. And the ENIAC didn't have nearly enough memory So von Neumann came up with a surprisingly simple way
for the ENIAC to generate its own random numbers. So the way we're going to do this is I'm actually going So let's try with 2,137.
and 2,137 squared is 4,566,769. but to do that first, I have to add a zero to the front
I won't use the digits at the edges So the last two digits only depend on the end of the seed because 37 squared ends in 1,369.
So anything ending in 37 squares to something ending in 69. Also, every seed in the 2,100s is going to square So they all start with a zero
But the middle digits get a contribution from So 5,667 is going to be the next number in the sequence. 32,114,889.
end, and you can just keep going. but watch what happens if I keep going.
after 43 steps, I get 4,100, then 8,100, and then 6,100, and then 2,100, and then 4,100 again.
From here on, the generator will produce these same four and nearly two-thirds of all four-digit seeds end up in this exact loop.
and once they do, every number that follows is also zero. Almost one in five starting values end up here. value, every single sequence eventually gets stuck in one
Now, von Neumann knew So for the first ENIAC simulation, so they produced much longer sequences before they looped.
for randomness by hand, they programmed the ENIAC to restart from the original seed And in the spring of 1948,
the ENIAC finally ran the first computerized simulations Von Neumann wrote to Ulam, "The results are very promising and the method is clearly a 100% success."
after Monte Carlo, Monaco, Today, it's one of the most important tools in statistics Now, this sequence of numbers isn't truly random.
you get exactly the same sequence every time. but that didn't actually stop them from being useful. so did this demand for pseudorandom numbers.
who considers arithmetical methods of producing random digits is of course in a state of sin. with three major challenges.
One, sequences could get stuck in these short loops. Two, even sequences that looked random could hide patterns. they could work out every number that followed.
They were predictable. So you, you got to show me - This is Matthew Bolan, Minecraft expert University of Toronto.
Minecraft before, diamonds are a big deal. - We're going to change that today. - Every Minecraft world is made up of chunks.
and 16 blocks in the Z direction. And in our version, each chunk originates at most a single that is hidden somewhere below the surface.
- So we are looking for either a clay patch What you do is you pull up your F3 screen,
you locate which direction is positive Z. - Yeah. - And what you do for clay, you add three.
and we go one, two, three in the positive Z. And now, if we dig down here, unless it got blocked by bedrock or something,
where it couldn't spawn in, there will be a diamond ore - Let's give it a shot. - All right. - Oh, no way. - Did you get anything?
- I did. I got eight. - You got eight. Let's go. - Okay. the game uses an algorithm
where resources like clay and diamonds appear. So I'm going to take a wheel with seven positions. It has numbers going from zero through to six.
and then multiply by some number. So one times three gives us three, Now, we multiply three by three again and we get nine,
so we're going to have to wrap around. and that gives us a remainder of two. This kind of wrapping
And now we keep going. So two times three is six, And then six times three is 18. So we get to four. Four times three is 12.
Five times three is 15. So what we've done is we've gone through every number except The formula for this kind of algorithm looks like this.
between the current number and the next, after dividing by m. the values wrap around falling along
So it is a linear rule using modular arithmetic, of pseudorandom number generators got the name linear
congruential generators, better known as LCGs. LCGs can produce enormously long sequences In the 1960s, IBM developed one called RANDU.
and used in simulations of everything from radioactive decay to instruments aboard NASA's Skylab Space Station. before repeating, so at least
But a long sequence doesn't necessarily mean a good one. consecutive numbers and we plot them If the numbers behaved independently, we'd expect the points
And from this angle, they certainly seem to, but if you rotate the cube in just the right way, you can see that they actually line up in these 15
where RANDU will never place a point, of all LCGs because of that linear relationship. and the third from the second using exactly the same rule.
So all three numbers are linked by a linear equation. a linear equation describes a plane, and the mod step creates a series of parallel planes.
that pattern especially obvious, In the 1990s, Java adopted one and a much larger modulus.
Its sequence takes over 281 trillion steps before repeating. and what we get is this. because they're so closely packed together
that the points more or less look like a random cloud. So that is problem two dealt with. - Occupational hazard.
So for most of the game's history, it used Java's LCG to determine the placement of resources in a given chunk. it didn't use completely independent starting numbers.
and added a different fixed number for each resource. those starting numbers differed by just three. before using them, so the difference wasn't always three
of a few predictable values. to choose their position were related. the shared unknown part cancels out.
The location of the clay patch was enough Matthew has a great video on his channel that works through description if you want to go check it out.
The outputs themselves can reveal enough information See, Java's LCG keeps track of an internal number and this is what Java's LCG uses
But when it generates an integer output, of those digits leaving just 16 hidden. And since it's binary, each can only be a zero or a one.
So that's just 65,536 possible values. but a computer can test them against the very next output And then you know the full 48 bit internal number,
every number that follows. They can produce incredibly long sequences but their simple mathematical structure still
- Like LCGs, they're, they're not good. They're very exploitable. They're for when you're, and dirty and you're not too worried about people like me.
work on the most recent versions of Minecraft. - Once I published this trick, it got patched out - Oh, no way. - I think a bug report was made
What they did is they actually switched the random number to a different random number generator - They changed the whole,
- Yeah, exactly. You can do the honours. - Okay, okay, okay. Let's see if I can remember. - Oh - Boy. Okay, check this out. Here you go.
Pants, boots, chest piece, helmet. to put this particular random number generator into the
when you're building software. Hostinger is an all-in-one platform for building, running, or an online store, you can manage it all from one place,
So for example, let's say I want diamonds that I just mined. and Hostinger's AI is going to build an initial version.
And if I want to change something, I can just describe it, because I can also add my own custom code. I can just spend more time mining diamonds.
and if you go to hostinger.com/veritasium, I want to thank Hostinger for sponsoring this part where gamblers were exploiting random number generators
to win thousands of dollars. of the gamblers who had been repeatedly winning on slot
- So when they picked these guys up in California, and they were able to see that the video was actually being - More specifically, a team in St.
Petersburg, led by a hacker only known as Alex. of its gambling and thousands So Alex got hold of some of these machines
- There's a processing board, which is a slot machine interface board. the processing board is locked into the game.
That comes with the machine. So if you can... it's just a matter of time before you're... using an LCG like Java.
- A lot of them were using the same - This algorithm still starts with a seed, it fills a table of 624 numbers.
combining the binary digits from different parts of the table to produce 624 new numbers. through another series of calculations,
and it produces its first pseudo-random output. and the next until it has produced 624 outputs. and the process continues, and its sequence is huge.
6,000 digits. But despite all that, every step still followed these fixed that Alex was actually able to work out
So when his team received videos of spins from casinos in the US, they could work backwards and predict when a winning spin was most likely.
the random number generator kept running even when nobody at the instant the player pressed spin. So the gamblers had to press at exactly the right time,
So Alex built that delay into the system. quarter of a second before they actually needed to press, and...
but a four-person team could reportedly take more than $250,000 in a week, so it was pretty effective. of the scheme were charged with conspiracy to commit fraud.
while one chose to cooperate with the FBI. exploit in casinos still? - Yeah, I would be completely surprised if they weren't.
There's a lot of those boxes are still out there. of these generators fail at being unpredictable if you know and if you can study enough of their outputs.
They're used to protect everything from our messages to our bank accounts, and if those numbers can be predicted, then that security can be compromised.
and Technology in Boulder, Colorado. NIST sets the standards for secure random number generation, - So what we're trying to do is say,
that nature allows you to build? - And that's what, that's what this is about. to make the world's best random number generator, really try
and science to try to develop the best And then we use those measurements to develop standards. for generating random numbers for digital security,
the ones we've seen so far. different kind of generator. Start with a string of numbers, say just one, two, three,
of those numbers into an encryption algorithm. which is based on a large random number. that without the key, the outputs look completely unrelated.
It's the one random number you need to start, and it decides every number that comes out. of its hidden state, and with the Mersenne Twister ,
Here, even if you know exactly how the encryption works, and outputs, there's no practical way And guessing it isn't realistic either.
A common key length is 128 bits, so that's 128 trillion possible keys. output, it's practically impossible.
cryptographically secure pseudo-random number generator, But where did that secret key actually come from? nothing on its own, it actually needs
And for that, computers turn to the physical world. random number generators to provide those unpredictable seeds.
even uses a whole wall of lava lamps to generate random seeds for its algorithms. So does that mean the problem is solved? Not exactly.
as a random event, heads or tails. you can actually make the coin land heads every single time,
of classical mechanics. and how it's flipped, you can predict The French mathematician, Pierre-Simon Laplace,
He imagined an intelligence that knew the position So according to classical mechanics, - You know, I looked long and hard to try to figure out
definition of randomness is just something that nobody could have predicted in advance. but like anything in the universe.
not just to generate numbers that seem random, - We don't want to do seeds at all, because some quantum measurement outcomes are
- So on this setup right here we start with a very bright of these pulses per second,
and interacts with this crystal here. with this crystal sometimes one of our
and fission into what we call a pair of daughter photons. - Now, each photon has a property called polarization, electric field oscillates.
that the pair can be produced or both vertically, but there's no way to distinguish which. of both possibilities.
- This is very much like a Schrödinger cat type state, and now it's like they're kind of both - The photons share a quantum state no matter
In other words, they are entangled. the results are correlated. to two separate measurement stations,
to get each photon into an optical fiber. - The really hard part is these fiber cables right here, It's only about 10 microns in diameter.
that's about one-tenth the diameter So it's a very, very tiny target. to call quantum archery.
and the fact that, you know, you could kind of pull back Yeah. And then it can keep shooting arrows We're doing a version of that
where now Robin Hood has two targets and he has a single bow and yet he's able to continually keep - Into these 10 micron holes. - Into these 10 micron holes.
- The photons then arrive at two measurement stations This means that even a signal traveling at the speed to impact the measurement.
the researchers measure the photon's polarization, angles to measure it at. before the photon arrives.
and there that gives you that ultimate final random number? A detection gives us a one. No detection gives us a zero.
to choose the measurements in an experiment that is designed It doesn't make sense. How are these guys random - So you know, it takes randomness to, to make randomness.
And this whole setup is a way to kind of purify and turn it into something that is like certifiably - The first numbers choose which measurements to perform,
and ones coming out of the detectors. there are four possible combinations of measurements.
answers for every possible measurement, stations could be correlated. the correlations exceed that limit.
We actually made an entire video about Bell tests So we've linked it in the description if you want Because the measurement choices are independent
during the measurements, that means the photons' results of locally predetermined outcome. So the experiment is actually testing whether those numbers
But there are other potential loopholes. with was called the Freedom of Choice loophole. gets the quiz ahead of time, knows
These particles, again, to speak kind of anthropomorphically, before they reach their detectors. And that goes back to randomness really at its core.
of measurements to perform had no kind - There are a few ways to do this, but David Kaiser - What we wanted to do was turn the universe itself into a
- They pointed two telescopes at distant quasars on opposite photons arriving from each of the quasars
Now, that light had been traveling for billions of years, to communicate with each other since nearly the Big Bang.
any hidden coordination between the measurement choices to happen billions of years ago. but it pushed that possibility much further back in time.
explanation could account for the results, - If I was a hacker, how would I attack In principle, two people working together could shine
And control which measurements are selected So NIST has to keep the random number generators used outside interference.
That makes it much harder for someone to hack the system, of the devices being tested. NIST still has to assume that along with the impossibility
and distance measurements, and faithful secure If those assumptions hold, then the Bell test can certify the detector outputs contain.
If we use entanglement, you can do these types that could have predicted what's happening in advance. But the raw measurements aren't necessarily an even
There might be far more zeros than ones. how much unpredictability is present across millions of evenly balanced, independent, random bits.
The basic idea is similar as his state of sin joke. If you get heads, then tails, you call that a zero.
And if both flips match, then you just throw them away. and the bias doesn't change, heads, tails,
So what's left is perfectly fair. Now, NIST technique is far more powerful, The Bell test certifies at least 820 bits worth
And then using a mathematical technique called randomness to just 512 bits. that we make contributes to every bit.
that we've seen throughout the video, Their unpredictability can actually be certified. - Albert Einstein, his argument was
That's this famous Einstein quote. In fact, these experiments that we do here that show that really, you know, this predictable nature, this kind
that Einstein espoused really is - Yeah. - So if God does play&nbsp; And it's this experiment.
This is the most random source of entropy you can generate. - God's dice are not loaded. Exactly. Yeah.
nothing in the universe could have predicted in advance. NIST actually publishes this on random.colorado.edu, along
and verify how the numbers were generated. and I can really use the, the bits that are generated here or a red sweater, and I'll be using these entangled
to me if you were a red and green sweater, It's like, it takes a lot of equipment. how we actually interconnect
and these different beacons together and sources of randomness can kind of actually form a layer to randomize is the internet.
can we just make everything more secure? - Okay. One last thing. Last year we launched the official
It's a game with 200 questions about science and technology, See, there's a confidence mechanic in the game and 10 on your answer.
you may lose out on points if you're doubting yourself. and it has been super fun. that it's now available.
to the Elements of Truth website. and as always, thanks for watching. that... no,
- No. I don't think I should die. I'll be fine.
