5.3. Random Number Generator (RNG)
We have demonstrated the uses of random numbers in evaluating the integral of a function. Some fundamental aspects of RNG need to be discussed here. The RNG used in simulation is actually a pseudo-random number generator. A commonly applied method is the linear congruential method (Knuth, The art of computer programming, vol. – 2), although, many variation of this method are in use. Before using any RNG, the quality of the RNG needs to be tested. We need a RNG to generate a uniform random number between 0 and 1. Quality of the RNG refers to the uniformity of the distribution of random numbers between (0, 1) and the periodicity of the RNG. The periodicity refers to after how many random numbers; the sequence of the random numbers would be repeated. It also indicates the number of digits after the decimal point. For a RNG with low periodicity, repetition of a sequence can be expected when we generate large number of random numbers. It will cause severe problems in estimating the average properties, since it violates the randomness of the system.
We can test the quality of the RNG by the following way.
Generate large number of random numbers and segregate them in various bins according to predefined ranges. For example, let us dived the entire range (0,1) into thousand sub-ranges with equal span. Therefore, each bin will have a span of 0.001. It is summarized in the following table: