Struct histogram_sampler::Sampler
[−]
[src]
pub struct Sampler { /* fields omitted */ }Used to sample values according to a histogram distribution.
See crate-level docs for details.
Use like:
let original_data = vec![ (bin, count), ]; let sampler = Sampler::from_bins(original_data, 10 /* bin width */); let mut rng = rand::thread_rng(); use rand::distributions::IndependentSample; println!("{}", sampler.ind_sample(&mut rng));
Methods
impl Sampler[src]
pub fn from_bins<I>(iter: I, bin_width: usize) -> Self where
I: IntoIterator<Item = (usize, usize)>, [src]
I: IntoIterator<Item = (usize, usize)>,
Create a new [Sampler] from the given input histogram where the bin width is bin_width.
Trait Implementations
impl Clone for Sampler[src]
fn clone(&self) -> Sampler[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Sampler[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl Sample<usize> for Sampler[src]
fn sample<R: Rng>(&mut self, rng: &mut R) -> usize[src]
Generate a random value of Support, using rng as the source of randomness. Read more
impl IndependentSample<usize> for Sampler[src]
fn ind_sample<R: Rng>(&self, rng: &mut R) -> usize[src]
Generate a random value.