The Illusion of Randomness

Can a computer ever generate a truly ‘random’ number?

Posted November 6, 2024

The other day, I had a conversation with my Computer Science teacher about the ‘randomness’ of computer generated numbers. On asking a computer to generate a random number, true unpredictability is often expected, but only a clever imitation is received. This imitation is known as a pseudorandom number, created by an algorithm. The term pseudo meaning artificial or not genuine. Due to algorithms using formulas or set sequences, if the starting point, or ‘seed’ is known, the entire sequences of ‘random’ numbers could be predicted. This explains why computer-generated numbers aren’t truly random.

True randomness does exist in nature such as in radioactive decay, where it’s defined as an event that no one in any context would be able to specifically predict.

Patterns in Pseudorandom Numbers

Pseudorandom numbers often show subtle patterns. I generated 1 billion random numbers from 0 to 100 and the results are displayed in these heatmaps below, where the darker colours indicate numbers generated more frequently

Heatmaps of Pseudorandom Generated Numbers using matplotlib with Python

Across multiple trials, different heatmaps were produced. A similarity in this case is how one range has the darkest colours, 3 to 4 on one, and 67 to 69 on the other. These patterns are not obvious to the human eye and are generally meaningless to us, but this shows that certain ranges are slightly more frequent than others, suggesting a subtle pattern.

Limitations of Pseudorandomness

This being said, pseudorandom numbers will suffice for most use cases. However, in the scenario where true randomness is critical, such as that in cryptography or scientific simulations, pseudorandom numbers may not meet the needs.

In these cases, true random number generators can be used. These typically measure unpredictable physical processes on a computer rather than using mathematical based algorithms. Examples of this would be to measure electronic noise, radioactive decay, or thermal changes – as these are considered to be ‘truly’ random phenomena. This utilises the ‘truly’ random aspects of nature and converts them from analogue to digital. Although the option to measure these usually isn’t available with a standard computer, but instead requires specialized equipment.

Quantum Randomness

Going even further than these physical phenomena, quantum randomness can be introduced with the idea that photon emission is fundamentally unpredictable, and thus can produce true, non-replicable randomness.

To Conclude: The Importance of Randomness

The ability to generate random numbers is key for many programs that we use daily, however for the most purposes, we can live with pseudorandomness. Whilst it is interesting to understand that computers can never generate ‘truly’ random numbers it doesn’t have such a large impact on most individuals' daily life. However, this becomes more important in fields such as cryptography, needing to secure online transactions and thus a need for true randomness is vital in keeping information secure in a digital age.