SSJ
V. 2.6.

## umontreal.iro.lecuyer.rng Class TruncatedRandomStream

```java.lang.Object umontreal.iro.lecuyer.rng.TruncatedRandomStream
```
All Implemented Interfaces:
RandomStream

`public class TruncatedRandomStreamextends Objectimplements RandomStream`

Represents a container random stream generating numbers in an interval (a, b) instead of in (0, 1), where 0 <= a < b <= 1, 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.

Constructor Summary
```TruncatedRandomStream(RandomStream stream, double a, double b)```

Method Summary
` 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.
` 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.
` 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.
` 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` `resetNextSubstream()`
Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.
` void` `resetStartStream()`
Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.
` void` `resetStartSubstream()`
Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface umontreal.iro.lecuyer.rng.RandomStream
`toString`

Constructor Detail

### TruncatedRandomStream

```public TruncatedRandomStream(RandomStream stream,
double a,
double b)```
Method Detail

### resetStartStream

`public void resetStartStream()`
Description copied from interface: `RandomStream`
Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.

Specified by:
`resetStartStream` in interface `RandomStream`

### resetStartSubstream

`public void resetStartSubstream()`
Description copied from interface: `RandomStream`
Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.

Specified by:
`resetStartSubstream` in interface `RandomStream`

### resetNextSubstream

`public void resetNextSubstream()`
Description copied from interface: `RandomStream`
Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.

Specified by:
`resetNextSubstream` in interface `RandomStream`

### nextDouble

`public double nextDouble()`
Description copied from interface: `RandomStream`
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.

Specified by:
`nextDouble` in interface `RandomStream`
Returns:
the next generated uniform

### nextArrayOfDouble

```public void nextArrayOfDouble(double[] u,
int start,
int n)```
Description copied from interface: `RandomStream`
Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.

Specified by:
`nextArrayOfDouble` in interface `RandomStream`
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

### nextInt

```public int nextInt(int i,
int j)```
Description copied from interface: `RandomStream`
Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream. (Calls nextDouble once.)

Specified by:
`nextInt` in interface `RandomStream`
Parameters:
`i` - smallest integer that can be generated
`j` - greatest integer that can be generated
Returns:
the generated integer

### nextArrayOfInt

```public void nextArrayOfInt(int i,
int j,
int[] u,
int start,
int n)```
Description copied from interface: `RandomStream`
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.)

Specified by:
`nextArrayOfInt` in interface `RandomStream`
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

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.