Trait vrp_core::utils::Random[][src]

pub trait Random {
    fn get_rng(&self) -> StdRng;

    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 { ... } }
Expand description

Provides the way to use randomized values in generic way.

Required methods

fn get_rng(&self) -> StdRng[src]

Expand description

Returns RNG.

Loading content...

Provided methods

fn uniform_int(&self, min: i32, max: i32) -> i32[src]

Expand description

Produces integral random value, uniformly distributed on the closed interval [min, max]

fn uniform_real(&self, min: f64, max: f64) -> f64[src]

Expand description

Produces real random value, uniformly distributed on the closed interval [min, max)

fn is_head_not_tails(&self) -> bool[src]

Expand description

Flips a coin and returns true if it is “heads”, false otherwise.

fn is_hit(&self, probability: f64) -> bool[src]

Expand description

Tests probability value in (0., 1.) range.

fn weighted(&self, weights: &[usize]) -> usize[src]

Expand description

Returns an index from collected with probability weight. Uses exponential distribution where the weights are the rate of the distribution (lambda) and selects the smallest sampled value.

Loading content...

Implementors

Loading content...