Stream Sampling for Frequency Cap Statistics

Edith Cohen

Abstract

In big data analytics, estimating statistics from unaggregated streams often requires a trade-off between memory and accuracy. This paper introduces a unified framework for estimating "frequency cap" statistics—where occurrences are counted up to a threshold $T$. By defining the Sample and Hold (SH) Spectrum, the author presents a family of algorithms that unify distinct counting ($L_0$) and sum estimation ($L_1$). The proposed methods provide unbiased, low-variance estimates while requiring memory proportional only to the sample size, offering a robust solution for applications like frequency capping in online advertising.

Introduction

Standard stream processing typically focuses on two extremes: counting unique keys (Distinct or $L_0$) or totaling all occurrences (Sum or $L_1$). However, many real-world applications require intermediate "Frequency Cap Statistics." For instance, an advertiser may need to estimate the reach of a campaign where each user is capped at 3 impressions. Calculating this exactly requires storing a counter for every unique key, which is infeasible for massive streams with billions of keys.

Edith Cohen's paper, "Stream Sampling for Frequency Cap Statistics," addresses this by introducing the SH Spectrum, a sampling framework optimized for mid-range caps that performs poorly under traditional $L_0$ or $L_1$ samplers.

Methods: The SH Spectrum

The core contribution is the SH (Sample and Hold) Spectrum, a family of sampling schemes parameterized by a value $\ell$. By adjusting $\ell$, the algorithm's behavior shifts along a spectrum:

  • Distinct Sampling ($\ell=1$): The algorithm treats all keys equally, regardless of their frequency.
  • Weighted Sum Sampling ($\ell \to \infty$): The algorithm favors keys with higher frequencies, similar to classic weighted sampling.
Sampling probability as a function of flow size for various values of the parameter $\ell$.

The framework includes both discrete and continuous versions. The Continuous SH version uses exponential random variables ($Exp[w]$) to handle arbitrary weights and simplify the derivation of unbiased estimators. To ensure accuracy, the paper utilizes Inverse Probability Estimation, applying a "transform inversion" to the sampled frequencies in the cache to estimate true capped frequencies.

Furthermore, the paper introduces Multi-objective Sampling. By coordinating random seeds across different parameters, a single small summary can provide accurate estimates for any cap $T$ simultaneously.

Evaluation and Results

The algorithms were evaluated using synthetic datasets mimicking real-world "power-law" distributions (Zipf distributions with $\alpha$ from 1.0 to 2.0). Key findings include:

  • Unbiasedness: Estimators are mathematically proven to be unbiased and non-negative.
  • Accuracy: Error rates (NRMSE) closely track the theoretical lower bounds of aggregated data.
  • Efficiency: A 1-pass streaming algorithm performs nearly as well as a 2-pass algorithm, with the second pass offering only a marginal (~10%) improvement in accuracy.
  • Versatility: The multi-objective approach allows a single sample of size $k$ to estimate a wide range of statistics with high accuracy.

Discussion and Conclusion

The SH Spectrum provides a unified theory for stream sampling, demonstrating that Distinct and Sum problems are endpoints of a single mathematical continuum. The use of continuous sampling distributions simplifies the mathematics of unbiased estimation and leads to "minimum variance unbiased" estimators.

While the framework is robust, it faces challenges in "borderline" cases where many keys have frequencies near the cap $T$, leading to higher variance. Additionally, the current model supports only positive updates (additions), leaving the handling of deletions for future work. Despite these limitations, the SH Spectrum offers a flexible and memory-efficient toolkit for modern large-scale data processing.

Summary updated

BibTeX
@inproceedings{cohen2015stream,
  author = {Edith Cohen},
  title = {{Stream Sampling for Frequency Cap Statistics}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2015},
  doi = {10.1145/2783258.2783279},
}
Figure