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.

Tuesday, January 12, 2010

Whats the big deal?

After wondering for a while on what could be my first post, I settled on this five month old story at the Mamooth Caves National Park, Kentucky.
On our way back from Atlanta, we stopped at Mamooth Caves, Kentucky. This was an unplanned visit. As it was already Post Meridian part of the day, we had to settle for the only cave trail available. The trail group was around twenty and we were guided by two Senior guides in their nice khaki uniforms. As we entered the cave, it was pitch dark. We had few dim Lantern to light the area. The trail was good, chilling, informative and so on. But the subject of this post is a fellow visitor who was in our group of twenty. I do not know her name. With my instincts, I can guess she was an elderly person in her sixties. She was in her white trouser and blue jacket wearing sunglasses. Her pet dog accompanied her. I started wondering, how can a old lady come for a cave trail. The cave was slippery, muddy with rocks and things like that. I can say that she was the most active visitor in the group. She touched the walls of the cave and felt them. She asked many interesting questions to the guides. It was a one mile trail which was slippery all the way. She was never exhausted. I appreciated her attitude towards the life. She still feels young enough to tour the places.
I came back home and almost never slept that night. I kept thinking about the lady. I think I have a lesson to learn from her. I kept thinking about her for the days that followed. Now the question comes... Whats the big deal ? A lady in her sixties being active is not worth an exaggeration... Yeah, may be... but let me tell you that she was blind in her two eyes !