MSfUnifRand


Routine

double MSfUnifRand (void)
void MSrandSeed (int seed)

Purpose

Generate a uniformly distributed pseudo-random value
Reseed the uniform pseudo-random value

Description

This routine generates uniformly distributed pseudo-random numbers. The multiplicative congruential method is used to generate integer pseudo-random numbers, is = (a*is) % m. The values a=16807 and m=2147483647 are used. These values have been shown to give good results. Further, the values generated are shuffled to give better serial correlation properties. The pseudo-random number generation routine is self initializing, but if a different sequence of pseudo-random values is desired, the routine MSrandSeed can be used to supply a starting (seed) value.

Reference:
W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery, "Numerical Recipes in C" (2nd ed.) (p. 280), Cambridge University Press, 1992.

Parameters

MSfUnifRand:
<- double MSfUnifRand
Uniform deviate with values between 0 and 1, exclusive of the end points.
MSrandSeed:
-> int seed
Seed value. A positive seed value sets the pseudo-random generation to a new sequence. A zero value sets the actual seed to a value based on the current time. The default sequence can be restarted by setting the seed value to 12345.

Author / revision

P. Kabal / Revision 1.18 2003/05/09

See Also

MSfGaussRand


Main Index libtsp