SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.rng.MRG32k3a Class Reference

Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined multiple recursive generator (CMRG) MRG32k3a proposed by L’Ecuyer [145] , implemented in 64-bit floating-point arithmetic. More...

Inheritance diagram for umontreal.ssj.rng.MRG32k3a:
umontreal.ssj.rng.RandomStreamBase umontreal.ssj.rng.CloneableRandomStream umontreal.ssj.rng.RandomStream

Public Member Functions

 MRG32k3a ()
 Constructs a new stream, initializes its seed \(I_g\), sets.
 MRG32k3a (String name)
 Constructs a new stream with an identifier name (used when printing the stream state).
void setSeed (long seed[])
 Sets the initial seed \(I_g\) of this stream to the vector seed[0..5].
void resetStartStream ()
 Reinitializes the stream to its initial state \(I_g\): \(C_g\) and \(B_g\) are set to \(I_g\).
void resetStartSubstream ()
 Reinitializes the stream to the beginning of its current substream:
void resetNextSubstream ()
 Reinitializes the stream to the beginning of its next substream:
long[] getState ()
 Returns the current state \(C_g\) of this stream.
String toString ()
 Returns a string containing the name and the current state \(C_g\) of this stream.
String toStringFull ()
 Returns a string containing the name of this stream and the values of all its internal variables.
MRG32k3a clone ()
 Clones the current generator and return its copy.
Public Member Functions inherited from umontreal.ssj.rng.RandomStreamBase
void increasedPrecision (boolean incp)
 After calling this method with incp = true, each call to the RNG (direct or indirect) for this stream will return a uniform random number with more bits of precision than what is returned by nextValue, and will advance the state of the stream by 2 steps instead of 1 (i.e., nextValue will be called twice for each random number).
double nextDouble ()
 Returns a uniform random number between 0 and 1 from the stream.
void nextArrayOfDouble (double[] u, int start, int n)
 Calls nextDouble n times to fill the array u.
int nextInt (int i, int j)
 Calls nextDouble once to create one integer between i and j.
void nextArrayOfInt (int i, int j, int[] u, int start, int n)
 Calls nextInt n times to fill the array u.
String formatState ()
 Use the toString method.
String formatStateFull ()
 Use the toStringFull method.

Static Public Member Functions

static void setPackageSeed (long seed[])
 Sets the initial seed for the class MRG32k3a to the six integers in the vector seed[0..5].

Protected Member Functions

double nextValue ()
 This method should return the next random number (between 0 and 1) from the current stream.

Detailed Description

Extends the abstract class RandomStreamBase by using as a backbone (or main) generator the combined multiple recursive generator (CMRG) MRG32k3a proposed by L’Ecuyer [145] , implemented in 64-bit floating-point arithmetic.

This backbone generator has a period length of \(\rho\approx2^{191}\). The values of \(V\), \(W\), and

\(Z\) are \(2^{51}\), \(2^{76}\), and \(2^{127}\), 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)\).

Definition at line 46 of file MRG32k3a.java.

Constructor & Destructor Documentation

◆ MRG32k3a() [1/2]

umontreal.ssj.rng.MRG32k3a.MRG32k3a ( )

Constructs a new stream, initializes its seed \(I_g\), sets.

\(B_g\) and \(C_g\) equal to \(I_g\), and sets its antithetic switch to false. The seed \(I_g\) is equal to the initial seed of the package given by setPackageSeed(long[]) if this is the first stream created, otherwise it is \(Z\) steps ahead of that of the stream most recently created in this class.

Definition at line 120 of file MRG32k3a.java.

◆ MRG32k3a() [2/2]

umontreal.ssj.rng.MRG32k3a.MRG32k3a ( String name)

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

Parameters
namename of the stream

Definition at line 136 of file MRG32k3a.java.

Member Function Documentation

◆ clone()

MRG32k3a umontreal.ssj.rng.MRG32k3a.clone ( )

Clones the current generator and return its copy.

Returns
A deep copy of the current generator

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 272 of file MRG32k3a.java.

◆ getState()

long[] umontreal.ssj.rng.MRG32k3a.getState ( )

Returns the current state \(C_g\) 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

Definition at line 205 of file MRG32k3a.java.

◆ nextValue()

double umontreal.ssj.rng.MRG32k3a.nextValue ( )
protected

This method should return the next random number (between 0 and 1) from the current stream.

If the stream is set to the high precision mode (increasedPrecision(true) was called), then each call to nextDouble will call nextValue twice, otherwise it will call it only once.

Returns
a number in the interval (0,1)

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 285 of file MRG32k3a.java.

◆ resetNextSubstream()

void umontreal.ssj.rng.MRG32k3a.resetNextSubstream ( )

Reinitializes the stream to the beginning of its next substream:

\(N_g\) is computed, and \(C_g\) and \(B_g\) are set to \(N_g\).

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 193 of file MRG32k3a.java.

◆ resetStartStream()

void umontreal.ssj.rng.MRG32k3a.resetStartStream ( )

Reinitializes the stream to its initial state \(I_g\): \(C_g\) and \(B_g\) are set to \(I_g\).

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 178 of file MRG32k3a.java.

◆ resetStartSubstream()

void umontreal.ssj.rng.MRG32k3a.resetStartSubstream ( )

Reinitializes the stream to the beginning of its current substream:

\(C_g\) is set to \(B_g\).

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 184 of file MRG32k3a.java.

◆ setPackageSeed()

void umontreal.ssj.rng.MRG32k3a.setPackageSeed ( long seed[])
static

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 \(m_1 = 4294967087\), and not all 0; and the last 3 values must all be less than \(m_2 = 4294944443\), and not all 0.

Parameters
seedarray of 6 elements representing the seed

Definition at line 151 of file MRG32k3a.java.

◆ setSeed()

void umontreal.ssj.rng.MRG32k3a.setSeed ( long seed[])

Sets the initial seed \(I_g\) 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
seedarray of 6 integers representing the new seed

Definition at line 170 of file MRG32k3a.java.

◆ toString()

String umontreal.ssj.rng.MRG32k3a.toString ( )

Returns a string containing the name and the current state \(C_g\) of this stream.

Returns
the state of the generator, formated as a string

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 215 of file MRG32k3a.java.

◆ toStringFull()

String umontreal.ssj.rng.MRG32k3a.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

Definition at line 238 of file MRG32k3a.java.


The documentation for this class was generated from the following file: