SSJ
V. labo.

umontreal.iro.lecuyer.rng
Class MRG31k3p

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

public class MRG31k3p
extends RandomStreamBase

MRG31k3p

Extends the abstract class RandomStreamBase, thus implementing the RandomStream interface indirectly. The backbone generator is the combined multiple recursive generator (CMRG) MRG31k3p proposed by L'Ecuyer and Touzin[#!rLEC00b!#], implemented in 32-bit integer arithmetic. This RNG has a period length of approximately 2185. The values of V, W and Z are 262, 272 and 2134 respectively. (See RandomStream for their definition.) The seed and the state of a stream at any given step are six-dimensional vectors of 32-bit integers. The default initial seed is (12345, 12345, 12345, 12345, 12345, 12345). The method nextValue provides 31 bits of precision.

The difference between the RNG of class MRG32k3a and this one is that this one has all its coefficients of the form a = ±2q±2r. This permits a faster implementation than for arbitrary coefficients. On a 32-bit computer, MRG31k3p is about twice as fast as MRG32k3a. On the other hand, the latter does a little better in the spectral test and has been more extensively tested.

See Also:
Serialized Form

Constructor Summary
MRG31k3p()
          .
MRG31k3p(String name)
          .
 
Method Summary
 MRG31k3p clone()
          .
 int[] getState()
          .
 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(int[] seed)
          .
 void setSeed(int[] seed)
          .
 String toString()
          Returns a string containing the current state of this stream.
 
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

MRG31k3p

public MRG31k3p()
. \begin{tabb}Constructs a new stream, initialized at its beginning.
 Its seed is $Z = 2^{134}$\ steps away from the previous seed.
 \end{tabb}


MRG31k3p

public MRG31k3p(String name)
. \begin{tabb}Constructs a new stream with the identifier \texttt{name}
 (used when formatting the stream state).
 \end{tabb}
namename of the stream

Method Detail

setPackageSeed

public static void setPackageSeed(int[] seed)
. \begin{tabb}Sets the initial seed for the class \texttt{MRG31k3p} to the six
 in...
 ...st 3 values must all be less than $m_2 =
 2147462579$, and not all 0.
 \end{tabb}
seedarray of 6 elements representing the seed


setSeed

public void setSeed(int[] seed)
. \begin{tabb}\emph{Use of this method is strongly discouraged}.
 Initializes the ...
 ...se of \texttt{reset...}
 and of the stream constructor is preferable.
 \end{tabb}
seedarray 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 int[] getState()
. \begin{tabb}Returns the current state $C_g$\ of this stream.
 This is a vector o...
 ...thod is convenient if we want to save the state for
 subsequent use.
 \end{tabb}
the current state of the generator


clone

public MRG31k3p clone()
. \begin{tabb}Clones the current generator and return its copy.
 \end{tabb}
A deep copy of the current generator

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

toString

public String toString()
Description copied from interface: RandomStream
Returns a string containing the current state 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

SSJ
V. labo.

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