Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous 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 class. The abstract RandomVariable class extends the abstract Object class introduced in Program gif. The RandomVariable class defines the property next. Given an instance, say rv, of a class derived from the RandomVariable class, repeated accesses to the next property are expected to return successive elements of a pseudorandom sequence.

   program33861
Program: Abstract RandomVariable class.




next up previous index

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