weiss.util
Class Random

java.lang.Object
  |
  +--weiss.util.Random

public class Random
extends java.lang.Object

Random number class, using a 31-bit linear congruential generator.


Constructor Summary
Random()
          Construct this Random object with initial state obtained from system clock.
Random(int initialValue)
          Construct this Random object with specified initial state.
 
Method Summary
static void main(java.lang.String[] args)
           
 double nextDouble()
          Return a pseudorandom double in the open range 0..1 and change the internal state.
 int nextInt()
          Return a pseudorandom int, and change the internal state.
 int nextInt(int high)
          Return a pseudorandom int in range [0..high), and change the internal state.
 int nextInt(int low, int high)
          Return an int in the closed range [low,high], and change the internal state.
 int nextIntWRONG()
          Return a pseudorandom int, and change the internal state.
 long nextLong()
          Return an long in the range [0, 2^62-1], and change the internal state.
 long nextLong(long low, long high)
          Return an long in the closed range [low,high], and change the internal state.
 double nextNegExp(double expectedValue)
          Return an double using a negative exponential distribution, and change the internal state.
 int nextPoisson(double expectedValue)
          Return an int using a Poisson distribution, and change the internal state.
static void permute(java.lang.Object[] a)
          Randomly rearrange an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Random

public Random()
Construct this Random object with initial state obtained from system clock.

Random

public Random(int initialValue)
Construct this Random object with specified initial state.
Parameters:
initialValue - the initial state.
Method Detail

nextInt

public int nextInt()
Return a pseudorandom int, and change the internal state.
Returns:
the pseudorandom int.

nextInt

public int nextInt(int high)
Return a pseudorandom int in range [0..high), and change the internal state.
Returns:
the pseudorandom int.

nextIntWRONG

public int nextIntWRONG()
Return a pseudorandom int, and change the internal state. DOES NOT WORK.
Returns:
the pseudorandom int.

nextDouble

public double nextDouble()
Return a pseudorandom double in the open range 0..1 and change the internal state.
Returns:
the pseudorandom double.

nextInt

public int nextInt(int low,
                   int high)
Return an int in the closed range [low,high], and change the internal state.
Parameters:
low - the minimum value returned.
high - the maximum value returned.
Returns:
the pseudorandom int.

nextLong

public long nextLong()
Return an long in the range [0, 2^62-1], and change the internal state.
Returns:
the pseudorandom long.

nextLong

public long nextLong(long low,
                     long high)
Return an long in the closed range [low,high], and change the internal state.
Parameters:
low - the minimum value returned.
high - the maximum value returned.
Returns:
the pseudorandom long.

nextPoisson

public int nextPoisson(double expectedValue)
Return an int using a Poisson distribution, and change the internal state.
Parameters:
expectedValue - the mean of the distribution.
Returns:
the pseudorandom int.

nextNegExp

public double nextNegExp(double expectedValue)
Return an double using a negative exponential distribution, and change the internal state.
Parameters:
expectedValue - the mean of the distribution.
Returns:
the pseudorandom double.

permute

public static final void permute(java.lang.Object[] a)
Randomly rearrange an array. The random numbers used depend on the time and day.
Parameters:
a - the array.

main

public static void main(java.lang.String[] args)