Generates pseudorandom numbers from a standard normal distribution using an inverse CDF method.
R — Vector of length NR containing the random standard normal deviates. (Output)
NR — Number of
random numbers to generate. (Input)
Default: NR = size (R,1).
Generic: CALL RNNOR (R [,…])
Specific: The specific interface names are S_RNNOR and D_RNNOR.
Single: CALL RNNOR (NR, R)
Double: The double precision name is DRNNOR.
Routine RNNOR generates pseudorandom numbers from a standard normal (Gaussian) distribution using an inverse CDF technique. In this method, a uniform (0,1) random deviate is generated and then the inverse of the normal distribution function is evaluated at that point, using the routine ANORIN (see Chapter 17, Probability Distribution Functions and Inverses;). This method is slower than the acceptance/rejection technique used in the routine RNNOA to generate standard normal deviates. Deviates from the normal distribution with mean XM and standard deviation XSTD can be obtained by scaling the output from RNNOR. The following statements (in single precision, using the routines SSCAL (IMSL MATH/LIBRARY) and SADD (IMSL MATH/LIBRARY).) would yield random deviates from a normal (XM, XSTD**2) distribution.
USE IMSL_LIBRARIES
M
CALL
RNNOR (R, NR)
CALL
SSCAL (NR, XSTD,
R,
1)
CALL
SADD (NR, XM,
R,
1)
The routine RNSET can be used to initialize the seed of the random number generator. The routine RNOPT can be used to select the form of the generator.
In this example, RNNOR is used to generate five pseudorandom deviates from a standard normal distribution.
USE RNNOR_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER ISEED, NOUT, NR
REAL R(5)
!
CALL UMACH (2, NOUT)
NR = 5
ISEED = 123457
CALL RNSET (ISEED)
CALL RNNOR (R)
WRITE (NOUT,99999) R
99999 FORMAT (' Standard normal random deviates: ', 5F8.4)
END
Standard normal random deviates: 1.8279 -0.6412 0.7266 0.1747 1.0145
PHONE: 713.784.3131 FAX:713.781.9260 |