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.

Syntax

RANGAM ( seed,a )

Arguments

seed

  • is an integer. If seed 0, the time of day is used to initialize the seed stream.

  • Range: seed < 2 31 -1

  • See: 'Seed Values' on page 257 for more information about seed values

a

  • is a numeric shape parameter.

  • Range: a > 0

Details

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) (See 'References' on page 926) is used. For a 1, an acceptance-rejection method due to Fishman is used (1978, Algorithm G2) (See 'References' on page 926).

A gamma variate X with shape parameter ALPHA and scale BETA can be generated:

 x=beta*rangam(seed,alpha); 

If 2*ALPHA is an integer, a chi-square variate X with 2*ALPHA degrees of freedom can be generated:

 x=2*rangam(seed,alpha); 

If N is a positive integer, an Erlang variate X can be generated:

 x=beta*rangam(seed,N); 

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:

 y1=rangam(seed,alpha);  y2=rangam(seed,beta);  x=y1/(y1+y2); 

Comparisons

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

See Also

Call routine:

  • 'CALL RANGAM Routine' on page 371




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net