2 Random numbers

Index - - Contents - - Previous chapter - Next chapter - - Previous page - Next page

2.2 Pseudo random number generation

Most generators internally produce uniformly distributed integers Xi in (0,Xmax) which then are transformed to (0, 1) by ui := Xi/Xmax. To get uniform random numbers xi in the interval (a, b) we make the transformation
                xi := a + (b-a)ui
Often the generation has the functional form
                     Xi := f(C,Xi-1)
where C denotes some free parameters. In this case at most all the numbers [0 ... Xmax] can be generated in some order before the numbers will repeat. We then say that the period is Xmax+1, i.e., the maximal possible. For a given generator the order is then fixed, the only variable is the choice of starting number, the so called seed. If the period is not the maximal then the generator consists of a set of ordered sequences. Which sequence is chosen depends then on the seed. In order to be able to either repeat with the same or different random numbers it is therefore important that the user can provide the seed.

An example of a generator is the multiplicative congruential generator

               Xi := c1Xi-1 (mod c2)
where c2 is a suitable base (often 10 or 2) raised to some power. Xmax=c2-1 and the seed is X0. The number Y (mod c) is in [0,c-1] and is obtained by writing Y = nc + Y (mod c). (25 (mod 7) = 4 = 25 - 3x7).

Of course the quality of such pseudo random numbers depends on that only a small part of the sequence is used and that the numbers produced by using some specific seed have good random characteristics.

In some cases it might be possible to find the function fk(C,Xi) that in a single step gives the i+k:th number where k>1

                fk(C,Xi) = f(f(...(f(C,Xi))...)
Using the functional form fk(C,Xi), k=1,2,... for successive pseudo random numbers might help in finding such parameters C and seed which gives maximal length.

The choice of parameters C might also influence on the quality of the pseudo random numbers. The mathematics needed for such analysis is far from trivial and we will not dwell on this here but rather rely on quality generators developed by others.