Previous Page | Next Page

Functions and CALL Routines

CALL RANTRI Routine



Returns a random variate from a triangular distribution.
Category: Random Number

Syntax
Arguments
Details
Comparisons
Examples
See Also

Syntax

CALL RANTRI(seed,h,x);

Arguments

seed

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

Range: seed < 231 - 1
Note: If seed [le] 0, the time of day is used to initialize the seed stream.
See: Seed Values and Comparison of Seed Values in Random-Number Functions and CALL Routines for more information about seed values
h

is a numeric SAS value.

Range: 0<h<1
x

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


Details

The CALL RANTRI routine updates seed and returns a variate x generated from a triangular distribution on the interval (0,1) with parameter h, which is the modal value of the distribution.

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.

The CALL RANTRI routine uses an inverse transform method applied to a RANUNI uniform variate.

For a discussion and example of an effective use of the random number CALL routines, see Starting, Stopping, and Restarting a Stream.


Comparisons

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


Examples

This example uses the CALL RANTRI routine:

options pageno=1 ls=80 ps=64 nodate;

data u1(keep=x);
   seed = 104;
   do i = 1 to 5;
      call rantri(seed, .5, x); 
      output;
   end;
   call symputx('seed', seed);
run;

data u2(keep=x);
   seed = &seed;
   do i = 1 to 5;
      call rantri(seed, .5, x); 
      output;
   end;
run;

data all;
   set u1 u2;
   z = rantri(104, .5);
run;

proc print label;
   label x = 'Separate Streams' z = 'Single Stream';
run;

Output from the CALL RANTRI Routine

                                 The SAS System                                1

                                  Separate     Single
                           Obs     Streams     Stream

                             1     0.34359    0.34359
                             2     0.76466    0.76466
                             3     0.54269    0.54269
                             4     0.89384    0.89384
                             5     0.72311    0.72311
                             6     0.68763    0.68763
                             7     0.48468    0.48468
                             8     0.38467    0.38467
                             9     0.29881    0.29881
                            10     0.80369    0.80369

See Also

Functions:

RAND Function

RANTRI Function

Previous Page | Next Page | Top of Page