Module utils

Module utils 

Source
Expand description

Utility functions for RNG operations

Functionsยง

choose
Choose a random element from a slice
fill_bytes
Fill a byte buffer with random data
gen_f32
Generate a random f32 in [0.0, 1.0)
gen_f64
Generate a random f64 in [0.0, 1.0)
gen_range
Generate a random value in the given range [low, high) - fallback without distributions
gen_range_f32
Generate a random f32 value in the given range [low, high) - fallback without distributions
gen_range_f64
Generate a random f64 value in the given range [low, high) - fallback without distributions
gen_range_u32
Generate a random u32 value in the given range [low, high) - fallback without distributions
gen_range_u64
Generate a random u64 value in the given range [low, high) - fallback without distributions
sample
Sample n elements from a slice (without replacement)
shuffle
Shuffle a slice in place using Fisher-Yates algorithm
weighted_choose
Weighted random selection