Chapter Contents |
Previous |
Next |
CALL RANGAM |
Category: | Random Number |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
See Also |
Syntax |
CALL RANGAM(seed,a,x); |
Range: | seed < 231 - 1 |
Note: | If seed 0, the time of day is used to initialize the seed stream. |
Range: | a > 0 |
Details |
The CALL RANGAM routine updates seed and returns a variate x that is generated from a gamma distribution with parameter a.
By adjusting the seeds, you can force streams of variates to agree or disagree for some or all of the observations in the same, or in subsequent, DATA steps.
For a>1, an acceptance-rejection method (Cheng 1977) (See References) is used. For a 1, an acceptance-rejection method due to (Fishman 1978) (See References) is used.
Comparisons |
The CALL RANGAM routine gives greater control of the seed and random number streams than does the RANGAM function.
Examples |
This example uses the CALL RANGAM routine:
options nodate pageno=1 linesize=80 pagesize=60; data case; retain Seed_1 Seed_2 Seed_3 45; a=2; do i=1 to 10; call rangam(Seed_1,a,X1); call rangam(Seed_2,a,X2); X3=rangam(Seed_3,a); if i=5 then do; Seed_2=18; Seed_3=18; end; output; end; run; proc print; id i; var Seed_1-Seed_3 X1-X3; run;
The RANGAM Example shows the results.
The SAS System 1 i Seed_1 Seed_2 Seed_3 X1 X2 X3 1 1404437564 1404437564 45 1.30569 1.30569 1.30569 2 1326029789 1326029789 45 1.87514 1.87514 1.87514 3 1988843719 1988843719 45 1.71597 1.71597 1.71597 4 50049159 50049159 45 1.59304 1.59304 1.59304 5 802575599 18 18 0.43342 0.43342 0.43342 6 100573943 991271755 18 1.11812 1.32646 1.11812 7 1986749826 1437043694 18 0.68415 0.88806 0.68415 8 52428589 959908645 18 1.62296 2.46091 1.62296 9 1216356463 1225034217 18 2.26455 4.06596 2.26455 10 805366679 425626811 18 2.16723 6.94703 2.16723 |
Changing Seed_2 for the CALL RANGAM statement, when I=5, forces the stream of the variates for X2 to deviate from the stream of the variates for X1. Changing Seed_3 on the RANGAM function, however, has no effect.
See Also |
Function:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.