From:	SCOVCB::GALVIN_FX    31-JAN-1989 09:03
To:	ARISIA::EVERHART
Subj:	

with text_io; use text_io;
with UTILITY; use UTILITY; 
with MATH; use MATH; 
with SIMULATION; use SIMULATION;
pragma ELABORATE (text_io, UTILITY, MATH, SIMULATION);

        ------
package RANDOM is
        ------

-- Limited Private Declarations :
-- ------------------------------

   type UNIFORM_FLOAT_RANDOM is limited private;
   type UNIFORM_INTEGER_RANDOM is limited private;
   type UNIFORM_BOOLEAN_RANDOM is limited private;
   type NORMAL_RANDOM is limited private;
   type POISSON_RANDOM is limited private;
   type EXPONENTIAL_RANDOM is limited private;
   type ERLANG_RANDOM is limited private;


-- Random Stream Creating Operators :
-- ----------------------------------

   -- Random stream creating procedures provide seeds with a 
   -- default value of 365437, which invokes the random deviate
   -- functions to re-assigning the seed with a 
   -- system-determined seed value.

   -- The seed is any positive integer less than 1.0 E +8 not
   -- divisible by 2 or 5.


   procedure CREATE_UNIFORM_FLOAT
            (FLOAT_STREAM : out UNIFORM_FLOAT_RANDOM;
             TITLE : in string;
             MIN_VALUE, MAX_VALUE : in float;
             SEED : in positive := 365437);

   procedure CREATE_UNIFORM_INTEGER
            (INTEGER_STREAM : out UNIFORM_INTEGER_RANDOM;
             TITLE : in string;
             MIN_VALUE, MAX_VALUE : in integer;
             SEED : in positive := 365437);

   procedure CREATE_UNIFORM_BOOLEAN
            (BOOLEAN_STREAM : out UNIFORM_BOOLEAN_RANDOM;
             TITLE : in string;
             PROPORTION_TRUE : in float;
             SEED : in positive := 365437);

   procedure CREATE_NORMAL
            (NORMAL_STREAM : out NORMAL_RANDOM;
             TITLE : in string;
             MEAN, STD_DEV, MIN_VALUE, MAX_VALUE : in float;
             SEED : in positive := 365437);

   procedure CREATE_POISSON
            (POISSON_STREAM : out POISSON_RANDOM;
             TITLE : in string;
             MEAN, MIN_VALUE, MAX_VALUE : in integer;
             SEED : in positive := 365437);

   procedure CREATE_EXPONENTIAL
            (EXPONENTIAL_STREAM : out EXPONENTIAL_RANDOM;
             TITLE : in string;
             MEAN, MIN_VALUE, MAX_VALUE : in float;
             SEED : in positive := 365437);

   procedure CREATE_ERLANG
            (ERLANG_STREAM : out ERLANG_RANDOM;
             TITLE : in string;
             NUM_OF_DEVIATES : in positive;
             MEAN, MIN_VALUE, MAX_VALUE : in float;
             SEED : in positive := 365437);


-- Sampling Operators :
-- --------------------

   function UNIFORM_FLOAT 
            (FLOAT_STREAM : in UNIFORM_FLOAT_RANDOM) 
            return float;

   function UNIFORM_INTEGER
            (INTEGER_STREAM : in UNIFORM_INTEGER_RANDOM)
            return integer;

   function UNIFORM_BOOLEAN
            (BOOLEAN_STREAM : in UNIFORM_BOOLEAN_RANDOM)
            return boolean;

   function NORMAL (NORMAL_STREAM : in NORMAL_RANDOM)
            return float;

   function POISSON (POISSON_STREAM : in POISSON_RANDOM)
            return integer;

   function EXPONENTIAL
            (EXPONENTIAL_STREAM : in EXPONENTIAL_RANDOM)
            return float;

   function ERLANG (ERLANG_STREAM : in ERLANG_RANDOM)
            return float;


-- Trace Operator :
-- ------------------------------------

   procedure SET_RANDOM_TRACE_OPTION (TRACE_OPTION : in UTILITY.OPTION);


-- Exception :
-- -----------

   RANDOM_VARIABLE_DOES_NOT_EXIST : exception;


-- Private Declarations :
-- ----------------------

private


   type UNIFORM_FLOAT_REC is
      record
         MIN_VALUE, DIFF : float;
         -- MIN_VALUE and MAX_VALUE are the lower and upper 
         -- bounds of a uniform random distribution upon which
         -- a pseudo-random deviate may be based.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type UNIFORM_FLOAT_RANDOM is access UNIFORM_FLOAT_REC;

   type UNIFORM_INTEGER_REC is
      record
         MIN_VALUE : integer;
         DIFF : float;
         -- MIN_VALUE and MAX_VALUE are the lower and upper 
         -- bounds of a random integer distribution upon which
         -- a pseudo-random number may be based.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type UNIFORM_INTEGER_RANDOM is access UNIFORM_INTEGER_REC;

   type BOOLEAN_REC is
      record
         PROPORTION_TRUE : float;
         -- PROPORTION_TRUE is the proportion of the time that
         -- a random deviate will be true.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type UNIFORM_BOOLEAN_RANDOM is access BOOLEAN_REC;

   type NORMAL_REC is
      record
         MEAN, STD_DEV, MIN_VALUE, MAX_VALUE : float;
         -- MEAN and STD_DEV are the mean and standard deviation
         -- of a normal (Gaussian) distribution.  MAX_VALUE and MIN_VALUE 
         -- are the empirical limits that a random deviate may have.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type NORMAL_RANDOM is access NORMAL_REC;

   type POISSON_REC is
      record
         MEAN, MIN_VALUE, MAX_VALUE : integer;
         -- MEAN is the mean, or expected value, of a random 
         -- variate from a Poisson distribution.  MAX_VALUE and
         -- MIN_VALUE are the lower and upper bounds of the 
         -- distribution from which pseudo-random deviates may
         -- be generated.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type POISSON_RANDOM is access POISSON_REC;

   type EXPONENTIAL_REC is
      record
         MEAN, MAX_VALUE, MIN_VALUE : float;
         -- MEAN is mean value that a random deviate from an
         -- exponential distribution.  MAX_VALUE and MIN_VALUE
         -- are the upper and lower bounds of an exponential 
         -- random distribution upon which a pseudo-random 
         -- number may be based.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type EXPONENTIAL_RANDOM is access EXPONENTIAL_REC;

   type ERLANG_REC is
      record
         MEAN, MIN_VALUE, MAX_VALUE : float;
         NUMBER_OF_DEVIATES : positive;
         -- MEAN is the mean of each of <NUMBER_OF_DEVIATES>
         -- exponential deviates.  MIN_VALUE and MAX_VALUE 
         -- define the lower and upper bounds of the random variable.
         SEED : float;
         -- SEED is the stream of seeds for this particular
         -- stream of random deviates.
         TITLE : UTILITY.CHAR_STRING;
      end record;
   type ERLANG_RANDOM is access ERLANG_REC;
   
end RANDOM;
