Why can’t computers achieve complete randomness like flipping a coin, and how are real-world random numbers generated?

W

Computers are limited in their ability to implement randomness and cannot provide completely unpredictable results like a coin flip. In the real world, random numbers for security and gaming are generated using TRNG and PRNG methods. TRNGs create perfect random numbers by observing natural phenomena, but are limited in speed and reproducibility. To compensate, PRNGs use mathematical algorithms and random seed values to generate fast and reproducible random numbers, often utilizing sophisticated algorithms like Mersenne Twister.

 

“If there’s one thing computers aren’t good at, it’s flipping coins.” So says Steve Ward, professor of computer science at MIT. Because today’s computers can only process human-input conditions according to algorithms, which are human-defined ways of processing conditions, it’s difficult for a computer alone to achieve the randomness one would hope for in a coin flip. While computers can process millions of pieces of data through numerous complex calculations and precise predictions, “randomness” remains a challenge because it inherently involves an element of unpredictability. As a result, the computer’s behavior is based on human input. So how can we overcome this limitation?
However, many programs that are closely related to our daily lives require random numbers. Examples include OTPs, which are often used for security, and sweepstakes, which are one of the main sources of income for many gaming companies. OTPs provide added security by generating a new number every time you log in, and games provide unpredictability and excitement to their users by randomizing rewards through a draw system. The randomness of numbers is becoming an essential element in many different fields. So here’s the problem we need to solve. How do we get computers to output “random” numbers that we are comfortable with?
The most basic principle is to observe and record random factors and use them to our advantage. Modern science has advanced to the point where we can accurately predict many phenomena, but there are still many that we cannot. By observing these phenomena, we can assign random numbers to computers, as if we were “borrowing” random elements from nature. For example, a site called random.org observes the noise in the atmosphere and uses the results to generate random numbers, which are then given to us. Devices, programs, etc. that generate random numbers in this way are collectively known as TRNGs (True Random Number Generators).
However, it’s one thing to generate completely random numbers, but it’s another to use them. While it’s clear that the numbers generated by a TRNG are completely random and unpredictable to anyone, there are two problems with using them directly. One is that the speed of outputting the numbers can’t outpace the speed of measuring them, so depending on the TRNG, it may not be able to do its job when you need a lot of numbers in a short amount of time. For example, if you have a TRNG that flips a coin 10 times in one second and records a 1 on a head and a 0 on a tails, this TRNG will be difficult to use if you need a 1000-digit binary random number in 10 seconds. The other difficulty is that the numbers are too random to reproduce in another space or at another time. This makes it difficult to diagnose errors in programs that involve numbers, or to share the “key” when using TRNGs for security.
That’s why many companies and organizations use a Pseudo Random Number Generator (PRNG) in addition to a TRNG to generate random numbers. A PRNG is an algorithm that basically takes one number from somewhere else to create the next number, uses that number to create the next number, uses that number to create the next number, uses that number to create another number, and so on. PRNGs provide randomness, but due to the nature of the algorithm, they have repetitive patterns. To compensate for this, we set the seed to the value of the TRNG to enhance the randomness of the pseudorandom number.
Based on the information so far, it seems that any algorithm can be used as a PRNG as long as the basic conditions are met. However, there are two crucial reasons why you shouldn’t use just any algorithm as a PRNG. The first is that the output of any algorithm will eventually be circular. PRNGs go through the process of [input a number → process it in a certain way → output a number corresponding to the processed result → input another number using the output number → process it in a certain way →……], and due to the limitations of computer programs, there is a limit to the range of numbers that can be used in every input and output step. Because of this limitation, there will be a point during the same process where the “other numbers using the output” will be the same as the “previously received values as input,” at which point the previous numbers will start to appear again, and the output will be predictable rather than random. This is a limitation of all algorithms, but it is obvious that an algorithm that avoids this cyclic behavior as much as possible is more valuable as a random number generator than one that does not.
The second reason is that any algorithm can produce numbers that never appear in the output range. For example, imagine a game where 100 people are given numbers from 1 to 100 in key order, and a computer program is used to pick a number between 1 and 100 and give $1 million to the person who picks that number. It would be unfair if the PRNG algorithm used did not produce the numbers 88 and 99 due to the limitations of the algorithm. Not only this, but in other fields that require sophisticated randomization, this error can be catastrophic.
That’s why the algorithms used in PRNGs are usually elaborated with the best of modern mathematics and modern computer science to ensure that they loop, but not so far away that they don’t loop, and that all the numbers in the output range are represented and, more importantly, that all the numbers are represented evenly. The Mersenne Twister, a PRNG created in 1997 and still used today in many fields, has a period of ((2^19937)-1), which means that there is a cycle, but in theory, even if all computers on Earth use it until the end of the universe, they will never see a cycle of numbers, and it is guaranteed that all numbers will appear a uniform number of times with the same distribution in 623 dimensions.
After TRNG and PRNG, we have randomized numbers available to computers. In a nutshell, since computers can’t flip a coin themselves, we can watch a coin flip happen elsewhere and have the computer do it for us. Random number technology is ubiquitous, but behind it is the work of many people who have encountered this problem in the past and tried to solve it. If you find yourself using OTP or buying a lottery item, I hope you’ll take a moment to thank them.

 

About the author

Blogger

Hello! Welcome to Polyglottist. This blog is for anyone who loves Korean culture, whether it's K-pop, Korean movies, dramas, travel, or anything else. Let's explore and enjoy Korean culture together!