aspartik.rng
class RNG:
#Random number generator
It is backed by a PCG64 random number generator implemented in Rust. Its
output is a part of the stability guarantee: for the same seed and the same
minor version of b3 it will always output the same stream of values.
It has a number of built-in methods, but it is primarily used by other
Aspartik modules (for example b3 and stats.distributions) as a
randomness source.
Pickling
This class supports pickling. It can be saved and then restored without losing its internal state.
def random_bool(self, /, ratio=0.5)
#Returns true with the probability of ratio
Exceptions
Will throw an exception if ratio is not in [0, 1].
def random_int(self, /, lower, upper)
#Returns a random integer in [lower, upper)
lower and higher must be between -2^63 and 2^63 - 1.
Exceptions
- If the arguments are out of bounds.
lower >= upper.
def random_float(self, /, lower=0.0, upper=1.0)
#Returns a random floating point number in [lower, upper]
Exceptions
- Throws an exception if
lower < upperisn't true. This means that neitherlowernoruppercan beNaN.