RandomStream

This class represents a pseudo-random stream, such as the one consumed by the Monte Carlo transport. The stream can be shifted forwards or backwards using the index attribute. By default, the stream is seeded using the system entropy.

Constructor

class RandomStream(seed=None)

The seed argument should be a 128-bit integer. If no seed is provided, a random value will be chosen using the system entropy.

Attributes

Note

The attributes below are both readable and writable. For instance, decreasing the index will rewind the pseudo-random stream.

RandomStream.index: int

The current index of the pseudo random stream.

RandomStream.seed: int

The initial seed of the pseudo random stream.

Note

Modifying the seed value resets the stream position (index) to 0. If a None seed value is set, a random value will be selected from the system entropy.

Methods

RandomStream.normal(shape=None)

Returns pseudo-random numbers that are distributed according to the Normal distribution. If the shape argument is not specified, the function will return a single float. Otherwise, it will return a numpy.ndarray of pseudo-random values with the specified shape.

RandomStream.uniform01(shape=None)

Returns pseudo-random numbers that are uniformly distributed over \((0,1)\). As above, depending on the shape argument, the function will return a single float or a numpy.ndarray.