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: