The Rand structure implements a simple linear congruential random number generator with a uniform distribution. It is based on the one described in Paulson's book (pp. 170-171), which is derived from the article ``Random number generators: good ones are hard to find,'' by Stephen K. Park and Keith W. Miller, CACM 31 (1988), pp. 1192-1201. It also incorporates the changes suggested by Park and Miller in CACM 36 (1993), pp. 105-110. The generator has period 2(31)-1. The values returned by
mkRandom are 31-bit words in the range [
randMax]. In the current implementation,
randMin is 1.0 and
randMax is 2(31)-2.
type rand = Word31.word
val randMin : rand
val randMax : rand
val random : rand -> rand
val mkRandom : rand -> unit -> rand
val norm : rand -> real
val range : (int * int) -> rand -> int
randMax] using the seed r. Iteratively using the value returned by
randomas the next seed to
randomwill produce a sequence of pseudo-random numbers.
randMax], starting from the seed r.
randMax] to the range (0.0,1.0). This can be used in combination with
mkRandomto generate normalized real-valued random numbers.
range (i, j)
randMax] uniformly to the range [i,j]. This can be used in combination with
mkRandomto generate random numbers in a given integer range. This raises the exception Fail if j < i.
Last Modified May 6, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies