**
Optimal Sampling from Sliding Windows
**

*
Vladimir Braverman, Rafail Ostrovsky, Carlo Zaniolo
*

**
Abstract:
**

A *sliding windows* model is an important case of the streaming model,
where only the most "recent" elements remain active and the rest are discarded in a stream.
The sliding windows model is important for many applications
(see, e.g., Babcock, Babu, Datar, Motwani and Widom (PODS 02); and Datar, Gionis, Indyk and Motwani (SODA 02)).
There are two equally important types of the sliding windows model -- windows with fixed size, (e.g., where items arrive one at a time,
and only the most recent n items remain active for some fixed parameter n), and bursty windows (e.g.,
where many items can arrive in "bursts" at a single step and where only items from the last t steps remain active, again for some fixed parameter t).
*Random sampling* is a fundamental tool for data streams,
as numerous algorithms operate on the sampled data instead of on the entire stream.
Effective sampling from sliding windows is a nontrivial problem, as
elements eventually expire. In fact, the deletions are \emph{implicit};
i.e., it is not possible to identify deleted elements without storing the entire window.
The implicit nature of deletions on sliding windows does not allow the existing methods (even those that support explicit deletions, e.g., Cormode, Muthukrishnan and Rozenbaum (VLDB 05); Frahling, Indyk and Sohler (SOCG 05)) to be directly "translated" to the sliding windows model.
One trivial approach to overcoming the problem of implicit deletions is that of over-sampling. When k samples are required, the over-sampling method maintains K'>k samples in the hope that at least k samples are not expired. The obvious disadvantages of this method are twofold:

- (a) It introduces additional costs and thus decreases the performance; and
- (b) The memory bounds are not deterministic, which is atypical for streaming algorithms (where even small probability events may eventually happen for a stream that is big enough).

Babcock, Datar and Motwani (SODA 02), were the first to stress the importance of improvements to over-sampling.
They formally introduced the problem of sampling
from sliding windows and improved the over-sampling method for *sampling with replacement*.
Their elegant solutions for sampling with replacement are optimal *in expectation*, and thus resolve disadvantage (a) mentioned above. Unfortunately, the randomized bounds do not resolve disadvantage (b) above. Interestingly, all algorithms that employ the ideas of Babcock, Datar and Motwani have the same central problem of having to deal with randomized complexity (see e.g., Datar and Muthukrishnan (ESA 02); Chakrabarti, Cormode and McGregor (SODA 07)).
Further, the proposed solutions of Babcock, Datar and Motwani for \emph{sampling without replacement} are based on the criticized over-sampling method and thus do not solve problem (a).
Therefore, the question of whether we can solve sampling on sliding windows optimally (i.e., resolving both disadvantages) is implicit in the paper of Babcock, Datar and Motwani and has remained open for all variants of the problem.
In this paper we answer these questions affirmatively and provide optimal sampling schemas for all variants of the problem, i.e.,
sampling with or without replacement from fixed or bursty windows. Specifically, for fixed-size windows, we provide optimal
solutions that require O(k) memory; for bursty windows, we show algorithms that require O(k\log{n}), which is optimal
since it matches the lower bound by Gemulla and Lehner (SIGMOD 08). In contrast to the work of of Babcock, Datar and Motwani, our solutions have deterministic bounds.
Thus, we prove a perhaps somewhat surprising fact: the memory complexity of the
sampling-based algorithm for all variants of the sliding windows model is comparable with
that of streaming models (i.e., without the sliding windows). This is the first result of this type, since
all previous "translations" of sampling-based algorithms to sliding windows incur randomized memory guarantees only.

**comment:**
PODS-2009

Fetch PostScript file of the paper Fetch PDF file of the paper

Back to Publications List |