org.omegahat.Simulation.RandomGenerators
Class CollingsPRNG

java.lang.Object
  |
  +--org.omegahat.Simulation.RandomGenerators.NotifyingPRNG
        |
        +--org.omegahat.Simulation.RandomGenerators.CollingsPRNG
All Implemented Interfaces:
PRNG, java.lang.Runnable

public class CollingsPRNG
extends NotifyingPRNG
implements PRNG

provide a stream of pseudo-random numbers using Collings Parallel Pseudo Random Number Generator.


Field Summary
(package private)  int[] ComponentMult
          Multiplicative constants for component generators
(package private)  int[] ComponentSeed
          Seeds for component generators
 boolean debug
          if true, show debugging messages
(package private)  int MixerMult
          Multiplicative constant for mixing generator
(package private)  int MixerSeed
          Seed for mixing generator
(package private) static int Mod
          Modulus constant for all generators
(package private)  int NumGen
          Number of generators in the pool
 
Fields inherited from class org.omegahat.Simulation.RandomGenerators.NotifyingPRNG
listeners
 
Constructor Summary
CollingsPRNG(int in_NumGen, int in_MixerMult, int in_MixerSeed, int[] in_ComponentMult, int[] in_ComponentSeed)
          Instantiate from state details (needed for CORBA).
CollingsPRNG(PRNGState state)
          instantiate from a specified PRNGState
 
Method Summary
 double getDoubleEpsilon()
          Return the minimum possible difference between two generated double's.
 int getIntRange()
          Return the largest int value returned by nextInt<\b>.
 PRNGState getState()
          Return an object describing the state of the PRNG.
static void main(java.lang.String[] argv)
          To test, generate 10 integers
private  int multCong(int seed, int mult, int mod)
          Compute next value using multiplicative congruential formula.
(package private)  double nextComponentDouble(int which)
          Generate a double on [0,1] using pool generator which.
(package private)  int nextComponentInt(int which)
          Generate an int using pool generator which.
 double nextDouble()
          Generate a single pseudo-random double on [0,1)
 double[] nextDoubleArray(int num)
          Generate num pseudo-random doubles on (0,1]
 int nextInt()
          Generate a single pseudo-random integer
 int[] nextIntArray(int num)
          Generate num pseudo-random integers
(package private)  double nextMixerDouble()
          Generate a double on [0,1) using the mixing generator.
(package private)  int nextMixerInt()
          Generate an int using the mixing generator.
 
Methods inherited from class org.omegahat.Simulation.RandomGenerators.NotifyingPRNG
addListener, listeners, listeners, removeListener, run
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

debug

public boolean debug
if true, show debugging messages

NumGen

int NumGen
Number of generators in the pool

MixerMult

int MixerMult
Multiplicative constant for mixing generator

MixerSeed

int MixerSeed
Seed for mixing generator

ComponentMult

int[] ComponentMult
Multiplicative constants for component generators

ComponentSeed

int[] ComponentSeed
Seeds for component generators

Mod

static int Mod
Modulus constant for all generators
Constructor Detail

CollingsPRNG

public CollingsPRNG(PRNGState state)
instantiate from a specified PRNGState

CollingsPRNG

public CollingsPRNG(int in_NumGen,
                    int in_MixerMult,
                    int in_MixerSeed,
                    int[] in_ComponentMult,
                    int[] in_ComponentSeed)
Instantiate from state details (needed for CORBA).
Method Detail

getState

public PRNGState getState()
Description copied from interface: PRNG
Return an object describing the state of the PRNG. This state can be used to create another PRNG that has will generate the same stream of random numbers. This can be useful for reproducing simulation results.
Specified by:
getState in interface PRNG

getDoubleEpsilon

public double getDoubleEpsilon()
Description copied from interface: PRNG
Return the minimum possible difference between two generated double's.
Specified by:
getDoubleEpsilon in interface PRNG

getIntRange

public int getIntRange()
Description copied from interface: PRNG
Return the largest int value returned by nextInt<\b>. This value can be used to convert int's returned by nextInt to doubles uniformly distributed on the range [0,1).
Specified by:
getIntRange in interface PRNG

multCong

private int multCong(int seed,
                     int mult,
                     int mod)
Compute next value using multiplicative congruential formula. The next value is computed using the formula: X[t+1] = X[t] * mult % mod
Parameters:
seed - Seed value in [1, 2^31-1]
mult - Multiplicative constant
mod - Modulus

nextMixerInt

int nextMixerInt()
Generate an int using the mixing generator.

nextMixerDouble

double nextMixerDouble()
Generate a double on [0,1) using the mixing generator.

nextComponentInt

int nextComponentInt(int which)
Generate an int using pool generator which.
Parameters:
which - which of the generators in the pool should be used to compute the next pseudo-random deviate

nextComponentDouble

double nextComponentDouble(int which)
Generate a double on [0,1] using pool generator which.
Parameters:
which - which of the generators in the pool should be used to compute the next pseudo-random deviate

nextInt

public int nextInt()
Generate a single pseudo-random integer
Specified by:
nextInt in interface PRNG

nextIntArray

public int[] nextIntArray(int num)
Generate num pseudo-random integers
Specified by:
nextIntArray in interface PRNG
Parameters:
num - number of values to return
Returns:
an array of integers of length num

nextDouble

public double nextDouble()
Generate a single pseudo-random double on [0,1)
Specified by:
nextDouble in interface PRNG

nextDoubleArray

public double[] nextDoubleArray(int num)
Generate num pseudo-random doubles on (0,1]
Specified by:
nextDoubleArray in interface PRNG
Parameters:
num - number of values to return
Returns:
an array of doubles of length num

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
To test, generate 10 integers