RANGAM Function

Returns a random variate from a gamma distribution.

Category: Random Number
Tip: If you want to change the seed value during execution, you must use the CALL RANGAM routine instead of the RANGAM function.



Required Arguments


is a numeric constant, variable, or expression with an integer value. If seed ≤ 0, the time of day is used to initialize the seed stream.

Range seed < 231−1
See Seed Values for more information about seed values


is a numeric constant, variable, or expression that specifies the shape parameter.

Range a > 0


The RANGAM function returns a variate that is generated from a gamma distribution with parameter a. For a > 1, an acceptance-rejection method due to Cheng (1977) is used. (See References). For a ≤ 1, an acceptance-rejection method due to Fishman is used (1978, Algorithm G2) (See References).
A gamma variate X with shape parameter ALPHA and scale BETA can be generated:
If 2*ALPHA is an integer, a chi-square variate X with 2*ALPHA degrees of freedom can be generated:
If N is a positive integer, an Erlang variate X can be generated:
It has the distribution of the sum of N independent exponential variates whose means are BETA.
And finally, a beta variate X with parameters ALPHA and BETA can be generated:
For a discussion about seeds and streams of data, as well as examples of using the random-number functions, see Generating Multiple Variables from One Seed in Random-Number Functions.


The CALL RANGAM routine, an alternative to the RANGAM function, gives greater control of the seed and random number streams.

See Also

CALL Routines: