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

Extends the abstract class RandomStreamBase, thus implementing the. More...

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

Public Member Functions

 MRG31k3p ()
 Constructs a new stream, initialized to its seed, which is.
 MRG31k3p (String name)
 Constructs a new stream with the identifier name (used when formatting the stream state).
void setSeed (int seed[])
 Use of this method is strongly discouraged.
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:
int[] getState ()
 Returns the current state \(C_g\) of this stream.
MRG31k3p clone ()
 Clones the current generator and return its copy.
String toString ()
 Returns a string containing the current state of this stream.
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 (int seed[])
 Sets the initial seed for the class MRG31k3p to the six integers of 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, thus implementing the.

RandomStream interface indirectly. The backbone generator is the combined multiple recursive generator (CMRG) MRG31k3p proposed by L’Ecuyer and Touzin [130] , implemented in 32-bit integer arithmetic. This RNG has a period length of \(\rho\approx\) \(2^{185}\). The values of \(V\), \(W\) and \(Z\) are \(2^{62}\), \(2^{72}\) and \(2^{134}\) 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 = \pm2^q \pm2^r\). This permits a faster implementation than for arbitrary coefficients.

Definition at line 52 of file MRG31k3p.java.

Constructor & Destructor Documentation

◆ MRG31k3p() [1/2]

umontreal.ssj.rng.MRG31k3p.MRG31k3p ( )

Constructs a new stream, initialized to its seed, which is.

\(Z = 2^{134}\) steps away from the previous seed.

Definition at line 117 of file MRG31k3p.java.

◆ MRG31k3p() [2/2]

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

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

Parameters
namename of the stream

Definition at line 139 of file MRG31k3p.java.

Member Function Documentation

◆ clone()

MRG31k3p umontreal.ssj.rng.MRG31k3p.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 234 of file MRG31k3p.java.

◆ getState()

int[] umontreal.ssj.rng.MRG31k3p.getState ( )

Returns the current state \(C_g\) of this stream.

This is a vector of 6 integers represented. This method is convenient if we want to save the state for subsequent use.

Returns
the current state of the generator

Definition at line 225 of file MRG31k3p.java.

◆ nextValue()

double umontreal.ssj.rng.MRG31k3p.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 255 of file MRG31k3p.java.

◆ resetNextSubstream()

void umontreal.ssj.rng.MRG31k3p.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 213 of file MRG31k3p.java.

◆ resetStartStream()

void umontreal.ssj.rng.MRG31k3p.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 198 of file MRG31k3p.java.

◆ resetStartSubstream()

void umontreal.ssj.rng.MRG31k3p.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 204 of file MRG31k3p.java.

◆ setPackageSeed()

void umontreal.ssj.rng.MRG31k3p.setPackageSeed ( int seed[])
static

Sets the initial seed for the class MRG31k3p to the six integers of the vector seed[0..5].

This will be the initial state (or seed) of the next created stream. By default, if this method is not called, the first stream is created with the seed \((12345, 12345, 12345, 12345, 12345, 12345)\). If it is called, the first 3 values of the seed must all be less than \(m_1 = 2147483647\), and not all 0; and the last 3 values must all be less than \(m_2 = 2147462579\), and not all 0.

Parameters
seedarray of 6 elements representing the seed

Definition at line 155 of file MRG31k3p.java.

◆ setSeed()

void umontreal.ssj.rng.MRG31k3p.setSeed ( int seed[])

Use of this method is strongly discouraged.

Initializes the stream at the beginning of a stream with the initial seed seed[0..5]. This vector must satisfy the same conditions as in setPackageSeed. This method only affects the specified stream, all the others are not modified, so the beginning of the streams are no longer spaced

\(Z\) values apart. For this reason, this method should be used only in very exceptional situations; proper use of reset... and of the stream constructor is preferable.

Parameters
seedarray of 6 integers representing the new seed

Definition at line 182 of file MRG31k3p.java.

◆ toString()

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

Returns a string containing the current state of this stream.

Returns
the state of the generator formated as a string

Reimplemented from umontreal.ssj.rng.RandomStreamBase.

Definition at line 246 of file MRG31k3p.java.


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