Papers
Topics
Authors
Recent
Search
2000 character limit reached

Metric Reservoir Sampling Techniques

Updated 14 July 2026
  • Metric reservoir sampling is a family of bounded-memory algorithms that employ metric-driven criteria, such as weights, temporal decay, or confidence scores, instead of uniform random replacement.
  • These methods optimize unbiased variance estimates and support diverse applications including subset sum estimation, graph stream analysis, and continual learning.
  • Key techniques include VAROPT_k, Graph Priority Sampling, and time-weighted approaches that tailor eviction and retention policies for improved sample representativeness.

Metric reservoir sampling denotes a family of bounded-memory streaming samplers in which retention, eviction, or weighting is driven by a metric, score, decay function, or objective-specific quantity rather than by uniform replacement alone. The cited literature suggests that the phrase does not identify a single canonical algorithm. Instead, it spans fixed-size weighted priority reservoirs for subset sums, graph streams, and repeated-key aggregates; confidence- and time-weighted buffers for continual learning and visual tracking; temporally biased reservoirs with explicit decay semantics; and reservoir reuse inside stochastic estimators of metric quantities such as Sliced Wasserstein Distance. A separate geometric line studies sampling of metric measure spaces via ε\varepsilon-nets and snowflaked metrics; that line is related terminologically but is not a reservoir algorithm in the streaming sense (0803.0473, Ahmed et al., 2017, Duffield et al., 2017, Chen et al., 2021, Li et al., 2012, Hentschel et al., 2018, Hentschel et al., 2019, Boss et al., 1 Oct 2025, Saucan, 2011).

1. Multiple meanings of “metric” in reservoir sampling

In one major usage, the metric is a scalar importance weight that enters a threshold or priority law. In VAROPTk\mathrm{VAROPT}_k, items have weights wi>0w_i>0, inclusion probabilities are of threshold form

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},

and sampled items receive adjusted weight

w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.

The objective is “variance-optimal unbiased estimation of subset sums” under a fixed sample size kk (0803.0473). In graph streams, Graph Priority Sampling maintains a reservoir K^t\hat K_t of size mm, assigns each arriving edge kk a random key u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1], an adaptive weight VAROPTk\mathrm{VAROPT}_k0, and a priority

VAROPTk\mathrm{VAROPT}_k1

The sample is the top-VAROPTk\mathrm{VAROPT}_k2 priority edges, and the metric is the weight function VAROPTk\mathrm{VAROPT}_k3, which may depend on graph structure, attributes, or variance-reduction surrogates (Ahmed et al., 2017). For repeated-key streams, Priority-Based Aggregation maintains per-key priorities VAROPTk\mathrm{VAROPT}_k4 and unbiased aggregate estimates in a fixed-size cache over non-unique keys (Duffield et al., 2017).

In a second usage, the metric is an application-specific value signal. Confidence Reservoir Sampling in task-free online continual learning keeps the outer reservoir-style admission test but changes eviction by scoring memory items with

VAROPTk\mathrm{VAROPT}_k5

where VAROPTk\mathrm{VAROPT}_k6 is an exploitation rate and VAROPTk\mathrm{VAROPT}_k7 is a margin increment based on softmax confidence (Chen et al., 2021). In online visual tracking, time-weighted reservoir sampling assigns each sample a time-based weight

VAROPTk\mathrm{VAROPT}_k8

and a key

VAROPTk\mathrm{VAROPT}_k9

so that recent samples are more likely to remain in bounded foreground and background buffers used for online Mahalanobis metric learning (Li et al., 2012).

In a third usage, the metric is temporal age. Temporally-biased sampling schemes specify a decay function wi>0w_i>00 over item age and aim to maintain inclusion probabilities proportional to that decay, while controlling memory usage through a reservoir cap or a target size (Hentschel et al., 2018, Hentschel et al., 2019).

In a fourth usage, reservoir sampling is embedded inside a stochastic estimator of a metric. ReSWD stores projection directions and scores each direction by

wi>0w_i>01

then uses weighted reservoir sampling to retain “informative projection directions” across optimization steps for lower-variance Sliced Wasserstein estimation (Boss et al., 1 Oct 2025).

2. Fixed-size weighted and priority reservoirs

The foundational fixed-size formulation is the weighted subset-sum problem addressed by wi>0w_i>02. After processing a stream prefix wi>0w_i>03, the sampler stores a reservoir wi>0w_i>04 of size at most wi>0w_i>05, and any subset sum

wi>0w_i>06

is estimated by

wi>0w_i>07

The threshold wi>0w_i>08 is defined by

wi>0w_i>09

and the scheme satisfies three defining properties: inclusion probabilities proportional to size in threshold form, a sample of at most pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},0 items, and no positive covariances between distinct adjusted weights. Its central claim is optimality of average subset-sum variance for every subset cardinality pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},1, and it supports the streaming recurrence

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},2

as well as a mergeability law over disjoint partitions (0803.0473).

Graph Priority Sampling specializes the same priority-sampling paradigm to graph streams. Each arriving edge is provisionally inserted, the edge of lowest priority

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},3

is identified if the reservoir exceeds capacity, the threshold is updated by

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},4

and pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},5 is evicted. Selected edges are normalized with

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},6

The graph-specific novelty is that pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},7 can encode “number of sampled adjacent edges,” “number of triangles completed by the edge,” or a variance-oriented metric such as

pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},8

For subgraphs pi=min{1,wi/τk},p_i=\min\{1,w_i/\tau_k\},9, the estimator is the product of constituent edge estimators,

w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.0

and the paper establishes unbiasedness through a martingale formulation of graph stream order sampling (Ahmed et al., 2017).

Priority-Based Aggregation adapts order sampling to repeated keys. The stream consists of weighted items w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.1, the true per-key aggregate is

w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.2

and the summary stores at most w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.3 keys. The key technical device is “a single persistent random variable across the lifetime of each key in the cache.” Priority evolves as

w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.4

where w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.5 is accumulated weight since the latest admission of key w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.6. The algorithm keeps the top-w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.7 current priorities, uses a monotone threshold w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.8, and maintains unbiased estimates w^i=max{wi,τk}.\hat w_i=\max\{w_i,\tau_k\}.9 for per-key aggregates (Duffield et al., 2017).

For distributed weighted reservoirs with fixed positive weights, an exact bottom-kk0 view is also available. Each item receives an exponential key

kk1

and the reservoir contains the kk2 smallest keys. This directly supports weighted and unweighted reservoir sampling in a distributed mini-batch streaming model, and the paper explicitly notes that the method remains valid when weights are “fixed metric-derived weights” known at arrival time (Hübschle-Schneider et al., 2019). In the with-replacement setting, each reservoir slot can be maintained as an independent one-item weighted sampler with replacement probability kk3, and skip-based acceleration is obtained from the threshold

kk4

with accepted multiplicity sampled from a zero-truncated binomial law (Meligrana, 2024).

3. Learned confidence, topology, and recency as reservoir metrics

Confidence Reservoir Sampling treats uniform replacement as suboptimal for continual learning because it preserves “equilibrium/fairness of storage, but not informativeness.” The admission gate remains reservoir-style: VAROPTk\mathrm{VAROPT}_k20 but eviction is metric-driven. The score

kk5

combines exploitation rate

kk6

with margin increment

kk7

The paper defines two replacement strategies: deterministic eviction

kk8

and probabilistic eviction

kk9

High-score examples are “more appropriate to replace” because they are either highly exploited or less informative. Empirically, ER-C improves average accuracy on MNIST-S, MNIST-P, CIFAR10-S, and Mini-S, and reduces forgetting on all four datasets, but the paper does not provide a formal theorem for CRS (Chen et al., 2021).

In visual tracking, the reservoir metric is explicitly time-based. The tracker maintains separate finite buffers K^t\hat K_t0 and K^t\hat K_t1 for foreground and background samples, used both as basis matrices for non-sparse reconstruction and as training pools for triplet-based Mahalanobis metric learning. For each new sample, time-weighted reservoir sampling sets

K^t\hat K_t2

and inserts the sample if the corresponding class buffer is not full or if K^t\hat K_t3 exceeds the smallest stored key. The paper states that this balances “sample diversity and adaptability,” because the procedure is still reservoir-style random sampling while assigning later samples larger weights. Weighted reservoir sampling performs better than ordinary reservoir sampling in CLE on multiple sequences, and the implementation uses K^t\hat K_t4 and K^t\hat K_t5 in experiments (Li et al., 2012).

These constructions suggest two application-specific patterns. First, the reservoir can remain structurally classical while the eviction rule becomes metric-driven, as in CRS. Second, the metric can be folded directly into the key distribution, as in time-weighted tracking reservoirs.

4. Temporal metrics and decay-controlled reservoirs

Temporally-biased sampling formalizes age as the metric. The target condition is that, for items K^t\hat K_t6 and K^t\hat K_t7 at time K^t\hat K_t8,

K^t\hat K_t9

where mm0 is a nonnegative, nonincreasing decay function and mm1 is age (Hentschel et al., 2019). In the exponential case,

mm2

and the earlier formulation writes the ratio law as

mm3

for mm4 and mm5 (Hentschel et al., 2018).

The simpler scheme, T-TBS, probabilistically maintains a target sample size but does not enforce a hard cap. In the exponential case it uses per-step retention

mm6

and arrival acceptance

mm7

where mm8 is the mean batch size. T-TBS exactly preserves exponential temporal bias, but sample size is controlled only in expectation (Hentschel et al., 2018).

R-TBS is the reservoir-based construction. It introduces a latent sample

mm9

where kk0 is a set of kk1 full items, kk2 is at most one partial item, and kk3 is sample weight. Realization includes all full items and includes the partial item with probability kk4, so

kk5

The critical primitive is downsampling: if kk6 is produced from kk7 with weight kk8, then for every item kk9,

u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]0

In the exponential-decay case, R-TBS maintains

u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]1

and is proved to maximize expected sample size and minimize sample-size variance among valid samplers with the same maximal expected sample size (Hentschel et al., 2019). The earlier exponential-only treatment presents the same idea in terms of item weights

u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]2

with inclusion law

u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]3

That formulation emphasizes the bridge to classical reservoir sampling: when there is no decay and batches are singletons, it reduces to the classical uniform reservoir law (Hentschel et al., 2018).

For general decay functions, the later paper consolidates old batches into a single exponentially decaying latent sample and introduces a headroom parameter u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]4. The resulting scheme trades off footprint, sample-size stability, and decay fidelity, while providing explicit controls u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]5 and u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]6 on approximation error and bounded footprint (Hentschel et al., 2019).

5. Reservoirs inside metric estimators and constrained candidate streams

ReSWD applies weighted reservoir sampling to the Monte Carlo estimator of Sliced Wasserstein Distance. At optimization step u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]7, the reservoir stores tuples

u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]8

where u(k)Uni(0,1]u(k)\sim \mathrm{Uni}(0,1]9 is a projection direction, VAROPTk\mathrm{VAROPT}_k00 its associated weight, VAROPTk\mathrm{VAROPT}_k01 its reservoir key, and VAROPTk\mathrm{VAROPT}_k02 its insertion time. Each candidate direction is scored by

VAROPTk\mathrm{VAROPT}_k03

and receives a weighted-reservoir key

VAROPTk\mathrm{VAROPT}_k04

Historical entries are decayed by

VAROPTk\mathrm{VAROPT}_k05

the next reservoir keeps the VAROPTk\mathrm{VAROPT}_k06 directions with smallest keys, and the loss is computed with the self-normalized estimator

VAROPTk\mathrm{VAROPT}_k07

The paper presents this as an unbiased Monte Carlo estimate, monitors

VAROPTk\mathrm{VAROPT}_k08

and resets the reservoir when VAROPTk\mathrm{VAROPT}_k09 with VAROPTk\mathrm{VAROPT}_k10. Empirically, ReSWD improves final matching score on synthetic benchmarks and improves several color-correction metrics relative to standard SWD, while adding modest overhead (Boss et al., 1 Oct 2025).

A different but related extension appears in sampling over joins. The generalized reservoir sampler with predicate maintains a uniform sample of VAROPTk\mathrm{VAROPT}_k11 real items from a stream that may also contain dummy items. It uses Li-style skipping with

VAROPTk\mathrm{VAROPT}_k12

but updates the reservoir only when the skipped-to item satisfies the predicate VAROPTk\mathrm{VAROPT}_k13. The paper proves exact uniformity over real items and an instance-optimal expected running time

VAROPTk\mathrm{VAROPT}_k14

when primitive access costs are constant. Its synthetic evaluation uses an edit-distance predicate over strings. This suggests a route for metric-thresholded reservoirs in which the admissible set is defined by a metric predicate and reservoir logic operates over a denser candidate stream that may contain non-eligible items (Dai et al., 2024).

6. Guarantees, limits, and conceptual boundaries

The strongest guarantees appear when the metric reduces to a fixed thresholdable weight or to a controlled decay law. VAROPTk\mathrm{VAROPT}_k15 gives “variance optimal unbiased estimation of subset sums,” preserves exact threshold marginals, and has no positive covariances (0803.0473). GPS proves unbiased edge and subgraph estimators through a martingale formulation, even when subgraph estimators are products of edge estimators computed at different points in the stream (Ahmed et al., 2017). PBA proves unbiased estimates of true aggregates under repeated keys (Duffield et al., 2017). Exponential R-TBS provides exact decay-controlled inclusion probabilities together with a guaranteed upper bound on sample size, and the later treatment proves optimality in expected sample size and sample-size stability (Hentschel et al., 2018, Hentschel et al., 2019).

The guarantees weaken when the metric is adaptive, model-dependent, or heuristic. CRS is motivated by replay saturation and margin dynamics, but the paper explicitly provides no theorem, proof of optimality, or isolated complexity analysis for the reservoir component (Chen et al., 2021). ReSWD repeatedly states that the estimator remains unbiased, but the manuscript does not provide a full theorem-proof derivation of unbiasedness for the exact self-normalized estimator (Boss et al., 1 Oct 2025). Time-weighted reservoir sampling for tracking is justified by adaptability and diversity, not by an exact inclusion law over the original stream (Li et al., 2012).

A further boundary concerns what counts as reservoir sampling at all. “A Simple Sampling Method for Metric Measure Spaces” defines

VAROPTk\mathrm{VAROPT}_k16

and studies VAROPTk\mathrm{VAROPT}_k17-nets, quasimetric metrization, and bilipschitz equivalence to sampling subsets of some VAROPTk\mathrm{VAROPT}_k18. It is a geometric sampling theory, not a one-pass bounded-memory reservoir algorithm (Saucan, 2011). Conversely, parallel weighted reservoir methods based on fixed exponential keys

VAROPTk\mathrm{VAROPT}_k19

are directly applicable when metric information can be encoded as fixed positive per-item weights at arrival time, but the same paper states that they do not directly solve adaptive diversity-aware settings in which weights depend on the current reservoir or on pairwise distances among sampled items (Hübschle-Schneider et al., 2019).

The literature therefore suggests a precise but plural understanding of metric reservoir sampling. In the most developed cases, it means fixed-size weighted or temporally weighted reservoir maintenance with explicit threshold formulas, mergeability, martingale unbiasedness, or variance optimality. In more application-specific cases, it means retaining the outer reservoir skeleton while replacing uniform eviction by a confidence, topology, or recency metric. And in metric-estimation problems such as SWD, it means storing and reusing metric evaluation components—projection directions rather than data items—inside a bounded reservoir to reduce variance.

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 Metric Reservoir Sampling.