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 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.