History · 9 min read
From Knucklebones to ChaCha20: A History of Random Number Generation
Five thousand years of trying, and often failing, to make machines produce true unpredictability — and what each generation got right and wrong.
Long before there were spinner wheels, dice, or even written numbers, humans were already trying to delegate choices to chance. The history of random number generation is, in a real sense, the history of asking the universe to make a decision so we do not have to. It is also a history of repeated, sometimes embarrassing, failures to do that asking correctly.
The Astragalus Era
The earliest known randomization devices are astragali — the small four-sided ankle bones of sheep and goats. Excavations at sites in the ancient Near East have turned up astragali polished smooth from millennia of use, dating back to at least 3500 BCE. The four faces of the bone are not equally likely to land up, but ancient gamblers, oracle-priests, and casters of lots used them anyway, layering interpretive meaning onto whichever face appeared.
The Greeks and Romans refined the bones into six-sided cubic dice, which they cast for everything from board games to imperial succession. Roman law contains specific provisions for resolving inheritance disputes by dice. The Egyptians used randomized lot-casting to assign administrative positions in temples. The casting of lots is mentioned over seventy times in the Hebrew Bible alone.
The Birth of Algorithmic Randomness
For thousands of years, randomness meant a physical device. The shift to algorithmic random number generation came with the rise of computing in the mid-twentieth century. In 1946, John von Neumann proposed the middle-square method: take a number, square it, and take the middle digits as the next number. It was simple enough to run on the early electronic computers of the era.
It was also dreadful. The middle-square method has short cycles — sequences that return to their starting value after a small number of iterations — and is full of degenerate states where the output collapses to zero. Von Neumann was clear-eyed about this. He wrote that anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin. He proposed his method as a stopgap, not a solution.
The Linear Congruential Era
By the 1960s, the linear congruential generator (LCG) had become the standard. An LCG produces each output by multiplying the previous output by a constant, adding another constant, and taking the result modulo a power of two. With careful choice of constants, LCGs produce long periods and pass basic statistical tests. They were fast, simple, and good enough for most applications.
Most. The most infamous failure of the era was IBM's RANDU, an LCG shipped in IBM scientific subroutine libraries throughout the 1960s. RANDU's particular choice of constants caused its outputs, when plotted in three dimensions, to fall on just fifteen parallel planes. Years of scientific simulations — physics, chemistry, statistics — had been built on top of this generator before researchers noticed. Donald Knuth, in his Art of Computer Programming, would later describe RANDU as "truly horrible."
The Mersenne Twister and the Modern Era
In 1997, Makoto Matsumoto and Takuji Nishimura published the Mersenne Twister, a generator with a period of 2^19937 - 1. It was statistically excellent for non-cryptographic purposes, fast on the hardware of the time, and was adopted by Python, MATLAB, R, and many other languages as the default random number generator. For most simulation and gaming workloads, the Mersenne Twister was, and is, fine.
It is, however, fully deterministic. Given any 624 consecutive outputs, you can compute every subsequent output. For cryptographic applications — generating keys, nonces, session tokens — this is unacceptable. A new class of generators emerged: cryptographically secure pseudo-random number generators (CSPRNGs), built on top of cryptographic primitives that resist prediction even when partial outputs are known.
The CSPRNG Generation
Modern operating systems maintain entropy pools — collections of unpredictable bits gathered from physical sources like keystroke timings, mouse jitter, network packet arrivals, and hardware thermal noise. These bits are fed through cryptographic hash functions or stream ciphers to produce streams of random output. Linux exposes this via /dev/urandom; Windows has BCryptGenRandom; and the Web Crypto API exposes it in browsers via crypto.getRandomValues.
The current state of the art is ChaCha20, a stream cipher designed by Daniel J. Bernstein. ChaCha20 is the engine inside the random number generators of Linux, OpenBSD, modern macOS, iOS, Android, and most modern web browsers. When you call crypto.getRandomValues in a browser, you are almost certainly drawing bytes from ChaCha20 seeded by the operating system's entropy pool.
What Each Generation Got Right
Astragali got intuition right: outcomes need to be physically unmanipulable to be trusted. The middle-square method got speed right but unpredictability wrong. LCGs got period length right but structural quality wrong. The Mersenne Twister got statistical uniformity right but predictability wrong. CSPRNGs, finally, get all three right at once, at the cost of slightly more computation per draw.
Why This Matters for a Spinner Wheel
When a modern web app generates randomness, it inherits a chain of mathematical and engineering decisions stretching back through the entire history above. The choice to use crypto.getRandomValues instead of Math.random is, in effect, a choice to use the CSPRNG generation rather than the LCG generation. The result is a level of fairness that would have been unimaginable when astragali were the cutting edge — and is now available for free, in every browser, to anyone who wants to spin a wheel.
Recommended Reading
If you found this article useful, these books go deeper into the same topics. Each title is hand-picked for the material covered above.
- The Drunkard's Walk: How Randomness Rules Our Lives by Leonard Mlodinow — A readable history of how humans have grappled with randomness from ancient dice to modern probability. View on Amazon
- A Million Random Digits with 100,000 Normal Deviates by RAND Corporation — The legendary 1955 book of pre-computed random numbers — a primary source for the history of RNG. View on Amazon
As an Amazon Associate, Roulety earns from qualifying purchases. This does not change the price you pay and helps support the writing on this site.
© 2026 Roulety. Free online spinner wheel for decisions, games, and fun.