Fun Generators
Login
Fun Generators
Toggle sidebar

Random Number Generators Explained: How "Random" Is Actually Random?

By Fungenerators ·

Random Number Generators Explained: How "Random" Is Actually Random?

Every time you roll a digital die, shuffle a playlist, or generate a lottery pick, a computer produces a "random" number. But computers are machines built to do exactly what they're told, the same way, every time. So how can a machine designed for predictability produce something unpredictable?

The short answer: most of the time, it doesn't. And that's usually fine.


Most Random Numbers Are Completely Predictable

The random numbers your computer generates in everyday software are usually pseudorandom. They're produced by a formula that starts from a number called a seed. Give the same formula the same seed, and it will produce exactly the same "random" sequence every single time.

That sounds like a flaw, but it's often a feature. Scientists re-run simulations with the same seed to reproduce results. Game developers use seeds so players can share the same randomly generated world. Minecraft players trade world seeds for exactly this reason.

The mathematician John von Neumann, one of the founders of modern computing, joked about this tension in 1951: "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin." He still used them — because in practice, they work remarkably well.

We call this useful determinism: randomness that looks unpredictable to people but is fully reproducible for anyone who knows the seed.


Pseudorandom Number Generators (PRNGs)

A pseudorandom number generator takes a seed and repeatedly applies a mathematical function to produce a long sequence of numbers that look random — they pass statistical tests for randomness, even though they're entirely determined by the seed.

The Mersenne Twister

One of the most widely used PRNGs is the Mersenne Twister, created by Makoto Matsumoto and Takuji Nishimura in 1997. Its sequence doesn't repeat for 2^19937 − 1 numbers — a number with about 6,000 digits. For comparison, the number of atoms in the observable universe is estimated at around 10^80, a number with just 81 digits.

It's been used as a default random number generator in many programming languages and tools, including Python's random module.

Where PRNGs fall short

PRNGs are great for games, simulations, and shuffling. They're not safe for security, because if an attacker can figure out the seed or the internal state, they can predict every future number.


Cryptographically Secure Generators

For passwords, encryption keys, and security tokens, software uses cryptographically secure pseudorandom number generators (CSPRNGs). These are designed so that even seeing a long run of previous outputs doesn't help an attacker predict the next one.

Operating systems feed CSPRNGs with unpredictable data from the physical world, like tiny timing variations in hardware events. That's why a good Password Generator should always rely on a secure source of randomness.


True Random Number Generators (TRNGs)

True random number generators don't use formulas at all. They measure physical processes that are fundamentally unpredictable:

  • Atmospheric noise. Random.org, founded by computer scientist Mads Haahr at Trinity College Dublin in 1998, generates random numbers from radio noise in the atmosphere.
  • Radioactive decay. The timing of individual decay events is unpredictable.
  • Thermal noise. Tiny electrical fluctuations inside circuits.
  • Lava lamps. Really.

The lava lamp wall

Internet security company Cloudflare famously points a camera at a wall of around 100 lava lamps in its San Francisco office. The constantly shifting wax creates unpredictable images, which are converted into data and mixed into its randomness sources. It's part security engineering, part brilliant marketing.


Before Computers: A Million Random Digits

Randomness used to be printed. In 1955, the RAND Corporation published A Million Random Digits with 100,000 Normal Deviates — a book containing exactly what it sounds like. Scientists and statisticians used it to pick random samples before computers were widely available.

The book is still in print, and its online reviews are a legendary genre of internet comedy. ("The plot is predictable" is a popular joke.)


Humans Are Terrible Random Number Generators

If you ask people to pick a random number between 1 and 10, they pick seven far more often than 10% of the time. People also avoid repeats: when asked to write down a "random" sequence of coin flips, most people alternate heads and tails far too often, because a streak like H-H-H-H-H feels non-random.

Real randomness is streakier than people expect. We call this the clumping surprise: the tendency of truly random sequences to produce runs, repeats, and clusters that look suspicious to human eyes. Try flipping a digital coin 20 times and count the streaks.


So Which Kind Does a Random Generator Use?

Use case Typical source Good enough?
Dice, games, shuffles PRNG Yes
Scientific simulations Seeded PRNG Yes (and reproducible)
Passwords and keys CSPRNG Yes
Official lottery draws Physical ball machines or certified RNG systems Yes, with audits
Casino gaming machines Certified RNGs Yes, with regulation

For picking lottery numbers for fun, rolling dice, or spinning a decision wheel, a well-built PRNG is more than random enough. Your numbers are just as likely to win as any other combination.


See Pseudorandomness for Yourself

You can watch seeds in action with a few lines of Python:

import random

random.seed(42)
print([random.randint(1, 6) for _ in range(5)])

random.seed(42)
print([random.randint(1, 6) for _ in range(5)])

Both lines print exactly the same five "dice rolls," because both sequences start from the same seed. Change the seed to 43, and you get a different, but equally repeatable, sequence. Remove the seed() call entirely, and Python seeds itself from the operating system, so every run is different.

That's useful determinism in one small experiment: the numbers look random, pass statistical tests, and are still completely reproducible.


Quick Answers

Are online random number generators truly random?

Most are pseudorandom: they use a formula that starts from a seed, so the sequence is technically predictable if you know the seed. For games, dice, lottery picks, and decisions, that's more than random enough. True random generators instead measure unpredictable physical processes, like atmospheric noise or thermal noise.

What is a random seed?

A seed is the starting value a pseudorandom number generator uses to produce its sequence. The same seed always produces the same sequence of numbers. That's why games let players share world seeds, and why scientists record seeds so experiments and simulations can be repeated exactly.

Can a random number generator improve my lottery odds?

No. Every valid lottery combination has the same chance of being drawn, whether you pick it yourself or a generator picks it. A generator can help you avoid popular patterns like birthdays, which means you're less likely to split a jackpot with other winners if your numbers come up.


Where Randomness Is Heading

Quantum random number generators, which measure quantum effects like how individual photons behave, are already commercially available, and some smartphones have included quantum random number chips. Our prediction: within the next decade, hardware-based true randomness will become a standard, invisible feature of consumer devices, and the distinction between "pseudo" and "true" random will stop mattering to anyone outside of security research.


Try Them Yourself