Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Random Variables

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 gif 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.

   program33821
Program: RandomVariable interface.




next up previous contents index

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