Variance-Optimal Reservoir Sampling
- Variance-optimal reservoir sampling is an online method that maintains a bounded sample from weighted streams, ensuring unbiased subset sum estimations.
- It minimizes the average variance for any subset query size, outperforming other schemes in statistical accuracy and efficiency.
- The scheme supports efficient updates and distributed mergeability with O(log k) per-item processing time and low memory requirements.
Variance-optimal reservoir sampling refers to an online sampling methodology that maintains a bounded-size sample (reservoir) from a stream of weighted items, such that subset sum estimates—over any subset, of any size—are unbiased and achieve minimal possible average variance given the sample size constraint. The technique achieves strict optimality in terms of average subset sum estimation variance for every possible query size, outperforming all other known schemes, and is efficient with respect to both per-item processing time and memory requirements (0803.0473).
1. Problem Context and Formal Definition
Given a data stream comprised of items indexed by , each with a positive weight , the objective is to support approximate queries for subset sums: for any subset , estimate using a maintained reservoir of at most samples. Each sample in the reservoir carries an adjusted weight , so the estimator for any subset is . The requirements are as follows:
- Unbiasedness: for any 0.
- Variance Minimization (Average Optimality): For any subset size 1, the average variance over all subsets of size 2 is minimized simultaneously for all 3 and all possible weight assignments (0803.0473).
- Worst-case control: Single-subset, single-item, and total estimation variances are tightly bounded.
- Efficient Online Implementation: Space 4 and per-item time 5.
2. Core Reservoir Sampling Procedure (varoptₖ)
The variance-optimal reservoir sampling scheme, denoted as 6, incrementally constructs and maintains the optimal reservoir as follows (0803.0473):
- Initialization: For the first 7 arrivals, add each with 8.
- Update on Arrival 9 (for 0):
- Form 1, so 2.
- Compute the unique threshold 3 solving 4.
- For each 5, set 6 and 7.
- Randomly pick 8 to drop: sample 9 uniformly and select 0 so that 1.
- Resulting reservoir 2; for each 3, set 4.
In effect, this procedure exactly simulates a k-out-of-(k+1) variance-optimal sample, maintaining the unbiasedness and optimal average-variance properties.
Implementation
Efficient implementation is achieved via two balanced binary trees over 5:
- Tree 6 for items with 7 (sorted by 8; supports subtree statistics).
- Tree 9 for items with 0 (arbitrary order; supports split/concatenation).
All updates, threshold computations, and item removals are carried out in 1 worst-case per item.
3. Variance Optimality and Statistical Properties
The estimator 2 is unbiased for every 3, as each inclusion probability satisfies Horvitz–Thompson conditions:
4
(since 5 tracks the original 6 at final inclusion).
For any fixed subset size 7, let 8 denote the average user-facing query variance. An identity (ST07, Eq. 1 in (0803.0473)) expresses this as:
9
where 0 is the variance of the total weight estimator. 1 ensures 2, and in addition minimizes the total individual variances 3 among all schemes with 4 samples in expectation.
No other online or offline sampling scheme with 5 samples (even one optimized post hoc for the particular data stream) achieves lower 6 for any 7, establishing strict simultaneous optimality (0803.0473).
4. Worst-Case, Tail Bounds, and Complexity
The 8 scheme has strong worst-case guarantees for individual items and subsets:
- For all 9, 0 where 1; in particular, 2 (0803.0473).
- For any subset 3, 4 and 5.
High-probability error control is achieved through Chernoff-type tail bounds that mirror those for independent Poisson sampling. For the sum of inclusion indicators 6 over a subset 7, and 8:
9
The weighted estimator 0 thus satisfies standard multiplicative tail bounds (0803.0473).
Updates can be performed in 1 worst-case time per stream item, with 2 space for both the reservoir and supplemental structures. No general implementation achieves worst-case per-item time better than 3 on the word-RAM model (0803.0473).
5. Comparison to Other Sampling Schemes
Variance-optimal reservoir sampling is compared to several canonical alternatives:
| Scheme | Average Variance | Online-friendly | Mergeable | Worst-case Guarantee |
|---|---|---|---|---|
| Uniform w/o replacement | Arbitrarily bad (heavy tails) | Yes | No | Poor |
| PPS with replacement | Wastes samples (duplicates) | Yes | Yes | Weak |
| PPS w/o replacement | No global optimum | No | No | Moderate |
| IPPS Poisson sampling | Doubles large-4 variance | Yes | Yes | Moderate |
| Priority sampling | Suboptimal for large 5 | Yes | Yes | Good |
| Chao/Tillé (offline) | Optimum; 6–7 time | No | No | Good |
| 8 | Optimum for all 9 | Yes | Yes | Best known |
0 strictly dominates all listed competitors in unbiasedness, variance minimization for every subset size, worst-case control, and support for efficient online and mergeable sampling.
6. Distributed Mergeability and Scalability
The mergeability property of 1 enables scalable, distributed monitoring and analytics. Given any set of disjoint streams 2, maintain separate reservoirs of size 3, then merge the local reservoirs through a single 4 operation applied to the union. The resulting sample has the same distribution as if the scheme were run on the global union from scratch (0803.0473):
5
This allows aggregation of independently-maintained samples in 6 time for data-parallel, distributed, or federated data settings.
7. Limitations, Assumptions, and Open Directions
- Space/Time Complexity: The reservoir requires 7 memory and 8 worst-case per update. A matching lower bound of 9 rules out strict 0 worst-case updates in floating-point arithmetic.
- Numerical Stability: Accurate maintenance of sums and thresholds requires 1 bits of precision.
- Assumptions for Merge Operations: Standard mergeability assumes strict disjointness of item keys. Extensions to environments with key collisions (unaggregated keyed streams) require additional handling (0803.0473).
- Open Problems: Determining whether practical approximations can allow 2 or 3 worst-case update remains unresolved, though evidence suggests this is not feasible for exact implementations.
Variance-optimal reservoir sampling is the unique known scheme providing minimal average variance for subset sum estimation under constrained sample size, while remaining practical and adaptable for large-scale streaming and distributed systems (0803.0473).