Is it possible to generate truly random numbers using a computer?

This is a good question, but to dig into it we have to look at the underlying assumptions.

First, for the purpose at hand, it doesn't really make sense to say that a number itself is random. There is a sense of a particular number being random from Kolmogorov complexity, but that is not what is intended here. Instead, what we are interested in might be called a random process - a process that generates a sequence of numbers so that the sequence satisfies some particular probability distribution. We want to know if a computer can generate a sequence of numbers in a random manner.

The next question is what we mean by "using a computer program". If we take a "computer program" to be a completely deterministic algorithm, then it will not be able to generate numbers in a truly random manner. There is no computer program which could be simulated entirely by paper and pencil - deterministically - which generates numbers in a random manner. The next number in the sequence is always completely predictable!

However, if we are willing to add additional hardware, then it might become able. This is a broader notion of "program". For example, the machines used to draw winning numbers for a lottery are designed, essentially, to try to generate numbers in a random manner. There is no reason that one of these could not be connected to a computer and automated. So, if we accept that the lottery can generate numbers randomly, so can a computer.

There are faster methods, as well. Some operating systems try to gather random information from the environment, store this information, and then return it when asked to generate a random number. This is not a deterministic process, but theoretically it does generate numbers in a random manner. For example, the computer can measure white noise, or can measure the timing of various events like keystrokes and packet arrivals, and combine these in a theoretically valid way to generate numbers randomly.

The final issue is philosophical. Some might believe that the entire universe is deterministic, and therefore nothing is ever random. However, that objection is too far removed for the present conversation. If we want to ask whether computers can generate numbers in a random manner, we normally take it as a given that something could generate numbers in a random manner, so that we can focus on whether computers can do so.


After searching the Internet, I have decided to answer my own question here. It is possible to generate truly random numbers. Random numbers are generated from random unpredictable processes like thermal or atmospheric noises, cosmic radiations, etc. We need special hardware or sensors which can measure such processes and there could be a program which can produce a number from the input of random events. As this method uses random events rather than a pre-defined algorithm, it can generate a truly random number.

You can find one such online solution at https://www.random.org/. Random.org uses atmospheric noise to create randomness.

Finally, here is a joke:

Random number


Yes from a theoretical point of view, not from a practical point of view.

It is possible with a program accessing the wifi module in off-the-shelf computers. The idea behind this is described here: The random changes in noise level are recorded. This noise is generally accepted as being random (just turn your AM radio to some unoccupied frequency at daytime and listen to the noise the atmosphere produces. The same happens on the ~2 GHz frequencies our wifi modules operate on.). I think they follow some kind of poisson process, so the time between noise changes follows some exponential distribution.

Maybe one could also use turning objects like the cooling fan or the hard disk as some kind of wheel of Fortune since their rotation speed can be controlled and recorded by software.

However, such random numbers tend to have one big drawback: You don't know their true distribution. So they are useless for most applications, except if you take the random number to seed a ordinary pseudo random number generator (pRNG). Then the resulting pseudo random numbers are a bit less "pseudo" but still have a known (frequency) distribution.

Sources of useful randomness with a better understood distribution usually need devices that are no longer part of usual computers. Such devices need to comply to narrow specifications in order to produce the desired probabilities. Usual computers do not: You don't know how much your cooling fan's bearing is worn-out, which random noise your wifi actucally receives etc.

Another downside: Generating real random numbers is much slower than pRNGs are, even if you have a specialized device that observes some radioactive decay in order to produce random numbers. So you may end up again with producing only the seed for the pRNG at random.