Blog Index Page 3

Selecting random elements from iterator (or list) using python with reservoir sampling algorithm

We briefly explain how to implemente the reservoir sampling algorithm with python to select random elements from a list of unknown size with O(n) complexity.