RNTRI
Generates pseudorandom numbers from a triangular distribution on the interval (0, 1).
Required Arguments
R — Vector of length NR containing the random triangular deviates. (Output)
Optional Arguments
NR — Number of random numbers to generate. (Input)
Default: NR = size (R,1).
FORTRAN 90 Interface
Generic: CALL RNTRI (R [])
Specific: The specific interface names are S_RNTRI and D_RNTRI.
FORTRAN 77 Interface
Single: CALL RNTRI (NR, R)
Double: The double precision name is DRNTRI.
Description
Routine RNTRI generates pseudorandom numbers from a triangular distribution over the unit interval. The probability density function is f(x) = 4x, for 0  x  0.5, and f (x) = 4(1  x), for 0.5 < x  1. RNTRI uses an inverse CDF technique.
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, RNTRI is used to generate five pseudorandom deviates from a triangular distribution.
 
USE RNTRI_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 RNTRI (R)
WRITE (NOUT,99999) R
99999 FORMAT (' Triangular random deviates: ', 5F8.4)
END
Output
 
Triangular random deviates: 0.8700 0.3610 0.6581 0.5360 0.7215
Published date: 03/19/2020
Last modified date: 03/19/2020