umontreal.iro.lecuyer.rng

## Class BakerTransformedStream

- java.lang.Object
- umontreal.iro.lecuyer.rng.BakerTransformedStream

- All Implemented Interfaces:
- RandomStream

public class BakerTransformedStreamextends Objectimplements RandomStream

This container class permits one to apply the baker's transformation to the output of any`RandomStream`

. It transforms each*u*∈[0, 1] into 2*u*if*u*<= 1/2 and 2(1 -*u*) if*u*> 1/2. The`nextDouble`

method will return the result of this transformation and the other`next...`methods are affected accordingly. Any instance of this class contains a`RandomStream`

called its base stream, used to generate its numbers and to which the transformation is applied. Any call to one of the`next...`methods of this class will modify the state of the base stream.The baker transformation is often applied when the

`RandomStream`

is actually an iterator over a point set used for quasi-Monte Carlo integration (see the`hups`package).

### Constructor Summary

Constructors Constructor and Description **BakerTransformedStream**(RandomStream stream)Constructs a new baker transformed stream, using the random numbers from the base stream`stream`.

### Method Summary

Methods Modifier and Type Method and Description `void`

**nextArrayOfDouble**(double[] u, int start, int n)Calls`nextArrayOfDouble (u, start, n)`for the base stream, then applies the baker transformation.`void`

**nextArrayOfInt**(int i, int j, int[] u, int start, int n)Fills up the array by calling`nextInt (i, j)`.`double`

**nextDouble**()Returns the baker transformation of`s.nextDouble()`where`s`is the base stream.`int`

**nextInt**(int i, int j)Generates a random integer in {*i*,...,*j*} via`nextDouble`

(in which the baker transformation is applied).`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}.`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}.`String`

**toString**()Returns a string starting with`"Baker transformation of "`and finishing with the result of the call to the`toString`method of the generator.

### Constructor Detail

#### BakerTransformedStream

public BakerTransformedStream(RandomStream stream)

Constructs a new baker transformed stream, using the random numbers from the base stream`stream`.

### Method Detail

#### resetStartStream

public void resetStartStream()

**Description copied from interface:**`RandomStream`

Reinitializes the stream to its initial state*I*_{g}:*C*_{g}and*B*_{g}are set to*I*_{g}.**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:*C*_{g}is set to*B*_{g}.**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:*N*_{g}is computed, and*C*_{g}and*B*_{g}are set to*N*_{g}.**Specified by:**`resetNextSubstream`

in interface`RandomStream`

#### toString

public String toString()

Returns a string starting with`"Baker transformation of "`and finishing with the result of the call to the`toString`method of the generator.**Specified by:**`toString`

in interface`RandomStream`

**Overrides:**`toString`

in class`Object`

- Returns:
- the state of the generator formated as a string

#### nextDouble

public double nextDouble()

Returns the baker transformation of`s.nextDouble()`where`s`is the base stream.**Specified by:**`nextDouble`

in interface`RandomStream`

- Returns:
- the next generated uniform

#### nextInt

public int nextInt(int i, int j)

Generates a random integer in {*i*,...,*j*} via`nextDouble`

(in which the baker transformation is applied).**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

#### nextArrayOfDouble

public void nextArrayOfDouble(double[] u, int start, int n)

Calls`nextArrayOfDouble (u, start, n)`for the base stream, then applies the baker transformation.**Specified by:**`nextArrayOfDouble`

in interface`RandomStream`

- Parameters:
`u`

- the array in which the numbers will be stored`start`

- the first index of`u`to be used`n`

- the number of random numbers to put in`u`

#### nextArrayOfInt

public void nextArrayOfInt(int i, int j, int[] u, int start, int n)

Fills up the array by calling`nextInt (i, j)`.**Specified by:**`nextArrayOfInt`

in interface`RandomStream`

- Parameters:
`i`

- the smallest possible integer to put in`u``j`

- the largest possible integer to put in`u``u`

- the array in which the numbers will be stored`start`

- the first index of`u`to be used`n`

- the number of random numbers to put in`u`

**SCaVis 2.1 © jWork.ORG**