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
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.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RandomExponential
public RandomExponential(double lambda)
RandomExponential
public RandomExponential(double lambda,
long seed)
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 )
.