SSJ
V. 2.6.

umontreal.iro.lecuyer.rng
Class MRG32k3a

java.lang.Object
  extended by umontreal.iro.lecuyer.rng.RandomStreamBase
      extended by umontreal.iro.lecuyer.rng.MRG32k3a
All Implemented Interfaces:
Serializable, Cloneable, CloneableRandomStream, RandomStream

public class MRG32k3a
extends RandomStreamBase

Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined multiple recursive generator (CMRG) MRG32k3a proposed by L'Ecuyer, implemented in 64-bit floating-point arithmetic. This backbone generator has a period length of ρ = 2191. The values of V, W, and Z are 251, 276, and 2127, respectively. (See RandomStream for their definition.) The seed of the RNG, and the state of a stream at any given step, are six-dimensional vectors of 32-bit integers, stored in double. The default initial seed of the RNG is (12345, 12345, 12345, 12345, 12345, 12345).

See Also:
Serialized Form

Constructor Summary
MRG32k3a()
          Constructs a new stream, initializes its seed Ig, sets Bg and Cg equal to Ig, and sets its antithetic switch to false.
MRG32k3a(String name)
          Constructs a new stream with an identifier name (used when printing the stream state).
 
Method Summary
 MRG32k3a clone()
          Clones the current generator and return its copy.
 long[] getState()
          Returns the current state Cg of this stream.
 void resetNextSubstream()
          Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.
 void resetStartStream()
          Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.
 void resetStartSubstream()
          Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.
static void setPackageSeed(long[] seed)
          Sets the initial seed for the class MRG32k3a to the six integers in the vector seed[0..5].
 void setSeed(long[] seed)
          Sets the initial seed Ig of this stream to the vector seed[0..5].
 String toString()
          Returns a string containing the name and the current state Cg of this stream.
 String toStringFull()
          Returns a string containing the name of this stream and the values of all its internal variables.
 
Methods inherited from class umontreal.iro.lecuyer.rng.RandomStreamBase
formatState, formatStateFull, increasedPrecision, nextArrayOfDouble, nextArrayOfInt, nextDouble, nextInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MRG32k3a

public MRG32k3a()
Constructs a new stream, initializes its seed Ig, sets Bg and Cg equal to Ig, and sets its antithetic switch to false. The seed Ig is equal to the initial seed of the package given by setPackageSeed if this is the first stream created, otherwise it is Z steps ahead of that of the stream most recently created in this class.


MRG32k3a

public MRG32k3a(String name)
Constructs a new stream with an identifier name (used when printing the stream state).

Parameters:
name - name of the stream
Method Detail

setPackageSeed

public static void setPackageSeed(long[] seed)
Sets the initial seed for the class MRG32k3a to the six integers in the vector seed[0..5]. This will be the seed (initial state) of the first stream. If this method is not called, the default initial seed is (12345, 12345, 12345, 12345, 12345, 12345). If it is called, the first 3 values of the seed must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less than m2 = 4294944443, and not all 0.

Parameters:
seed - array of 6 elements representing the seed

setSeed

public void setSeed(long[] seed)
Sets the initial seed Ig of this stream to the vector seed[0..5]. This vector must satisfy the same conditions as in setPackageSeed. The stream is then reset to this initial seed. The states and seeds of the other streams are not modified. As a result, after calling this method, the initial seeds of the streams are no longer spaced Z values apart. For this reason, this method should be used only in very exceptional situations (I have never used it myself!); proper use of reset... and of the stream constructor is preferable.

Parameters:
seed - array of 6 integers representing the new seed

resetStartStream

public void resetStartStream()
Description copied from interface: RandomStream
Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.

Specified by:
resetStartStream in interface RandomStream
Specified by:
resetStartStream in class RandomStreamBase

resetStartSubstream

public void resetStartSubstream()
Description copied from interface: RandomStream
Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.

Specified by:
resetStartSubstream in interface RandomStream
Specified by:
resetStartSubstream in class RandomStreamBase

resetNextSubstream

public void resetNextSubstream()
Description copied from interface: RandomStream
Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.

Specified by:
resetNextSubstream in interface RandomStream
Specified by:
resetNextSubstream in class RandomStreamBase

getState

public long[] getState()
Returns the current state Cg of this stream. This is a vector of 6 integers. This method is convenient if we want to save the state for subsequent use.

Returns:
the current state of the generator

toString

public String toString()
Returns a string containing the name and the current state Cg of this stream.

Specified by:
toString in interface RandomStream
Specified by:
toString in class RandomStreamBase
Returns:
the state of the generator, formated as a string

toStringFull

public String toStringFull()
Returns a string containing the name of this stream and the values of all its internal variables.

Returns:
the detailed state of the generator, formatted as a string

clone

public MRG32k3a clone()
Clones the current generator and return its copy.

Specified by:
clone in interface CloneableRandomStream
Overrides:
clone in class RandomStreamBase
Returns:
A deep copy of the current generator

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.