Generates pseudorandom numbers from a Student’s t distribution.
DF — Degrees of
freedom. (Input)
DF must be
positive.
R — Vector of length NR containing the random Student’s t deviates. (Output)
NR — Number of
random numbers to generate. (Input)
Default: NR = size (R,1).
Generic: CALL RNSTT (DF, R [,…])
Specific: The specific interface names are S_RNSTT and D_RNSTT.
Single: CALL RNSTT (NR, DF, R)
Double: The double precision name is DRNSTT.
Routine RNSTT generates pseudo-random numbers from a Student’s t distribution with DF degrees of freedom, using a method suggested by Kinderman, Monahan, and Ramage (1977). The method (“TMX” in the reference) involves a representation of the t density as the sum of a triangular density over (−2, 2) and the difference of this and the t density. The mixing probabilities depend on the degrees of freedom of the t distribution. If the triangular density is chosen, the variate is generated as the sum of two uniforms; otherwise, an acceptance/rejection method is used to generate a variate from the difference density.
For degrees of freedom less than 100, RNSTT requires approximately twice the execution time as routine RNNOA which generates pseudorandom normal deviates. The execution time of RNSTT increases very slowly as the degrees of freedom increase. Since for very large degrees of freedom the normal distribution and the t distribution are very similar, the user may find that the difference in the normal and the t does not warrant the additional generation time required to use RNSTT instead of RNNOA.
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, RNSTT is used to generate 5 pseudo-random t variates with 10 degrees of freedom.
USE RNSTT_INT
USE UMACH_INT
USE RNSET_INT
IMPLICIT NONE
INTEGER NR
PARAMETER (NR=5)
!
INTEGER ISEED, NOUT
REAL DF, R(NR)
!
CALL UMACH(2, NOUT)
DF = 10.0
ISEED = 123457
CALL RNSET(ISEED)
CALL RNSTT(DF, R)
WRITE(NOUT, 99999) R
99999 FORMAT (' t (10) random deviates: ', 5F8.4)
END
t (10) random deviates: 0.6152 1.1528 0.0881 1.3382 -0.9893
PHONE: 713.784.3131 FAX:713.781.9260 |