org.mymedialite.util
Class Random

java.lang.Object
  extended by java.util.Random
      extended by org.mymedialite.util.Random
All Implemented Interfaces:
java.io.Serializable

public class Random
extends java.util.Random

Draws random values from a normal distributed using a simple rejection method.

See Also:
Serialized Form

Constructor Summary
Random()
          Default constructor
Random(long seed)
          Creates a Random object initialized with a seed.
 
Method Summary
static Random getInstance()
          Gets the instance.
static void initInstance(long seed)
          Initializes the instance with a given random seed.
 double nextExp(double lambda)
          Get the next exp.
 int nextInt(int min, int max)
          Get a random number within a specified range.
 double nextNormal()
          Get the next number from the standard normal distribution.
 double nextNormal(double mean, double stdev)
          Draw the next number from a normal distribution.
 
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

Random

public Random()
Default constructor


Random

public Random(long seed)
Creates a Random object initialized with a seed.

Parameters:
seed - an integer for initializing the random number generator
Method Detail

initInstance

public static void initInstance(long seed)
Initializes the instance with a given random seed.

Parameters:
seed - a seed value

getInstance

public static Random getInstance()
Gets the instance. If it does not exist yet, it will be created.

Returns:
the singleton instance

nextInt

public int nextInt(int min,
                   int max)
Get a random number within a specified range.

Parameters:
min - the minimum of the range
max - the maximum of the range
Returns:
a random number within the specified range

nextExp

public double nextExp(double lambda)
Get the next exp.

Parameters:
lambda -

nextNormal

public double nextNormal()
Get the next number from the standard normal distribution.

Returns:
a random number drawn from the standard normal distribution

nextNormal

public double nextNormal(double mean,
                         double stdev)
Draw the next number from a normal distribution.

Parameters:
mean - mean of the Gaussian
stdev - standard deviation of the Gaussian
Returns:
a random number drawn from a normal distribution with the given mean and standard deviation