umontreal.iro.lecuyer.rng
Class MRG32k3a
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.RandomStreamBase
-
- umontreal.iro.lecuyer.rng.MRG32k3a
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CloneableRandomStream, RandomStream
public class MRG32k3a extends RandomStreamBase
Extends the abstract classRandomStreamBaseby 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. (SeeRandomStreamfor 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
Constructors Constructor and Description MRG32k3a()Constructs a new stream, initializes its seed Ig, sets Bg and Cg equal to Ig, and sets its antithetic switch to false.MRG32k3a(java.lang.String name)Constructs a new stream with an identifier name (used when printing the stream state).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description MRG32k3aclone()Clones the current generator and return its copy.long[]getState()Returns the current state Cg of this stream.voidresetNextSubstream()Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.voidresetStartStream()Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.voidresetStartSubstream()Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.static voidsetPackageSeed(long[] seed)Sets the initial seed for the class MRG32k3a to the six integers in the vector seed[0..5].voidsetSeed(long[] seed)Sets the initial seed Ig of this stream to the vector seed[0..5].java.lang.StringtoString()Returns a string containing the name and the current state Cg of this stream.java.lang.StringtoStringFull()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
-
-
-
-
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 bysetPackageSeedif 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(java.lang.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:RandomStreamReinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.- Specified by:
resetStartStreamin interfaceRandomStream- Specified by:
resetStartStreamin classRandomStreamBase
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its current substream: Cg is set to Bg.- Specified by:
resetStartSubstreamin interfaceRandomStream- Specified by:
resetStartSubstreamin classRandomStreamBase
-
resetNextSubstream
public void resetNextSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.- Specified by:
resetNextSubstreamin interfaceRandomStream- Specified by:
resetNextSubstreamin classRandomStreamBase
-
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 java.lang.String toString()
Returns a string containing the name and the current state Cg of this stream.- Specified by:
toStringin interfaceRandomStream- Specified by:
toStringin classRandomStreamBase- Returns:
- the state of the generator, formated as a string
-
toStringFull
public java.lang.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:
clonein interfaceCloneableRandomStream- Overrides:
clonein classRandomStreamBase- Returns:
- A deep copy of the current generator
-
-
DMelt 3.0 © DataMelt by jWork.ORG