Generates pseudorandom numbers from a logarithmic distribution.
A — Parameter of
the logarithmic distribution. (Input)
A must be positive and
less than 1.0.
IR — Vector of length NR containing the random logarithmic deviates. (Output)
NR — Number of
random numbers to generate. (Input)
Default: NR = size (IR,1).
Generic: CALL RNLGR (A, IR [,…])
Specific: The specific interface name is S_RNLGR.
Single: CALL RNLGR (NR, A, IR)
Routine RNLGR generates pseudorandom numbers from a logarithmic distribution with parameter A. The probability function is
for x = 1, 2, 3, …, and 0 < a < 1.
The methods used are described by Kemp (1981) and depend on the value of A. If A is less than 0.95, Kemp’s algorithm LS, which is a “chop-down” variant of an inverse CDF technique, is used. Otherwise, Kemp’s algorithm LK, which gives special treatment to the highly probable values of 1 and 2, is used.
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, RNLGR is used to generate 5 pseudo-random deviates from a logarithmic distribution with parameter A equal to 0.3.
USE RNLGR_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER NR
PARAMETER (NR=5)
!
INTEGER IR(NR), ISEED, NOUT
REAL A
!
CALL UMACH (2, NOUT)
A = 0.3
ISEED = 123457
CALL RNSET (ISEED)
CALL RNLGR (A, IR)
WRITE (NOUT,99999) IR
99999 FORMAT (' Logarithmic (0.3) random deviates: ', 5I8)
END
Logarithmic (0.3) random deviates: 2 1 1 1 2
PHONE: 713.784.3131 FAX:713.781.9260 |