Use the following HTML code to embed the calculators within other websites:
Class LGM
This class produces good quality random numbers using the Lewis-Goodman-Miller algorithm.
It is best suited for simulations which require random sequences of length less than 10 million.
To give you an idea of the running time for each of the functions, here are the
results for generating 100,000,000 random numbers on a 750MHz microprocessor :
genReal() 11 seconds
genInt() 11 seconds
This diagram is obtained by generating two sequences of 1000 uniform floating point random numbers in the (0, 1) interval and then plotting them one versus the other. It shows that the distribution is indeed uniform.
References:
Numerical Recipes in C by Press, Flannery, Teukolsky, Vetterling published by the Cambridge University Press.
The Newran03 random number generator library of Robert Davies, http://www.robertnz.net/nr03doc.htm
Example 1
The following example displays 20 random floating point numbers and 20 random large integers.
It uses two different generators to achieve this. The first generator uses the system timer to
initialize the seed, while the second is simply initialized with a particular value.
Notice that it was necessary to divide the timer with the LGMDIV value in order to
keep the seed in the (0, 1) interval. The output of the first generator will obviously vary
with each execution of the program, while the output of the second will always be the same
if the seed is never changed.