pub trait Random {
// Required methods
fn uniform_int(&self, min: i32, max: i32) -> i32;
fn uniform_real(&self, min: f64, max: f64) -> f64;
fn is_head_not_tails(&self) -> bool;
fn is_hit(&self, probability: f64) -> bool;
fn weighted(&self, weights: &[usize]) -> usize;
fn get_rng(&self) -> RandomGen;
}
Expand description
Provides the way to use randomized values in generic way.
Required Methods§
sourcefn uniform_int(&self, min: i32, max: i32) -> i32
fn uniform_int(&self, min: i32, max: i32) -> i32
Produces integral random value, uniformly distributed on the closed interval [min, max]
sourcefn uniform_real(&self, min: f64, max: f64) -> f64
fn uniform_real(&self, min: f64, max: f64) -> f64
Produces real random value, uniformly distributed on the closed interval [min, max)
sourcefn is_head_not_tails(&self) -> bool
fn is_head_not_tails(&self) -> bool
Flips a coin and returns true if it is “heads”, false otherwise.