Random Numbers

A sequence of pseudo random numbers can be generated by a computer algorithm, such as the Linear Congruential Method. Such sequences are not random, since each number is completely determined from a set of numerical seeds. The sequences "appear" to be random, however, and are useful in calculations and simulations. The following Java applet demonstrates random number generation with the Linear Congruential Method. You can change the multiplier (a), modulus (m), and the initial seed (I). The algorithm produces random numbers between 0 and 1. You can see the distribution of 5000 random numbers develop as they are produced, by pressing the Run button.

You may also choose from three ways to show the random number distributions:
1D: shows the frequency distribution of all random numbers as a histogram divided into 20 bins from 0 to 1.
2D: pairs of random numbers are used to define the coordinates of points in a plane.
3D: groups of three random numbers are used to specify the coordinates of points in 3 dimensional space. By dragging the mouse on the picture you can rotate your viewpoint. Dragging the mouse while holding down the shift key allows you to zoom in and out.

The initial choices of multiplier and modulus are that of the RANDU generator, distributed by IBM in the 1960's. Only after it was widely distributed was it noticed to have a serious problem when generating 3 dimensional points. See if you can see the Marsaglia effect in the 3D view, by rotating your viewpoint. Better behaviour results with a different multiplier, such as 69069.

A special thanks to Careton University for the creation of this applet
Click here to return to the main page
Click here to return to the list of math related applets