[−][src]Struct wheel_resample::Resampler
The Resampler can be turned into an Iterator to contineously pull sample indices
Example
use wheel_resample::Resampler; let mut rng = rand::thread_rng(); let weights = [0.1, 0.2, 0.3, 0.8]; let resampler = Resampler::new(&mut rng, &weights); let population = vec![1, 2, 3, 4]; let samples = resampler.into_iter().take(4).map(|i| population[i].clone()).collect::<Vec<u32>>(); // Make sure we got four samples assert_eq!(samples.len(), 4); // Make sure all samples come from the population assert!(samples.iter().all(|s| population.contains(s)));
Methods
impl<'a, R: Rng, W: Float> Resampler<'a, R, W>
[src]
pub fn new(rng: &'a mut R, weights: &'a [W]) -> Self
[src]
Create Resampler instance from random generator and weights
Trait Implementations
impl<'a, R: Rng, W: SampleUniform + Float> IntoIterator for Resampler<'a, R, W>
[src]
Auto Trait Implementations
impl<'a, R, W> RefUnwindSafe for Resampler<'a, R, W> where
R: RefUnwindSafe,
W: RefUnwindSafe,
R: RefUnwindSafe,
W: RefUnwindSafe,
impl<'a, R, W> Send for Resampler<'a, R, W> where
R: Send,
W: Sync,
R: Send,
W: Sync,
impl<'a, R, W> Sync for Resampler<'a, R, W> where
R: Sync,
W: Sync,
R: Sync,
W: Sync,
impl<'a, R, W> Unpin for Resampler<'a, R, W>
impl<'a, R, W> !UnwindSafe for Resampler<'a, R, W>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,