robot-piglet ea1ca2e504 Intermediate changes 1 year ago
..
README.md b05913d1c3 Restoring authorship annotation for Aleksandr <ivansduck@gmail.com>. Commit 2 of 2. 2 years ago
__init__.py 9abfb1a53b Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2. 2 years ago
ya.make ea1ca2e504 Intermediate changes 1 year ago

README.md

Overview

Reservoir sampling is a family of randomized algorithms for choosing a simple random sample, without replacement, of k items from a population of unknown size n in a single pass over the items.

Example

In [1]: from library.python import reservoir_sampling

In [2]: reservoir_sampling.reservoir_sampling(data=range(100), nsamples=10)
Out[2]: [27, 19, 81, 45, 89, 78, 13, 36, 29, 9]