Generates pseudorandom numbers from a triangular distribution on the interval (0, 1).
R — Vector of length NR containing the random triangular deviates. (Output)
NR — Number of
random numbers to generate. (Input)
Default: NR = size (R,1).
Generic: CALL RNTRI (R [,…])
Specific: The specific interface names are S_RNTRI and D_RNTRI.
Single: CALL RNTRI (NR, R)
Double: The double precision name is DRNTRI.
Routine RNTRI
generates pseudorandom numbers from a triangular distribution over the unit
interval. The probability density function is f(x) = 4x,
for 0 ≤
x ≤
.5, and f (x) = 4(1 − x),
for .5 < x ≤ 1. RNTRI
uses an inverse CDF technique.
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, 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
Triangular random deviates: 0.8700 0.3610 0.6581 0.5360 0.7215
PHONE: 713.784.3131 FAX:713.781.9260 |