Papers
Topics
Authors
Recent
Search
2000 character limit reached

Weighted Reservoir Sampling

Updated 14 July 2026
  • Weighted Reservoir Sampling is a family of methods that maintain a fixed-size sample from data streams by assigning unequal selection probabilities based on item weights.
  • It includes both with-replacement schemes using skip-based formulations for efficiency and without-replacement approaches employing priority-based selections for variance optimality.
  • These methods support distributed and temporal adaptations, enabling unbiased aggregate estimation in applications like graph streaming, online learning, and real-time rendering.

Weighted reservoir sampling is a family of streaming and sublinear sampling methods that maintain a fixed-size sample from a sequentially observed population of unknown or very large size, while assigning unequal selection probabilities through item weights. In the literature, the term spans both weighted sampling with replacement and weighted sampling without replacement, and that distinction is substantive rather than terminological: most classical attention has focused on sampling without replacement, whereas weighted sampling with replacement has received comparatively less study (Meligrana, 2024). Across these regimes, weighted reservoir methods are used to preserve a bounded-memory synopsis while targeting objectives such as unbiased subset-sum estimation, low-variance aggregate estimation, distributed composability, temporal bias, or application-specific importance sampling.

1. Problem setting and basic distinctions

Reservoir sampling addresses the setting in which units are observed sequentially and the total population size is unknown in advance. The reservoir has fixed size mm, and the update rule must operate in one pass using bounded memory. In the weighted setting, each arriving unit ene_n carries a weight wnw_n, and the sampling design departs from uniformity by making selection probabilities depend on these weights (Meligrana, 2024).

Two regimes dominate the theory. In sampling with replacement, different reservoir positions may contain the same item, and each slot can be interpreted as an independent weighted draw from the stream prefix. In sampling without replacement, an item can appear at most once, and the design is typically expressed through inclusion probabilities, adjusted weights, or random priorities. The distinction matters algorithmically and statistically: weighted sampling without replacement is often preferable under skewed weight distributions because it yields broader representation and higher accuracy for the same sample size, whereas with-replacement schemes may be dominated by repeated selections of heavy items (Cohen et al., 2020).

A second distinction concerns the role of the reservoir. In some work the reservoir is a direct sample of raw items; in others it is a sketch, a bottom-kk synopsis, or a cache of keyed aggregates. A plausible implication is that “weighted reservoir sampling” is best understood as an umbrella design principle—bounded-memory unequal-probability sampling over streams—rather than as a single canonical algorithm.

2. Weighted sampling with replacement

A standard single-pass approach to weighted reservoir sampling with replacement adapts the A-Chao update rule. If WW denotes the cumulative weight seen so far and a new element ene_n arrives with weight wnw_n, then for each of the mm reservoir slots the algorithm replaces the current content by ene_n with probability

wnW.\frac{w_n}{W}.

This maintains the correct weighted-with-replacement law at each step (Meligrana, 2024).

For this regime, the main recent advance is a skip-based formulation. The key observation is that, as the stream grows, the ratio ene_n0 is often very small, so many arrivals produce no substitutions at all. Instead of testing every item against every slot, the algorithm samples the distance to the next successful substitution event. In the weighted case, the cumulative distribution function for the number of skips ene_n1 before the next substitution can be written as

ene_n2

and the number of substitutions at the selected event follows a truncated binomial law (Meligrana, 2024).

This weighted skip logic generalizes the unweighted skip-based method of Park et al. (2004). The resulting algorithm, denoted WRSWR_SKIP in the paper summary, reduces random-number generation and reservoir updates when the sample ratio is small. The reported complexity is close to ene_n3 when ene_n4, because work becomes proportional to the expected number of substitutions rather than to the full stream length. The same study states that the skip-based algorithm is faster than standard methods in non-streaming single-sample extraction when the sample ratio is approximately less than ene_n5 of the population (Meligrana, 2024).

The same paper also clarifies a recurrent point in the literature: the reduction of reservoir sampling with replacement to single-reservoir sampling without replacement requires care in the weighted case. It further gives a single-pass merging strategy for multiple streams that can be executed in parallel, extending weighted-with-replacement reservoirs beyond the single-stream setting (Meligrana, 2024).

3. Without replacement: priority, order, and variance-optimal schemes

Weighted reservoir sampling without replacement is commonly implemented through random keys or priorities. A standard construction assigns each item ene_n6 of weight ene_n7 a key

ene_n8

with ene_n9, and keeps the wnw_n0 items with the smallest keys. Equivalent order-sampling formulations use priorities such as wnw_n1 and retain the highest-priority items (Hübschle-Schneider et al., 2019, Ahmed et al., 2017). These constructions are central because they support streaming updates, composability, and Horvitz–Thompson-style estimation.

Priority- and order-based schemes have been adapted to richer stream objects. In graph streams, Graph Priority Sampling assigns each arriving edge a weight wnw_n2, a uniform random value wnw_n3, and a priority wnw_n4; the reservoir keeps the top-wnw_n5 edges and uses the resulting sample for unbiased triangle and wedge estimation (Ahmed et al., 2017). In keyed stream aggregation, Priority-Based Aggregation maintains one persistent random variable per cached key and supports unbiased estimates of per-key aggregates under a fixed reservoir size (Duffield et al., 2017).

A major theoretical benchmark is wnw_n6, which maintains a reservoir of at most wnw_n7 weighted items while achieving variance-optimal unbiased estimation of subset sums. Its target inclusion probabilities are

wnw_n8

where wnw_n9 is chosen so that kk0. The scheme is unbiased, enforces a hard capacity bound, guarantees non-positive covariances between adjusted weights, and minimizes the average variance of subset-sum estimators over all subsets of a given size—even against offline schemes tailored to the realized data (0803.0473).

Without-replacement designs have also been pushed into sketching regimes. Composable WOR kk1-sampling sketches use bottom-kk2 transforms together with heavy-hitters sketches such as CountSketch, support all kk3, and are the first such sample-sized sketches for the regime kk4 and for signed updates in the without-replacement setting (Cohen et al., 2020). This suggests a convergence between reservoir sampling and modern linear-sketch methodology: the reservoir is no longer only a stored subset, but also a composable synopsis.

4. Statistical properties, optimality, and common misconceptions

The statistical analysis of weighted reservoir methods depends sharply on the replacement regime. For weighted sampling without replacement, coupling arguments show that concentration guarantees familiar from with-replacement sampling can transfer under suitable monotonicity conditions. When weights and values are similarly ordered, the cumulative value from weighted sampling without replacement is below the with-replacement analogue in increasing convex order, so Chernoff-type upper-tail bounds carry over. For general weights, a sub-Gaussian concentration inequality is available with an explicit variance proxy kk5 (Ben-Hamou et al., 2016).

A notable caution in that same line of work is that the negative association familiar from the uniform without-replacement case does not generally extend to weighted sampling. That point corrects a common intuition: dependence in weighted without-replacement designs is not merely a weighted analogue of the uniform case, and direct coupling arguments can be necessary (Ben-Hamou et al., 2016).

Variance optimality has also been characterized at the algorithmic-design level. The kk6 scheme is explicitly presented as dominating previous stream-reservoir methods for subset-sum estimation quality, while retaining kk7 update time and supporting combination of samples from different streams (0803.0473). By contrast, with-replacement schemes remain useful when direct i.i.d.-style semantics or replacement-based estimators are desired, but they need not be optimal for coverage under skew.

A further misconception concerns robustness. For reservoir sampling in an adaptive adversarial stream, classical VC-dimension-based sample-size guarantees are insufficient even when the set system has VC-dimension kk8. Unweighted results show that robustness may require replacing the VC-dimension term by kk9, with reservoir size

WW0

for WW1-robustness (Ben-Eliezer et al., 2019). The weighted case was not directly analyzed there; a plausible implication is that weighted reservoir designs used in adversarial settings require comparable care rather than straightforward extrapolation from benign-stream theory.

5. Mergeability, distributed execution, and communication efficiency

Weighted reservoir sampling has a strong distributed and parallel strand because bounded-memory sampling is especially valuable when data arrive at many sites. For weighted sampling with replacement, the skip-based framework in "Investigating Methods for Weighted Reservoir Sampling with Replacement" includes a single-pass merging strategy that can be executed on multiple streams in parallel (Meligrana, 2024).

For weighted sampling without replacement, fully distributed algorithms based on mini-batches and local candidate reservoirs avoid central coordinators. One representative approach lets each processing element assign exponential keys WW2, maintain local BWW3-tree reservoirs, and periodically participate in a distributed selection of the global WW4-th smallest key as the new threshold (Hübschle-Schneider et al., 2019). Related work presents a communication-efficient, highly scalable distributed-memory approach to weighted and unweighted reservoir sampling, with experiments on up to WW5 nodes and WW6 cores showing good speedups (Hübschle-Schneider et al., 2019).

In the continuous distributed-stream model, message efficiency becomes the governing metric. For weighted sampling without replacement from distributed streams, a message-optimal algorithm uses precision sampling with exponential random variables, local filtering by thresholds and epochs, and level sets for heavy items. The expected message complexity is

WW7

where WW8 is total weight, WW9 is sample size, and ene_n0 is the number of sites (Jayaram et al., 2019). That result is paired with applications to residual heavy hitters and ene_n1 tracking, showing that weighted reservoir sampling can serve as an internal primitive for broader streaming analytics rather than as an end in itself.

Coordination across multiple weight assignments is another distributed generalization. Coordinated weighted samples use shared random seeds so that each assignment embeds a classic weighted sample, but the samples are positively correlated across assignments, enabling substantially tighter estimators for aggregates such as ene_n2 difference, minimum, and maximum than independent sketches permit (0906.4560).

6. Temporal bias, structured streams, and contemporary applications

A substantial extension of weighted reservoir ideas introduces time-dependent weights. Reservoir-based Temporally Biased Sampling (R-TBS) maintains exponentially decaying inclusion probabilities while imposing a hard sample-size bound. If item ene_n3 arrives at time ene_n4, its weight at time ene_n5 is

ene_n6

and the design invariant is

ene_n7

with ene_n8. R-TBS is described as the first reservoir-based scheme to provide both complete control over the decay rate and a guaranteed upper bound on the sample size under unknown and time-varying arrival rates (Hentschel et al., 2018).

Reservoir methods have also been adapted to structured objects rather than atomic items. RPS uses a weighted reservoir to sample patterns directly from streaming batch data, including sequential, weighted, and unweighted itemsets, and incorporates temporal damping through a global utility

ene_n9

with wnw_n0 (Diop et al., 2024). In keyed aggregation and graph streams, PBA and GPS show that weighted reservoir ideas can be fused with estimation problems over repeated keys or subgraph motifs rather than raw item frequencies (Duffield et al., 2017, Ahmed et al., 2017).

Recent application papers extend weighted reservoir sampling into optimization, rendering, and online learning. ReSWD integrates weighted reservoir sampling into Sliced Wasserstein Distance estimation to retain informative projection directions while remaining unbiased (Boss et al., 1 Oct 2025). A foveated-rendering method maintains per-pixel weighted reservoirs of perceptually relevant high-quality samples from previous frames and is reported to run in under wnw_n1 at 4K resolution (Cantory et al., 4 Oct 2025). In online learning, weighted reservoirs of intermediate classifiers are formed using survival time as the weight, stabilizing Passive-Aggressive and First-Order Sparse Online Learning without additional passes or growing memory (Wu et al., 2024).

Taken together, these developments show that weighted reservoir sampling has expanded from a classical stream-sampling primitive into a broader design pattern for bounded-memory unequal-probability selection. The unifying theme is still the reservoir—fixed storage under sequential arrival—but the operative notion of “weight” now includes raw item size, motif utility, temporal recency, optimization informativeness, perceptual relevance, and model stability.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Weighted Reservoir Sampling.