Skip to content

laser.core.random

laser.core.random

Functions for seeding and accessing the laser-core random number generator.

Using the seed() function here and the pseudo-random number generator (PRNG) returned from the prng() function in simulation code will guarantee that the same random number stream is generated and used during simulation runs using the same seed value (assuming no changes to code which add or remove PRNG calls or change the number of random draws requested). This is important for reproducibility and debugging purposes.

laser.core.random.get_seed()

Return the seed used to initialize the pseudo-random number generator.

Returns:

Name Type Description
uint32 uint32

The seed value used to initialize the random number generators.

laser.core.random.prng()

Return the global (to LASER) pseudo-random number generator.

laser.core.random.seed(seed)

Initialize the pseudo-random number generator with a given seed.

This function sets the global pseudo-random number generator (_prng) to a new instance of numpy's default random generator initialized with the provided seed. It also seeds Numba's per-thread random number generators with the same seed.

Parameters:

Name Type Description Default
seed int

The seed value to initialize the random number generators.

required

Returns:

Type Description
Generator

numpy.random.Generator: The initialized pseudo-random number generator.