Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
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 defines the RandomVariable interface. The RandomVariable interface provides the single property Next. Given an instance, say rv, of a class that implements the RandomVariable interface, repeated calls of the form
rv.Next;are expected to return successive elements of a pseudorandom sequence.
Program: RandomVariable interface.