The Illusion of Randomness: How Computers Generate Numbers
Can a computer actually be random? Learn the difference between True Randomness and Pseudo-Random Number Generators (PRNGs) used in video games and cryptography.

Generate mathematically secure, unbiased sequences instantly using our Random Number Generator, or read on to discover why true randomness is scientifically impossible for a computer.
We rely on random numbers every day. They shuffle your Spotify playlists, determine the loot drops in your favorite video games, and generate the cryptographic keys that secure your bank account passwords.
But there is a massive philosophical and mathematical problem: Computers are deterministic. A computer is a logic machine designed to follow strict, predictable instructions. Therefore, it is physically impossible for a computer to generate a truly "random" number out of thin air.
So, how do they do it?
Pseudo-Random Number Generators (PRNGs)
Most applications (like video games or spreadsheet software) use Pseudo-Random Number Generators (PRNGs).
A PRNG uses a highly complex mathematical algorithm to create a sequence of numbers that looks completely random to a human, but is actually entirely predictable if you know the starting variable.
The "Seed" Value
Every PRNG algorithm requires a starting number, called a Seed. If you feed the algorithm the exact same Seed, it will always output the exact same sequence of "random" numbers.
To create the illusion of randomness, the computer usually uses the system clock as the Seed. For example, the computer will look at the exact millisecond you clicked the "Generate" button (e.g., 14:32:05:943) and use 943 as the starting seed for the complex math equation. Because humans cannot perfectly time clicks down to the millisecond, the output appears completely unpredictable.
The Danger of PRNGs
Because PRNGs are deterministic, they are highly dangerous to use for cybersecurity. If a hacker can figure out the algorithm and guess the Seed (by looking at the computer's system clock), they can instantly predict all the "random" passwords or encryption keys the computer is generating.
Enter your own numbers and see the result instantly — free, no signup.
A Tiny PRNG You Can Run by Hand
The simplest famous family of PRNGs is the Linear Congruential Generator. Each new number comes from the previous one:
next = (a × current + c) mod m
Try it with tiny constants: a = 5, c = 3, m = 16, and a seed of 7.
(5 × 7 + 3) mod 16 = 38 mod 16 = 6(5 × 6 + 3) mod 16 = 33 mod 16 = 1(5 × 1 + 3) mod 16 = 8(5 × 8 + 3) mod 16 = 43 mod 16 = 11
The sequence runs 6, 1, 8, 11, 10, 5, 12, 15... and looks patternless at a glance. But with only 16 possible values, it must repeat within 17 steps — and once it repeats, the whole cycle repeats forever.
Real generators are this same idea, scaled enormously. With a modulus around 2⁶⁴ or larger, the repeat cycle is so long that no observer can wait it out.
The Middle-Square Method: An Early Attempt
In the 1940s, John von Neumann proposed an even simpler recipe: square the seed and take the middle digits.
Start with 1234. Square it: 1234² = 1,522,756, padded to 01522756. The middle four digits are 5227 — your first "random" number.
Square again: 5227² = 27,321,529, so the middle four digits are 3215. Repeat as needed.
The method is charming but flawed. Some seeds decay into short loops, and the seed 0000 collapses to zero forever — a warning that "looks random" is not the same as "behaves randomly."
The Mersenne Twister: The Modern Default
Most programming languages generate everyday random numbers with the Mersenne Twister, introduced in the 1990s. Python's random module is a well-known example.
Its cycle length is 2^19937 − 1, a number with about 6,000 digits. For shuffling playlists, dealing game cards, or running simulations, it will effectively never repeat.
It is also fast and passes demanding statistical tests for even distribution. For games and simulations, it is more than good enough.
But it is still deterministic. Observing enough of its outputs lets a determined analyst reconstruct its internal state — which is why it must never guard secrets.
Cryptographically Secure Generators (CSPRNGs)
Security software uses a stricter class of generator built for unpredictability, not just good statistics.
Operating systems maintain an entropy pool: a reservoir of randomness gathered from mouse movements, keystroke timings, disk activity, and hardware events. Cryptographic generators draw from this pool and mix it continuously.
The design goal is different from a game PRNG. Even seeing a long stretch of past output must reveal nothing about future output.
Password generators, session tokens, and encryption keys should always come from this class of generator. When a tool says "secure random," this is the machinery it is claiming to use.
Random Numbers as a Measuring Tool
PRNGs are not just for games. Scientists use them to measure things that are too complex to calculate directly, in a technique called Monte Carlo simulation.
Here is the classic demonstration. Scatter random points evenly inside a square, and count what fraction land inside a quarter-circle drawn in one corner.
That fraction approaches π/4 as the points multiply. If 785 of 1,000 points land inside, the estimate is 4 × 0.785 = 3.14 for π.
More points sharpen the estimate — millions of points yield several correct digits. The randomness is doing real mathematical work, which only succeeds if the generator is unbiased.
The same approach prices financial options, models weather ensembles, and tests engineering designs against thousands of simulated futures.
True Random Number Generators (TRNGs)
To secure the internet, computer scientists had to figure out how to generate True Random Number Generators (TRNGs).
Because a computer algorithm cannot be truly random, a TRNG relies on unpredictable physical phenomena occurring in the real world to generate the Seed.
Modern TRNGs measure physical entropy (chaos):
-
Atmospheric Noise: Measuring random radio static from lightning strikes around the world (this is what the famous site Random.org uses). - Thermal Noise: Measuring microscopic fluctuations in temperature on the computer's motherboard. - Radioactive Decay: Measuring the unpredictable timing of subatomic particle decay.
-
Lava Lamps: The cybersecurity firm Cloudflare famously uses a wall of 100 physical lava lamps in their lobby. A camera records the chaotic movement of the lava blobs and converts those visual pixels into massive strings of truly random cryptographic keys.
How to Tell If Numbers Behave Randomly
You cannot prove randomness by staring at a list, but you can test its fingerprints.
Check the distribution. Roll a fair die 600 times and each face should land near 100 times. Big, persistent gaps signal bias — our Probability Calculator shows the expected odds for common setups.
Check combined outcomes. Two dice sum to 7 in 6 of 36 combinations, about 16.7% of rolls. A generator that produces 7 only 5% of the time is not dealing fairly, whatever its output looks like.
Check for cycles. In a long output, look for a repeated block. Repetition at a fixed interval is the signature of a too-small PRNG, like the toy example above.
Statisticians formalize these checks with tests on spread and independence — the same thinking behind tools like a Standard Deviation Calculator.
No single test proves a generator random. Passing many different tests, over very long outputs, is what earns a generator its reputation.
Seeds in Games: Randomness You Can Replay
Video games turn determinism into a feature. Procedurally generated worlds are often built from a seed you can read and share.
Enter the same world seed in a game like Minecraft and the identical landscape regenerates, hill for hill. The "random" world was a compressed recipe all along.
Speedrunners and map-sharers rely on this. It is the friendliest possible demonstration that a PRNG's output is fully determined by its starting value.
FAQ
Why does Spotify's 'Shuffle' feel like it's not random? Because true randomness often results in "clumping" (e.g., playing three songs from the same artist in a row), which humans perceive as annoying or broken.
Spotify actually had to reduce the mathematical randomness of their shuffle algorithm, introducing rules to spread artists out evenly, so the playlist would feel more random to human psychology!
Can a hacker really predict a PRNG? For weak generators, yes. If the algorithm is known and the seed is guessable — a timestamp, a small counter, a process ID — the entire sequence is reproducible. Secure systems therefore use large, entropy-fed seeds and cryptographic generators.
Is flipping a coin truly random? Physically, a coin flip follows ordinary mechanics, so in principle its outcome is set by the flip's force and spin. In practice those inputs are too sensitive to measure, so coin flips serve as fair randomizers. Computers cannot toss coins, so they borrow chaos from the physical world instead.
What makes a good seed? Size and secrecy. A good seed is large enough that guessing is hopeless, and drawn from sources an attacker cannot observe or replay — which is exactly what operating-system entropy pools are for.
Need an unbiased result for a giveaway, statistical sample, or tabletop game? Use the CalcUnit Random Number Generator today.



