7917592@TWNCTU01.BITNET (05/20/91)
Hello Netters: Anybody has the experience about using OCCAM2 random number generator? It seems to have 2 different kinds of return value:INT or REAL. under such circumstances, how can I decide what type of rendom number I get ? -Jason
COS99284@UFRJ.BITNET (Luiz Felipe Perrone) (05/25/91)
In response to Jason's question about TDS2 random number generator: The RAND function in TDS2 requires one INT parameter that it uses as the seed for its linear congruential algorithm and returns two values: one of INT type and one of REAL32 type. The INT result can be used as a random INT, but its true purpose is to serve as seed for the next call to RAND. The REAL32 value is the real numeric value that results from the RAND function. I have used the INT.value as a random number in a simulation program some time ago where I needed to choose a random number between 0 and 3 (therefore I had to use INT.value REM 4) and must tell you that I wasn't very much pleased with the results. The result clearly showed a tendency to be non-uniformly distributed. I'm not sure this resulted from the characteristics of the algorithm used in RAND or from my attempt to limit the range of the random number produced. If someone can explain this behaviour, please send me a note. ------------------------------------------------------------------------ Luiz Felipe Perrone MSc student - COPPE - Dept. of Systems Engineering and Computer Science Universidade Federal do Rio de Janeiro E-mail: COS99284@UFRJ (BITNET) ------------------------------------------------------------------------
erik@GOOFY.LLNL.GOV (Erik Johansson) (05/25/91)
I haven't used the random number generator in Occam2, so I can't really comment on it. However, my experience with system supplied random number generators on other machines has been less than wonderful. You might want to take the time to write your own. Using a linear congruential algorithm you can write integer and real uniform generators which are quite simple, yet machine independent. For the details, I refer you to the following articles: "Random Number Generators: Good Ones Are Hard to Find" S. K. Park and K. W. Miller, Communications of the ACM, October 1988, Vol 31, No 10, pp 1192 - 1201 "Efficient and Portable Combined Random Number Generators" P. L'Ecuyer, Communications of the ACM, June 1988, Vol 31, No 6, pp 742 - 749, 774 Erik Johansson