ostore.util
Class RandomExponential

java.lang.Object
  |
  +--java.util.Random
        |
        +--ostore.util.RandomExponential
All Implemented Interfaces:
Serializable

public class RandomExponential
extends Random

A utility class for generating random values from a negative exponential distribution. PDF( x ) = -lambda * exp( -lambda * x ). The mean and standard deviation are both 1/lambda.

Version:
$Id: RandomExponential.java,v 1.1 2003/04/19 00:55:41 strib Exp $
Author:
Dennis Geels
See Also:
Serialized Form

Constructor Summary
RandomExponential(double lambda)
           
RandomExponential(double lambda, long seed)
           
 
Method Summary
static void main(String[] args)
           
 double nextExponential()
          Returns a positive number drawn pseudo-randomly from the exponential distribution with parameter this.lambda.
 
Methods inherited from class java.util.Random
next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomExponential

public RandomExponential(double lambda)

RandomExponential

public RandomExponential(double lambda,
                         long seed)
Method Detail

main

public static void main(String[] args)

nextExponential

public double nextExponential()
Returns a positive number drawn pseudo-randomly from the exponential distribution with parameter this.lambda.

This method uses the "inverse transform" method. Given a number u drawn uniformly at random from the interval [0,1), we calculate a value x from our distribution as x = (-1/lambda) * log( 1 - u ) .