SSJ  3.3.1 Stochastic Simulation in Java
TruncatedRandomStream Class Reference

Represents a container random stream generating numbers in an interval $$(a,b)$$ instead of in $$(0,1)$$, where $$0\le a < b \le1$$, by using the contained stream. More...

Inheritance diagram for TruncatedRandomStream:
[legend]
Collaboration diagram for TruncatedRandomStream:
[legend]

## Public Member Functions

TruncatedRandomStream (RandomStream stream, double a, double b)

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: $$C_g$$ is set to $$B_g$$.

void 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$$.

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. More...

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. More...

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. More...

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. More...

Public Member Functions inherited from RandomStream
String toString ()
Returns a string containing the current state of this stream. More...

## Detailed Description

Represents a container random stream generating numbers in an interval $$(a,b)$$ instead of in $$(0,1)$$, where $$0\le a < b \le1$$, by using the contained stream.

If nextDouble returns $$u$$ for the contained stream, it will return $$v = a + (b-a)u$$, which is uniform over $$(a,b)$$, for the truncated stream. The method nextInt returns the integer that corresponds to $$v$$ (by inversion); this integer is no longer uniformly distributed in general.

## ◆ nextArrayOfDouble()

 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.

Parameters
 u array that will contain the generated uniforms start starting index, in the array u, to write uniforms from n number of uniforms to generate

Implements RandomStream.

## ◆ nextArrayOfInt()

 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.

(Calls nextInt n times.)

Parameters
 i smallest integer that can be generated j greatest integer that can be generated u array that will contain the generated values start starting index, in the array u, to write integers from n number of values being generated

Implements RandomStream.

## ◆ nextDouble()

 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.

The generators programmed in SSJ never return the values 0 or 1.

Returns
the next generated uniform

Implements RandomStream.

## ◆ nextInt()

 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.

(Calls nextDouble once.)

Parameters
 i smallest integer that can be generated j greatest integer that can be generated
Returns
the generated integer

Implements RandomStream.

The documentation for this class was generated from the following file:
• TruncatedRandomStream.java