Reservoir Sampling
An algorithm for uniformly randomly selecting k samples from a stream of unknown or very large size.
Method
The first k elements enter the reservoir; the i-th element replaces a random reservoir element with probability k/i.
Applications
Population study (survey sampling), auditing (transaction sampling), law (document review sampling), log analysis.
Advantages
O(k) space; exactly uniform; no need to know total size.
Limitations
Single-pass only; no backtracking; requires extension for stratified sampling. Not suitable for precise stratified or weighted sampling.
Alternatives
Stratified sampling, weighted reservoir sampling, priority sampling.
Editorial clarification
Source description reviewed against the method-specific reference. Volume ordering is editorial, not a measured ranking; advantages are conditional rather than benchmark results.
Sources
Educational reference only, not professional advice.
All algorithms