2 releases
0.1.4 | Mar 19, 2020 |
---|---|
0.1.3 | Mar 19, 2020 |
0.1.1 |
|
0.1.0 |
|
#4 in #resample
8KB
93 lines
Library for drawing weighted samples from a population
Documentation and examples can be found here https://docs.rs/wheel-resample/
lib.rs
:
Re-sampling functions for weighted sampling
Example
use wheel_resample::resample;
let mut rng = rand::thread_rng();
let weights = [0.1, 0.2, 0.3, 0.8];
let population = vec![1, 2, 3, 4];
let samples = resample(&mut rng, &weights, &population);
assert_eq!(samples.len(), population.len());
// Make sure all samples are in the population
assert!(samples.iter().all(|s| population.contains(s)));
Dependencies
~1.7–2.4MB
~44K SLoC