Previous: utrrni Up: ../plot79_u.html Next: utrs1
REAL FUNCTION UTRRNO (JUNK) C$ (Normally-Distributed Pseudo-Random Number) C$ Return a normally-distributed pseudo-random number as the C$ function value. C$ C$ The integer argument, JUNK, is a dummy that is ignored. C$ C$ The numbers produced have zero mean and unit standard C$ deviation, often denoted N(0,1). They cluster around zero C$ with rapidly decreasing frequency of occurrence outside the C$ the interval -1.0 .. +1.0. In a test using 1000000 calls C$ to this function, 317485 absolute values exceeded 1.0, C$ 45751 exceeded 2.0, 2749 exceeded 3.0, 72 exceeded 4.0, 1 C$ exceeded 5.0, and none were larger than 6.0. C$ C$ To generate a sequence of normally distributed C$ pseudo-random numbers with mean mu and variance sigma**2, C$ N(mu,sigma**2), use sigma*UTRRNO(junk) + mu. C$ C$ Before calling this generator, call the function C$ UTRRNI(ISEED) once to initialize the sequence. C$ C$ Typical usage: C$ C$ REAL UTRRNI,UTRRNO,Z C$ INTEGER ISEED,I C$ C$ ISEED = 305 C$ Z = UTRRNI(ISEED) C$ C$ DO FOR I = 1,10 C$ Z = UTRRNO() C$ WRITE(*,*) Z C$ END FOR C$ C$ This code is essentially that given in the book C$ C$ David Kahaner, Cleve Moler, and Stephen Nash C$ Numerical Methods and Software C$ Prentice Hall, 1989 C$ ISBN 0-13-627258-4 C$ C$ as the functions RNOR() and RSTART(). It was originally C$ written on 15-Sep-1981 by David Kahaner and George C$ Marsaglia, and revised 19-Apr-1987. See also the article C$ by G. Marsaglia and ? Tsang, A Fast, Easily Implemented C$ Method for Sampling from Decreasing or Symmetric Unimodal C$ Density Functions", SIAM J SISC 1983. C$ C$ (23-Feb-1991)