Routine ID: V109 | |
---|---|
Author(s): J.F. Chamayou, F. James | Library: MATHLIB |
Submitter: | Submitted: 01.07.1979 |
Language: Fortran | Revised: |
OBSOLETE
Please note that this routine has been obsoleted in CNL 218. Users are
advised not to use it any longer and to replace it in older programs.
No maintenance for it will take place and it will eventually disappear.
Suggested replacement: RNGAMA (V135)
RANGAM generates positive random numbers x according to the gamma distribution with positive parameter p, i.e., according to the density
A special case of this distribution is the -distribution.
Structure:
FUNCTION subprogram
User Entry Names: RANGAM
External References: NORRAN (V101), RNDM (V104),
NRAN (V105)
Usage:
Z = RANGAM(P)sets Z to a gamma-distributed random number for any real parameter . The value of P may vary from call to call without infuencing the efficiency.
Method:
For integral values of , the logarithm of the product of p uniform random numbers is used. For any value of p > 15, the Wilson-Hilferty approximation (a transformed normal distribution) is used. For all other p, Johnk's algorithm is used.
Notes:
The routine is fast for small integer values of p, and for p > 15, (one Gaussian random number and one square root, plus a few multiplications). Non-integral values of p < 15 are rather slow.
Examples:
CHI2 = 2*RANGAM(0.5*ND)sets CHI2 to a random number distributed as with ND degrees of freedom.