Struct random_choice::RandomChoice
[−]
[src]
pub struct RandomChoice<RNG: Rng> { /* fields omitted */ }
Methods
impl<RNG: Rng> RandomChoice<RNG>
[src]
fn new(rng: RNG) -> Self
Creates a new RandomChoice struct. @param rng the random number generator to use with this stuct.
fn random_choice_f64<'a, T>(
&mut self,
samples: &'a [T],
weights: &[f64],
n: usize
) -> Vec<&'a T>
&mut self,
samples: &'a [T],
weights: &[f64],
n: usize
) -> Vec<&'a T>
Chooses n samples by their weights. The greater their weights the more likely they get chosen.
@invariant sum of weights must not overflow. @param samples The to be selected samples @param weights Weights that get chosen by their weight/probability. One weight can be greater 1. @param n Number of randomly chosen samples by weight. @return randomly selected samples by their weights
fn random_choice_f32<'a, T>(
&mut self,
samples: &'a [T],
weights: &[f32],
n: usize
) -> Vec<&'a T>
&mut self,
samples: &'a [T],
weights: &[f32],
n: usize
) -> Vec<&'a T>