blog/content/posts/2024-08-02-reservoir-sampling/index.md

733 B

title date draft description tags categories series favorite disable_feed mathjax
Reservoir Sampling 2024-08-02T18:30:56+01:00 false Elegantly sampling a stream
algorithms
python
programming
Cool algorithms
false false true

Reservoir Sampling is an online, probabilistic algorithm to uniformly sample k random elements out of a stream of values.

It's a particularly elegant and small algorithm, only requiring $\Theta(k)$ amount of space and a single pass through the stream.