Monday, March 15, 2010

Can a computer generate random numbers?

If you are a programmer or a mathematician of some sort, you would mostly say yes. As a justification, you would quote some of the functions like Rand( ), Random( ) from various programming languages. My answer is a sort of no. This post will give you some insights on the random number generation. I have a reasonably good amount of confidence that by the end of this post, you will agree with me in saying that a computer by itself cannot generate a random number.

To start with, we shall define Random Number. This is my favorite definition which I picked from the internet. (http://mathworld.wolfram.com/RandomNumber.html). “A random number is a number chosen as if by chance from some specified distribution such that selection of a large set of these numbers reproduces the underlying distribution.” Let me put it in simple mathematical terms. A random number should –

• Have no periodicity.
• Have good distribution of the numbers.
• Have no underlying logic for generation and hence impossible to predict the next number.

Every program (or computer instruction set) is built on a logic and thus the random generation program written to instruct computers lead to a predictable series which contradicts the basic definition of the random numbers. As a matter of fact the periodicity will be so big that, it is hard to notice the pattern unless you know the underlying logic.

To improve it further, programmers rely on the computer’s clock. They read the last few digits of the micro seconds from the processor clock and feed the same as the input for the random number generator. Though the clock cycle by itself is periodic, the reading of this clock is not periodic. It depends on the computer load and its behavior. In other words it depends on how many other programs are running on the computer and how fine the computer lock is. In a ‘ideal world’, given no other programs running, this still can’t generate a real random number. But in a ‘true world’ it would. The random numbers generated in this way are often referred to as Pseudo-Random Numbers.

So how are the random numbers generated? This can be achieved with the help of random events. In most of the cases, we use radio active elements. The decay of radio active elements is random. This is sampled and used to generate the true random numbers by feeding the data to a computer. Some use the cheaper ways like changing atmospheric temperature.

So, a computer by itself cannot generate a random number. It should rely on the entropy of external random events.

No comments:

Post a Comment