random#
Note
See the Glossary for the meaning of the acronyms used in this guide.
rng.py#
A task plugin module for managing random number generators.
- init_rng(seed: int = - 1) Tuple[int, numpy.random._generator.Generator] [source]#
Constructs a new random number generator.
- Parameters
seed – A seed to initialize the random number generator. If the value is less than zero, then the seed is generated by pulling fresh, unpredictable entropy from the OS. The default is -1.
- Returns
A tuple containing the seed and the initialized random number generator. If a seed < 0 was passed as an argument, then the seed generated by the OS will be returned.
See also
sample.py#
A task plugin module for drawing random samples.
- draw_random_integer(rng: numpy.random._generator.Generator, low: int = 0, high: int = 2147483647) int [source]#
Returns a random integer from low (inclusive) to high (exclusive).
The integer is sampled from a uniform distribution.
- Parameters
rng – A random number generator returned by
init_rng()
.low – Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case this parameter is 0 and this value is used for high).
high – If not None, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None)
- Returns
A random integer.
See also
- draw_random_integers(rng: numpy.random._generator.Generator, low: int = 0, high: int = 2147483647, size: Optional[Union[int, Tuple[int, ...]]] = None) numpy.ndarray [source]#
Returns random integers from low (inclusive) to high (exclusive).
The integers are sampled from a uniform distribution.
- Parameters
rng – A random number generator returned by
init_rng()
.low – Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case this parameter is 0 and this value is used for high).
high – If not None, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if high=None).
size – The output shape of array. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If None, a single value is returned. The default is None.
- Returns
A size-shaped array of random integers.
See also