CALL RANPOI Routine


Returns a random variate from a Poisson distribution

Category: Random Number

Syntax

CALL RANPOI ( seed,m,x );

Arguments

seed

  • is the seed value. A new value for seed is returned each time CALL RANPOI is executed.

  • Range: seed < 2 31 -1

  • Note: If seed 0, the time of day is used to initialize the seed stream.

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

m

  • is a numeric mean parameter.

  • Range: m

x

  • is a numeric variable. A new value for the random variate x is returned each time CALL RANPOI is executed.

Details

The CALL RANPOI routine updates seed and returns a variate x that is generated from a Poisson distribution, with mean m .

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 m < 85, an inverse transform method applied to a RANUNI uniform variate is used (Fishman, 1976; see in 'References' on page 926). For m 85, the normal approximation of a Poisson random variable is used. To expedite execution, internal variables are calculated only on initial calls (that is, with each new m ).

Comparisons

The CALL RANPOI routine gives greater control of the seed and random number streams than does the RANPOI function.

Examples

This example uses the CALL RANPOI routine:

 options nodate pageno=1 linesize=80 pagesize=60;  data case;     retain Seed_1 Seed_2 Seed_3 45;     m=120;     do i=1 to 10;        call ranpoi(Seed_1,m,X1);        call ranpoi(Seed_2,m,X2);        X3=ranpoi(Seed_3,m);        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 following output shows the results:

Output 4.11: The RANPOI Example
start example
 The SAS System                                       1    i         Seed_1             Seed_2    Seed_3      X1        X2        X3    1       1404437564       1404437564      45       111       111       111    2       1445125588       1445125588      45       119       119       119    3       1326029789       1326029789      45       110       110       110    4       1988843719       1988843719      45       133       133       133    5       2137808851               18      18       138       138       138    6       1233028129        991271755      18       115       104       115    7         50049159       1437043694      18       135       110       135    8        802575599        959908645      18       102       109       102    9        100573943       1225034217      18       137       113       137   10        414117170        425626811      18       121       122       121 
end example
 

Changing Seed_2 for the CALL RANPOI 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 RANPOI function, however, has no effect.

See Also

Function:

  • 'RANPOI Function' on page 781




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