Python implementation of fast approximation reservioir sampling.
$ pip install os-fast-reservoir
- API
from os_fast_reservoir import ReservoirSampling
rs = ReservoirSampling(100)
for i in range(1000):
rs.sample(i)
for i in rs:
print i
- Command line
$ os-fast-reservoir -h
usage: os-fast-reservoir [-h] [-v] [-f FILES [FILES ...]] -n NUM
Reservoir sample tool.
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-f FILES [FILES ...], --files FILES [FILES ...]
files to be sampled (default: stdin)
-n NUM, --num NUM sample number
- Reservoir sampling
- Faster Random Samples With Gap Sampling
- Very Fast Reservoir Sampling
- Another implementation: alexprengere/reservoir
$ tox
MIT licensed.