vix.ing · top · new · best · stats

Random sampling with a reservoir

1985/03/01 by Jeffrey S. Vitter, Jeffrey Scott Vitter · 1,772 citations
Computer Science · Mathematics · #Algorithm #Algorithms and Data Compression #Computer science #Constant (computer programming) #Current (fluid) #Machine Learning and Algorithms #Margin (machine learning) #Markov Chains and Monte Carlo Methods #Mathematical optimization #Mathematics #Pascal (unit) #Sampling (signal processing)

paper · pdf · doi:10.1145/3147.3165

published in ACM Transactions on Mathematical Software 11(1), 37-57 (Association for Computing Machinery)

openalex publication_date 1985/03/01 · openalex created_date 2025/10/10 · openalex updated_date 2026/08/04

Abstract

We introduce fast algorithms for selecting a random sample of n records without replacement from a pool of N records, where the value of N is unknown beforehand. The main result of the paper is the design and analysis of Algorithm Z; it does the sampling in one pass using constant space and in O ( n (1 + log( N/n ))) expected time, which is optimum, up to a constant factor. Several optimizations are studied that collectively improve the speed of the naive version of the algorithm by an order of magnitude. We give an efficient Pascal-like implementation that incorporates these modifications and that is suitable for general use. Theoretical and empirical results indicate that Algorithm Z outperforms current methods by a significant margin.

Cited by

Related