In this section we introduce the notion
of an abstract *random variable* .
In this context,
a random variable is an object that behaves
like a random number generator in that it produces
a pseudorandom number sequence.
The distribution of the values produced depends on the class
of random variable used.

Program declares several random variable classes.
The abstract `RandomVariable` class defines the shared interface.
A single, pure virtual member function is declared--`Sample`.
Given an instance, say `rv`,
of a concrete class derived from `RandomVariable`,
repeated calls of the form

rv.Sample ();are expected to return successive elements of a pseudorandom sequence.

**Program:** `RandomVariable`, `SimpleRV`, `UniformRV` and `ExponentialRV` Class Definitions

Program also declares three concrete random variable classes:

`SimpleRV`-
This class generates random numbers uniformly distributed
in the interval (0,1).
(It is merely a wrapper for the
`RandomNumberGenerator`defined in the preceding section). `UniformRV`-
This class generates random numbers which are uniformly distributed
in an arbitrary interval (
*u*,*v*), where*u**<**v*. The parameters*u*and*v*are specified in the constructor. `ExponentialRV`-
This class generates exponentially distributed random numbers
with a mean value of .
The mean value is specified in the constructor.

Copyright © 1997 by Bruno R. Preiss, P.Eng. All rights reserved.