RNNOA
Generates pseudorandom numbers from a standard normal distribution using an acceptance/rejection method.
Required Arguments
R — Vector of length NR containing the random standard normal deviates. (Output)
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (R,1).
FORTRAN 90 Interface
Generic: CALL RNNOA (R [])
Specific: The specific interface names are S_RNNOA and D_RNNOA.
FORTRAN 77 Interface
Single: CALL RNNOA (NR, R)
Double: The double precision name is DRNNOA.
Description
Routine RNNOA generates pseudorandom numbers from a standard normal (Gaussian) distribution using an acceptance/rejection technique due to Kinderman and Ramage (1976). In this method, the normal density is represented as a mixture of densities over which a variety of acceptance/rejection methods due to Marsaglia (1964), Marsaglia and Bray (1964), and Marsaglia, MacLaren, and Bray (1964) are applied. This method is faster than the inverse CDF technique used in RNNOR 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 RNNOA. The following statements (in single precision) would yield random deviates from a normal (XMXSTD**2) distribution.
 
CALL RNNOA (NR, R)
CALL SSCAL (NR, XSTD, R, 1)
CALL SADD (NR, XM, R, 1)
Comments
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.
Example
In this example, RNNOA is used to generate five pseudorandom deviates from a standard normal distribution.
 
USE RNNOA_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 RNNOA (R)
WRITE (NOUT,99999) R
99999 FORMAT (' Standard normal random deviates: ', 5F8.4)
END
Output
 
Standard normal random deviates: 2.0516 1.0833 0.0826 1.2777 -1.2260