os-fast-reservoir

Python implementation of fast approximation reservioir sampling.


Keywords
reservoir-sampling, utility
License
MIT
Install
pip install os-fast-reservoir==0.2.4

Documentation

os-fast-reservoir

Build Status codecov PyPI - Python Version PyPI

Python implementation of fast approximation reservioir sampling.

Install

$ pip install os-fast-reservoir

Usage

  • 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

Algorithm

Unit Tests

$ tox

License

MIT licensed.