Skip to main content

Distribution

Trait Distribution 

Source
pub trait Distribution<T> {
    // Required method
    fn sample(&self, rng: &mut Random) -> T;

    // Provided method
    fn samples<'a>(&'a self, rng: &'a mut Random) -> Iter<'a, Self, T> 
       where Self: Sized { ... }
}
Expand description

A distribution that can be sampled with a mutable Random.

T is the sample type - usually f64 for continuous distributions, u64 for integer ones, but any T is allowed.

Required Methods§

Source

fn sample(&self, rng: &mut Random) -> T

Draws one sample from self using rng.

Provided Methods§

Source

fn samples<'a>(&'a self, rng: &'a mut Random) -> Iter<'a, Self, T>
where Self: Sized,

Returns an iterator that calls sample repeatedly. Useful for take(n).collect()-style consumption.

Implementors§