[A plot of successive random numbers (ri, ri+1) generated with the linear congruent method.]
The linear congruent random number generator (LCG) is a one of the oldest (but not the best) pseudorandom number generators. The method generates a sequence of integers xi over the interval [0, m-1] by the recurrence relation
where the modulus m is greater than zero, the multiplier a is less than m, and the increment c is less than m. All numbers are integers and all arithmetic is integer arithmetic. The initial value x0 is known as the seed.
If we want floating point numbers in the range [0,1), we divide the pseudorandom integers xi by m.
Remember to cast to xi to a floating point number before doing the division when implementing this algorithm on a computer.
The Random LCG Model was created by Wolfgang Christian using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool.
You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu. You must, of course, have EJS installed on your computer. Information about Ejs is available at: <http://www.um.es/fem/Ejs/> and in the OSP comPADRE collection <http://www.compadre.org/OSP/>.