[−][src]Function reservoir_sampling::unweighted::l
pub fn l<I, T>(stream: I, sample: &mut [T]) where
I: Iterator<Item = T>,
An implementation of Algorithm L
(https://en.wikipedia.org/wiki/Reservoir_sampling#An_optimal_algorithm)
Parameters:
- Type implementing
std::iter::Iterator
as source, - Mutable array slice (i.e.
&mut [T]
) as sample array (i.e. where sampled data is stored)
Notes:
- In case iterator yields less than sample amount, sample will be filled as much as possible, and returned.
- This uses
rand::thread_rng
to provide RNG. To use your own RNG which implementsrand::RNG
, seereservoir_sampling::core