Skip to main content

Module random

Module random 

Source
Expand description

Random number module - port of Modules/random.c

Provides access to kernel random sources for cryptographically secure random number generation.

Structs§

RandomState
Random number generator state

Functions§

fill_random_bytes
get_bounded_random
Get random integers bounded by max (exclusive) Uses Lemire’s algorithm for unbiased bounded random numbers
get_bounded_random_buffer
Fill buffer with bounded random integers
get_random_u32
Get a single random u32
get_random_u64
Get a single random u64
random_range
Generate a random integer in range [min, max]
random_real
Generate a random real number in [0, 1) using 53 bits of randomness
random_real_exclusive_zero
Generate a random real number in (0, 1] (exclusive 0, inclusive 1)
random_real_inclusive
Generate a random real number in [0, 1] (inclusive both ends)
shuffle
Shuffle a slice in place using Fisher-Yates algorithm
zrand_float
zrand_float math function implementation Returns a random floating-point number between 0 and 1
zrand_int
zrand_int math function implementation Arguments: upper (optional), lower (optional), inclusive (optional)