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

Exponentially Distributed Random Variables

Program gif defines the ExponentialRV class. This class generates exponentially distributed random numbers with a mean value of tex2html_wrap_inline68161. The mean value tex2html_wrap_inline68161 is specified in the constructor.

   program33618
Program: ExponentialRV class.

The ExponentialRV class generates a sequence of random numbers, tex2html_wrap_inline68165, exponentially distributed  on the interval tex2html_wrap_inline68167 and having a mean value tex2html_wrap_inline68161. The numbers are said to be exponentially distributed because the probability that tex2html_wrap_inline68165 falls between 0 and z is given by

displaymath68159

where tex2html_wrap_inline68177. The function p(x) is called the probability density function . Thus,

eqnarray33640

Notice that tex2html_wrap_inline68181 is a value between zero and one. Therefore, given a random variable, tex2html_wrap_inline68151, uniformly distributed between zero and one, we can obtain an exponentially distributed variable tex2html_wrap_inline68165 as follows:

  eqnarray33648

Note, if tex2html_wrap_inline68151 is uniformly distributed on (O,1), then so too is tex2html_wrap_inline68191. The implementation of the nextDouble method follows directly from Equation gif.


next up previous contents index

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