## The Gambler’s Fallacy

Predicting the future is necessary for survival. I don’t mean predicting the end of the world, just simple things like whether the sun will rise tomorrow or how late your friend will be to coffee. These predictions use prior knowledge to figure out what to do next. Pretty nifty. On the other hand, there are some events that aren’t meant to be predicted—unknown futures that are best left in the hands of the universe.

For some reason, you try to predict them anyway.

You’re in grade school. You sit down for a history test. The teacher hands you the multiple choice questions. “Begin.”

B

C

D

A

A

A

A

Wait, why are there four As in a row? That can’t be right. Surely, the next one won’t be an A. It certainly looks like it should be A. A seems like the right answer. But it can’t be. C looks pretty good, and it’s not A. You choose C.

One week later, you get your test back. You scan down to question 8. Beside your poorly-erased A and second guess C sits the letter A, written in red pen. It may sting a little, but it’s nothing compared to the millions of francs lost at the Monte Carlo Casino in 1913.

One humid night in August, gamblers crowded the roulette table. Eight black in a row. Nine black in a row. Everyone was sure this streak had to end, and bet everything on red. Ten. Eleven. Surely, the end was near. Twelve. Thirteen. Emptied wallets and ripped up check books surrounded the table on the 27th spin, when the ball finally landed on red.

Like these unwitting patrons, you fell victim to the Gambler’s Fallacy. You tried predicting the future without the universe’s permission. We use a special name for these kinds of events, the ones only the universe knows the answer to. We call them random.

## Random

Most dictionary definitions of “random” describe it as occuring without a logical or regular pattern. Intuitively, this makes sense. We use the word “random” in our everyday lives to refer to unexpected events or those that stray from a known pattern.

Unfortunately, this colloquial idea of “random” makes understanding true randomness incredibly different for people. If we see a temporary pattern, like a repeated answer in a multiple choice exam, our brain believes the pattern must break because the events should be “random.” An exam with B as the correct answer for every question doesn’t feel random. A coin that never lands on tails no matter how many times you flip it doesn’t feel random.

Surprisingly, that test is random, and so is that coin. Remember, that teacher has written hundreds of exams with thousands of multiple choice answers. If you look at all those answers put together, a short string of 20 Bs in a row doesn’t seem too out of the ordinary. Likewise, you’ll only be able to flip that coin a finite number of times, and if in that finite number of times you only land heads, that is entirely possible. In fact, all heads is just as likely as alternating heads/tails starting with tails.

So, how should we conceptualize randomness? Assuming you’re not a statistician by trade, these two principles will cover most everyday cases:

- The coin has no memory.
- You cannot read the coin’s mind.

For the first principle, no matter how many times you flip a coin, every new flip is a 50/50 chance of heads or tails. The coin does not remember landing on heads 10 times in a row. It only knows this next flip, which brings us to the second principle. Only the coin knows the next flip. You cannot read the coin’s mind to see what it has chosen. You will not know whether the coin has chosen heads or tails until the flip is already complete.

Disclaimer: Remember that wherever humans are directly involved, what seems random likely isn’t. Teachers tend to avoid more than 5 of the same answer in a row on tests, even though it is entirely likely, so multiple choice isn’t completely random. Also, people have learned how to bias coin flips based on how they flip the coin.

## Blasphemy

Randomness is beautiful. It’s the universe’s way of keeping secrets and sharing them at just the right time. Nothing can truly defeat the purity of random numbers.

Except this one YouTuber apparently.

A computer science YouTube channel by the name PwnFunction found a way to predict the random numbers generated by the Chrome v8 engine, which runs your browser. After testing it myself, I can’t argue with the results. Does this mean we should ignore everything I just said about unpredictability? Not quite.

Countless engineers and mathematicians have devised ways for your computer to generate random numbers. Unfortunately, generating a random number means you have a formula, so it’s not random anymore. Instead, these are called pseudorandom numbers. Using the current time and a formula, the computer generates a starting “seed.” This seed is then used to generate the next seed without the use of the current time. This seed generates the next seed, and so on. Eventually, the cycle loops back all the way to the beginning:

$$1 \rightarrow 2 \rightarrow 3 \rightarrow \cdots \rightarrow 100 \rightarrow 1 $$

In the example above, the seeds increase by one every time until they reach 100, and they begin again. Not very “random.” Typically, the formula for generating the next seed isn’t that straightforward. This leads you to sequences that look like

$$ \rightarrow 2162 \rightarrow 4843 \rightarrow 9140 \rightarrow 3577 \rightarrow 8951 \rightarrow $$

except instead of 4 digit numbers, they use 10 digit numbers. They look random, but they can be predicted if you know the previous random number and the formula. That’s what makes them pseudorandom.

Left undefended, poorly designed “random” number generators make for fantastic attack targets. Since encryption and security rely on random numbers, your secrets are left in the hands of programmers playing god.

## The Beginning

Throughout the rest of this series, I will explore ways to generate random numbers to figure out which one is right for you. From the epitome of elegance to bleeding-edge technology, these episodes will cover the human pursuit of true randomness.