Section I: Introduction | Index | > > |
What's randomness?
It's a question without any easy answer. Generally, it means you should not be able to use the numbers that you have seen to predict which number will come next or to restrict the possibilities. For detailed discussion, please refer to chap 3.5 of [1].
Why do we need it?
We need to simulate randomness in computer very often. In numerical calculation, there is an important method called "Monte Carlo Methods", which relies greatly on the generation of random numbers. In online poker games, the designer has to simulate randomness in computer to shuffle cards.
Why it's not trivial?
Generating random numbers seems to be rather trivial at the first sight. Since it's very easy to list a dozen of methods which are randomly chosen and very hopefully will give random result.
The following paragraph is cited form [2]:
John von Neumann proposed using the following method as one of the first random number generators. Suppose we want to create eight-digit numbers. Begin with an eight-digit number X0, which we call the seed, and create the next integer in the sequence by getting the middle eight digits from X02. If X02 has less than 16 digits, we add some 0's to the left to make it have 16 digits. For instance, if X0 = 35385906, we find that X02 = 1252162343440836.
so that our next number is X1 = 16234344. If we repeat this a few times we get a sequence:
Xi | Xi2 | |
i=0 | 35385906 | 1252162343440836 |
i=1 | 16234344 | 0263553925110336 |
i=2 | 55392511 | 3068330274885121 |
i=3 | 33027488 | 1090814963590144 |
i=4 | 81496359 | 6641656530256881 |
i=5 | 65653025 | 4310319691650625 |
i=6 | 31969165 | 1022027510797225 |
i=7 | 02751079 | 0007568435664241 |
i=8 | 56843566 | 3231190995596356 |
Since it is difficult, at first glance, to find a pattern in these numbers, we may think that this is an appropriate way to find random numbers. In other words, we have created the illusion of randomness through a deterministic process. Further study shows, however, that this is not a good random number generator. Each term in the sequence depends only on its immediate predecessor and there are only a finite number of possible terms. This means that the sequence will inevitably repeat. The problem is that the sequence can get caught in relatively short cycles. For instance, if the number 31360000 appears in the sequence at some point, we end up with this number again after another 99 iterations and this cycle continues indefinitely.
The middle square method may give you the idea to ask the computer to perform a sequence of many, unrelated, random operations. In fact, Knuth constructed an algorithm that used 13 "peculiar" steps to produce the next number in a sequence of 10-digit numbers and found that it was a very poor way to generate random numbers.
So the generator has to be carefully designed to give nice result. The linear conguential generator introduced in the next two chapters is a very important and widely used generator and also a basic element in many other more complicated generators. It's first proposed by D.H. Lehmer in 1948.
Exercise 1.1: Construct a way of producing random number sequence, program it and see how it works. Save the output, you can use the method in section IV to test it later. |
Back to MEC Homepage | Back to Index | Next Section |