jsim.variate
Class LCGRandom

java.lang.Object
  extended by jsim.variate.LCGRandom

public class LCGRandom
extends java.lang.Object

Basic random number generator. It is a multiplicative Linear Congruential Generator (LCG). The generator can be adjusted simply by changing the constants MULTIPIER and MODULUS (be careful). The complete generated stream of MODULUS numbers is split into MAX_STREAMS (stream from 0 to MAX_STREAMS - 1) by appropriate setting of the SEED array (again be careful).


Field Summary
static int MAX_STREAMS
           
 
Constructor Summary
LCGRandom(int stream)
          Constructs an LCG-based Random Number Generator.
 
Method Summary
 double gen()
          Generates a real-valued random number in the range 0 to 1.
 java.lang.Double[] getParameters()
          Get the parameters of the constuctor
 long igen()
          Generates an integer-valued random number in the range 0 to MODULUS - 1.
 void incrStream()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_STREAMS

public static final int MAX_STREAMS
See Also:
Constant Field Values
Constructor Detail

LCGRandom

public LCGRandom(int stream)
Constructs an LCG-based Random Number Generator.

Parameters:
stream - stream number (integer from 0 to MAX_STREAMS - 1)
Method Detail

incrStream

public void incrStream()

getParameters

public java.lang.Double[] getParameters()
Get the parameters of the constuctor


gen

public double gen()
Generates a real-valued random number in the range 0 to 1.

Returns:
double random number

igen

public long igen()
Generates an integer-valued random number in the range 0 to MODULUS - 1.

Returns:
long integer-valued random number