Are Random Number Generators Really Random?

Computer systems run on code and algorithms, which determines the result before execution. So, are random number generators truly random?

Pseudo Random Number Generators (PRNG)

The typical random number generators that we find online or on our calculators are actually not truly random. Numbers are generated by algorithms, which means that the sequence of numbers is actually predetermined. Random number generators that use algorithms for generation are called pseudo random number generators (PRNG). Research has been conducted in pseudo random number theory, and modern algorithms make the numbers generated seem very random. 

One example of a PRNG is the linear congruential generator (LCG). The LCG generates numbers based on the following algorithm:

where a is the multiplier, c is the increment and m is the modulus. The first number that is substituted into Xn is called the seed value. The seed value is often representative of the current date and time. This algorithm is special because for a small change in input, it can return a large change in output. These algorithms are therefore described as having a high amount of entropy. 

Since they run on a set algorithm, PRNGs are efficient and can produce many numbers in a short time. In addition, if the algorithm and the seed value is known, the same number sequence can be reproduced later. 

There is a subset of PRNGs called quasi-randomisation. While pseudo-randomisation does not take uniformity of data points into account, quasi-randomisation does. They distribute the numbers evenly by positioning them as far away from other numbers as possible, as shown in the figure below. This avoids cluster formation. However, quasi-randomisation is sometimes considered not random enough, and they fail to pass some key randomness tests. 

▲Quasi and Pseudo-random distributions “True Random Number Generator Functions?” (Pamuditha) [4]

True Random Number Generators (TRNG)

Random number generators that are truly unpredictable are called true random number generators (TRNG). TRNGs are made possible by using outside phenomena that are unpredictable and processing them as data into the computer. The randomness is extracted from physical phenomena. Possible phenomena include atmospheric noise and the radioactive decay of an atom. Whether these phenomena are predetermined since the start of the universe is a debate for another time. What matters is the fact that they are unpredictable to humans. Outside data could also be mouse or keyboard movements of the user. The changes in these phenomena are translated into random numbers. 

TRNGs are inefficient compared to PRNGs. On the other hand, sequences cannot be reproduced later and there is no periodicity, increasing its randomness and unpredictability. 

Recently, quantum computers can be used to construct a TRNG, by using the behaviour of subatomic particles. Quantum computers run on qubits, which exists in all possible states at once until the very moment when the solution is computed. This phenomenon is called superposition. Superposition means that there is a truly equal chance of generating all possible numbers, and cannot be predicted beforehand.

Why Does it Matter?

Randomness is an important theme for humans in many areas. It was important in Athenian democracy where the administration was selected randomly. Randomness is sought in games, casinos, random sampling and simulations. Random number generators can also be used to solve deterministic problems. For example, pi can be estimated using randomly generated dots, as shown in the figure below. With more dots, the approximation of pi gets closer to the actual value. Moreover, randomness can help in increasing efficiency for sorting (by selecting random points repeatedly to sort) and portfolio optimisation for finance.

The capabilities of PRNGs are enough in many of these fields. The field where the difference between PRNGs and TRNGs become important is the security of encryption systems. Cryptography requires passwords and encryption that are truly unpredictable to attackers, and this is where the use of TRNGs is becoming increasingly important.

▲Simulating pi using random numbers. “An Overview of Monte Carlo Methods” (Pease) [6]

[1] Hoffman, Chris. (2019). “How Computers Generate Random Numbers”. https://www.howtogeek.com/183051/htg-explains-how-computers-generate-random-numbers/. Last Accessed: 2020/02/07. 

[2] Haahr, Mads. “Introduction to Randomness and Random Numbers”. Random.org. https://www.random.org/randomness/. Last Accessed: 2020/02/07.

[3] Xiannong, Meng. “Linear Congruential Method”. https://www.eg.bucknell.edu/~xmeng/Course/CS6337/Note/master/node40.html. Last Accessed: 2020/02/07. 

[4] Pamuditha, Isuru. (2019). “True Random Number Generator Functions?”. Medium. https://medium.com/swlh/random-functions-a4f36b1dfd8f. Last Accessed: 2020/02/07.

[5] McCorkell, Robble. (2018). “Programming a Quantum Computer: Generating True Random Numbers”. https://blog.red-badger.com/2018/9/24/generate-true-random-numbers-with-a-quantum-computer. Last Accessed: 2020/02/07.

[6] Pease, Christopher. (2018). “An Overview of Monte Carlo Methods”. Medium. https://towardsdatascience.com/an-overview-of-monte-carlo-methods-675384eb1694. Last Accessed: 2020/02/07.

en_USEnglish
jaJapanese en_USEnglish