Random number generator
File: random.doc
Last edition: 2003-03-19
Author: Anders Wallenborg
History: 96-02-11/MK First released version.
96-10-02/MK Updated to Menta 1.20
97-08-15/MK Updated to Menta 3.0
2003-03-19/MK Updated to Menta 4.0
Description
A pseudo-random number generator based on the following multiplicative congruential algorithm due to D.H. Lehmer:
x(k+1) = (a*x(k)+c) mod m
where x, a, c and m are integers. With a proper choice of integers the numbers
r(k) = x(k)/m
have a uniform distribution in the range [0, 1].
If m = 2**n, c is odd and a is of the form 4k+1, the first m-1 terms in the sequence x(k) are a permutation of the integers from 1 to m-1, and then the sequence repeats itself.
References:
Moler Cleve: "Random thoughts". MATLAB News and Notes, Fall 1995.
Fröberg, Carl-Erik: "Numerical Mathematics - Theory and Computer Applications". Addison-Wesley (1985).
Park, S.K. and K.W. Miller: "Random number generators: Good ones are hard to find". (Comm ACM, vol. 32)
Inputs
Outputs
(Real) Random, 0-1.
Parameters
(Int) a 13
(Int) c 1
(Int) m 512
Public signals
(Real) Random