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

This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numbers and convenient tools to move around within and across these streams. More...

Inheritance diagram for umontreal.ssj.rng.RandomStream:
umontreal.ssj.hups.PointSetIterator umontreal.ssj.rng.AntitheticStream umontreal.ssj.rng.BakerTransformedStream umontreal.ssj.rng.CloneableRandomStream umontreal.ssj.rng.RandomStreamWithCache umontreal.ssj.rng.TruncatedRandomStream umontreal.ssj.stochprocess.InverseGaussianProcessMSH.NonRandomStream umontreal.ssj.hups.PointSet.DefaultPointSetIterator umontreal.ssj.rng.RandomStreamBase umontreal.ssj.hups.CachedPointSet.CachedPointSetIterator umontreal.ssj.hups.ContainerPointSet.ContainerPointSetIterator umontreal.ssj.hups.CycleBasedPointSet.CycleBasedPointSetIterator umontreal.ssj.hups.DigitalNet.DigitalNetIterator umontreal.ssj.hups.Rank1Lattice.Rank1LatticeIterator umontreal.ssj.hups.SortedAndCutPointSet.SortedAndCutPointSetIterator umontreal.ssj.mcqmctools.anova.SplitStream umontreal.ssj.rng.LFSR113 umontreal.ssj.rng.LFSR258 umontreal.ssj.rng.MRG31k3p umontreal.ssj.rng.MRG32k3a umontreal.ssj.rng.MRG32k3aL umontreal.ssj.rng.WELL512

Public Member Functions

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:
String toString ()
 Returns a string containing the current state of this stream.
double nextDouble ()
 Returns a (pseudo)random number from the uniform distribution over the interval \((0,1)\), using this stream, after advancing its state by one step.
void nextArrayOfDouble (double[] u, int start, int n)
 Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.
int nextInt (int i, int j)
 Returns a (pseudo)random number from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream.
void nextArrayOfInt (int i, int j, int[] u, int start, int n)
 Generates n (pseudo)random numbers from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream and stores the result in the array u starting at index start.

Detailed Description

This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numbers and convenient tools to move around within and across these streams.

The actual random number generators (RNGs) are provided in classes that implement this RandomStream interface. Each stream of random numbers is an object of the class that implements this interface, and can be viewed as a virtual random number generator.

For each type of base RNG (i.e., each implementation of the RandomStream interface), the full period of the generator is cut into adjacent streams (or segments) of length \(Z\), and each of these streams is partitioned into \(V\) substreams of length \(W\), where \(Z = VW\). The values of \(V\) and \(W\) depend on the specific RNG, but are usually larger than \(2^{50}\). Thus, the distance \(Z\) between the starting points of two successive streams provided by an RNG usually exceeds \(2^{100}\). The initial seed of the RNG is the starting point of the first stream. It has a default value for each type of RNG, but this initial value can be changed by calling setPackageSeed for the corresponding class. Each time a new RandomStream is created, its starting point (initial seed) is computed automatically, \(Z\) steps ahead of the starting point of the previously created stream of the same type, and its current state is set equal to this starting point.

For each stream, one can advance by one step and generate one value, or go ahead to the beginning of the next substream within this stream, or go back to the beginning of the current substream, or to the beginning of the stream, or jump ahead or back by an arbitrary number of steps. Denote by

\(C_g\) the current state of a stream \(g\), \(I_g\) its initial state, \(B_g\) the state at the beginning of the current substream, and \(N_g\) the state at the beginning of the next substream. The following diagram shows an example of a stream whose state is at the 6th value of the third substream, i.e., \(2W+5\) steps ahead of its initial state \(I_g\) and 5 steps ahead of its state \(B_g\). The form of the state of a stream depends on its type. For example, the state of a stream of class MRG32k3a is a vector of six 32-bit integers represented internally as floating-point numbers (in double).

The methods for manipulating the streams and generating random numbers are implemented differently for each type of RNG. The methods whose formal parameter types do not depend on the RNG type are specified in the interface

RandomStream. The others (e.g., for setting the seeds) are given only in the classes that implement the specific RNG types.

See [114], [118], [132]  for examples of situations where the multiple streams offered here are useful.

Methods for generating random variates from non-uniform distributions are provided in the umontreal.ssj.randvar package.

Definition at line 141 of file RandomStream.java.

Member Function Documentation

◆ nextArrayOfDouble()

void umontreal.ssj.rng.RandomStream.nextArrayOfDouble ( double[] u,
int start,
int n )

Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.

Parameters
uarray that will contain the generated uniforms
startstarting index, in the array u, to write uniforms from
nnumber of uniforms to generate

Implemented in umontreal.ssj.hups.PointSet.DefaultPointSetIterator, umontreal.ssj.rng.AntitheticStream, umontreal.ssj.rng.BakerTransformedStream, umontreal.ssj.rng.RandomStreamBase, umontreal.ssj.rng.RandomStreamWithCache, umontreal.ssj.rng.TruncatedRandomStream, and umontreal.ssj.stochprocess.InverseGaussianProcessMSH.NonRandomStream.

◆ nextArrayOfInt()

void umontreal.ssj.rng.RandomStream.nextArrayOfInt ( int i,
int j,
int[] u,
int start,
int n )

Generates n (pseudo)random numbers from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream and stores the result in the array u starting at index start.

(Calls nextInt n times.)

Parameters
ismallest integer that can be generated
jgreatest integer that can be generated
uarray that will contain the generated values
startstarting index, in the array u, to write integers from
nnumber of values being generated

Implemented in umontreal.ssj.hups.PointSet.DefaultPointSetIterator, umontreal.ssj.rng.AntitheticStream, umontreal.ssj.rng.BakerTransformedStream, umontreal.ssj.rng.RandomStreamBase, umontreal.ssj.rng.RandomStreamWithCache, umontreal.ssj.rng.TruncatedRandomStream, and umontreal.ssj.stochprocess.InverseGaussianProcessMSH.NonRandomStream.

◆ nextDouble()

◆ nextInt()

int umontreal.ssj.rng.RandomStream.nextInt ( int i,
int j )

Returns a (pseudo)random number from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream.

(Calls nextDouble once.)

Parameters
ismallest integer that can be generated
jgreatest integer that can be generated
Returns
the generated integer

Implemented in umontreal.ssj.hups.PointSet.DefaultPointSetIterator, umontreal.ssj.rng.AntitheticStream, umontreal.ssj.rng.BakerTransformedStream, umontreal.ssj.rng.LFSR113, umontreal.ssj.rng.LFSR258, umontreal.ssj.rng.RandomStreamBase, umontreal.ssj.rng.RandomStreamWithCache, umontreal.ssj.rng.TruncatedRandomStream, and umontreal.ssj.stochprocess.InverseGaussianProcessMSH.NonRandomStream.

◆ resetNextSubstream()

◆ resetStartStream()

◆ resetStartSubstream()

◆ toString()


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