RNNOR

Generates pseudorandom numbers from a standard normal distribution using an inverse CDF 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 RNNOR (R [])

Specific: The specific interface names are S_RNNOR and D_RNNOR.

FORTRAN 77 Interface

Single: CALL RNNOR (NR, R)

Double: The double precision name is DRNNOR.

Description

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 Function 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 (XMXSTD**2) distribution.

 

USE IMSL_LIBRARIES

CALL RNNOR (R, NR)

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, 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

Output

 

Standard normal random deviates: 1.8279 -0.6412 0.7266 0.1747 1.0145