RNLGR
Generates pseudorandom numbers from a logarithmic distribution.
Required Arguments
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)
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (IR,1).
FORTRAN 90 Interface
Generic: CALL RNLGR (A, IR [, …])
Specific: The specific interface name is S_RNLGR.
FORTRAN 77 Interface
Single: CALL RNLGR (NR, A, IR)
Description
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.
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, 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
Output
Logarithmic (0.3) random deviates: 2 1 1 1 2