Manuscript Offprint
arXiv:2610.38860Fast Perfect Sampling
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Perfect sampling is a powerful primitive for turnstile data streams, allowing algorithms to extract an index with probability proportional to its squared frequency, with applications to dynamic join size estimation, query optimization, heavy-hitters, sampling from self-joins, and real-time monitoring of evolving datasets. The setting is also the largest for which sampling can be achieved in polylogarithmic space. However, existing space-optimal perfect samplers rely on explicit polynomial duplication, requiring inefficient polynomial update times per stream arrival. Resolving a open question left by Swartworth, Woodruff, and Zhou [FOCS 2025], we present a perfect sampler that achieves an expected polylog() update time while maintaining an optimal bits of space.
1 Introduction
The scale of modern data systems often makes it infeasible to store or repeatedly process an entire dataset. In many settings, such as network monitoring and large-scale database systems, data instead arrives as a continuous stream of updates. The streaming model of computation formalizes this setting by requiring algorithms to process the input using memory far smaller than the size of the data itself. In the standard turnstile model, the stream implicitly defines a high-dimensional frequency vector that is initialized to the all zeros vector and evolves through updates of the form , where may be positive or negative. This model naturally captures dynamic settings in which data is both inserted and deleted, such as updates to database records or changes in network traffic.
A central goal in the streaming model is to design primitives that extract useful information from the frequency vector while respecting stringent space constraints. One particularly powerful primitive is sampling, which returns an index with probability proportional to . Informally, an sampler selects coordinates according to their contribution to the -th frequency moment, biasing the sample toward larger entries as increases. The sampler is called perfect if and approximate otherwise. Because sampling captures structure in the frequency vector beyond global aggregates by extracting representative coordinates according to the geometry induced by the norm, sampling has emerged as a powerful primitive in a variety of sublinear
*Carnegie Mellon University and Google Research. dwoodruf@andrew.cmu.edu. David P. Woodruff is supported in part by Office of Naval Research award number N000142112647 and a Simons Investigator Award.
†Texas A&M University. samsonzhou@gmail.com. Samson Zhou is supported in part by NSF CCF-2335411 and gratefully acknowledges funding provided by the Oak Ridge Associated Universities (ORAU) Ralph E. Powe Junior Faculty Enhancement Award.
and streaming algorithms. In particular, it has found applications in a broad spectrum of settings, including network monitoring and anomaly detection [EV03, HNG+07, GKMS01, TLJ10, MCS+06], distributed computation frameworks [CMYZ12, TW11, JSTW19, WZ12, CF14], database query processing tasks [HNSS96, LNS90, GM98, CG19, Olk93, Haa16, LN95, HS92], and techniques for compact representation and summarization of large datasets [FKV04, DRVW06, DV07, ADK09, IMMM14, MIGR19, CPW20, IMGR20, MRWZ20, JWZ22, MWZ22, GMS23, MT23, LSW+26]. Despite this broad applicability, the complexity and behavior of sampling depend strongly on the choice of , and different regimes require fundamentally different algorithmic ideas.
Among the family of samplers, the case occupies a particularly important position. From a geometric perspective, the norm underlies Euclidean structure and is therefore deeply connected to many algorithmic techniques based on linear algebra and sketching. Within database systems, the second frequency moment corresponds directly to self-join size, making sampling a natural primitive for approximate query processing, join estimation, and regression over joins without explicitly materializing them, where sampling-based techniques are commonly used [JSWY21]. Moreover, it is used in a number of subroutines such as streaming algorithms for norm estimation for [WZ21, WXZ25]. Thus, progress on sampling directly influences the complexity of a much broader class of problems. In particular, is the largest exponent for which polylogarithmic space sampling is possible, as space is necessary for [GLW+25, WXZ25, JLY26].
Previous work. Despite its central role, constructing efficient samplers has been well-studied in the streaming literature. In the insertion-only setting, the classical reservoir sampling technique [Vit85] gives an exact sampler using bits of space with no distortion, both multiplicative and additive. However, beyond the case or outside insertion-only streams, the problem becomes significantly more complex and the question of whether such samplers exist was explicitly posed by [CMR05], and subsequently resolved in the affirmative for in the approximate setting [MW10]. These initial constructions used poly space, and were later improved to near-optimal bounds by [AKO11] and by [JST11], achieving roughly space for and for . While these results established near-optimal space complexity for approximate sampling, they left open finer questions regarding distortion and randomness requirements. This gap was later resolved by [JW18], who introduced the first perfect samplers for with space and for with space.
Update time. Despite resolving the space complexity, the algorithms of [JW18] and related work [CG19] suffer from a severe computational bottleneck, duplicating each coordinate times and assigning each copy an independent exponential weight. Consequently, a single update requires structural operations, so that the update time per element is polynomial in , which can be prohibitively large in many settings. This sparked work on fast perfect sampling. For insertion-only streams, [PW25] achieved update time for in the random oracle model. Subsequently, [SWZ25] introduced a continuous simulation framework for general turnstile streams, achieving polylogarithmic update time for . Unfortunately, the framework of [SWZ25] does not extend to the critical case , where the limiting behavior underlying the continuous simulation approach changes qualitatively and the techniques used for no longer apply (see Section 3 for more details).
At first glance, this distinction may appear to be merely a change of regime. However, the situation is less clear from a complexity perspective. Indeed, while a combination of techniques from [JLY26, SW26] showed an space lower bound for perfect sampling, perfect samplers for are known using only space [JW18, SWZ25]. Thus, it is natural to ask whether the additional memory complexity of the regime fundamentally obstructs fast algorithms, or whether one can still achieve polylogarithmic update time while maintaining optimal space.
Our contributions. In this paper, we resolve the open question of whether perfect sampling admits both optimal space and fast update time in the turnstile model. We introduce a new approach for implementing perfect sampling without relying on the explicit polynomial duplication used in previous constructions to achieve the first perfect sampler with expected polylogarithmic update time and optimal space complexity.
Theorem 1.1. Given a sequence of turnstile updates defining a frequency vector , and a failure probability parameter , there exists a perfect sampler that outputs a failure symbol with probability at most . Conditioned on returning an index ,
The algorithm uses bits of space and processes each stream update in polylog() time in expectation.
We remark that the output corresponds to a failure event that occurs with probability at most ; this is standard in perfect sampling constructions and can be reduced arbitrarily by repetition without affecting the conditional sampling guarantee. Conceptually, our result shows that the additional complexity of the regime does not fundamentally obstruct efficient algorithms. Although the methods developed for do not directly extend to , we show that this qualitative change in behavior need not incur an algorithmic penalty. Thus, despite occupying a distinct space complexity regime, perfect sampling remains achievable with both optimal space and efficient updates.
Approximate samplers permit multiplicative distortion in the sampling probabilities. While this distortion may be small for an individual sample, the effect can accumulate when many samples are repeatedly combined or reused throughout a larger computational pipeline. Consequently, hidden statistical bias may propagate into downstream procedures and alter their behavior. Perfect samplers avoid this issue by reducing the additive distortion in the output distribution to an arbitrarily small inverse-polynomial quantity while preserving essentially the same asymptotic space complexity. For example, if an application extracts samples for some constant , then choosing an additive error of ensures that the resulting joint distribution remains statistically indistinguishable from one obtained using truly exact samples. This makes perfect samplers particularly attractive as reusable black-box primitives.
Distributed databases and query processing. The distinction between approximate and perfect sampling becomes especially important in distributed database systems. Modern data processing architectures partition datasets across many machines, where local summaries are constructed independently and later combined into global estimates. Sampling provides a natural mechanism for constructing such summaries while avoiding communication of the raw data itself.
However, local inaccuracies need not remain local. Even small distortions introduced by approximate samplers can accumulate when summaries are merged, reused, or incorporated into later stages of processing. This phenomenon is particularly relevant in relational settings involving repeated statistical estimation, joins, and self-join computations, where the output of one randomized procedure often becomes the input to another. Perfect samplers substantially reduce such accumulated bias and therefore preserve the fidelity of both local and global statistical summaries.
Information leakage and adaptive interaction. Approximate sampling probabilities may also reveal unintended information about the underlying dataset. Since the permitted multiplicative distortion can depend on global properties of the data, repeated observations of samples may allow an observer to infer information beyond the sampled index itself. For instance, suppose a sampler increases the total probability mass of a large set of coordinates by a factor of whenever a property holds and decreases it by otherwise. Then an observer could estimate whether holds simply by collecting sufficiently many samples and measuring aggregate frequencies.
Perfect samplers mitigate this issue because their output distributions differ from the ideal distribution only by an arbitrarily small additive amount. As a result, repeated interactions with the sampler reveal essentially no additional information beyond that inherent to the target distribution itself.
3 Algorithmic and Technical Overview
In this section, we provide an overview of our algorithmic framework and the technical novelties required to achieve polylogarithmic update time for perfect sampling, c.f., Figure 1. To contextualize our approach, it is instructive to first review the mechanics and limitations of previous sampling frameworks before explaining how we overcome them.
Exponential random variables and duplication. The standard approach [JW18, SWZ25, WXZ25] for perfect sampling involves scaling each stream coordinate by an inverse exponential random variable . Due to the max-stability property of exponential random variables [AKO11], the probability that coordinate yields the largest scaled value is exactly . To recover this maximum element in a data stream, the coordinate is identified using a heavy-hitters data structure such as COUNTSKETCH, coupled with a statistical test to ensure the maximum is reliably isolated from the background noise. However, the probability of passing this test is heavily correlated with the identity of the maximum element itself, distorting the sampling probabilities by an multiplicative bias that destroys the “perfect” sampling guarantee.
To handle this issue, [JW18] duplicated each coordinate a total of times, scaling each duplicate by its own independent exponential random variable. This flattens the background noise so that the statistical test becomes nearly independent of the identity of the maximum element, recovering the desired perfect sampling distribution. Unfortunately, explicitly routing duplicate coordinates into the sketch requires a prohibitively high update time of .
Algorithm Pipeline: Fast Perfect Sampling
(1) Explicit Head: Conceptually duplicate each update times, but explicitly generate only the top exponential weights.
(2) Tail Simulation: Compress the remaining copies into a variance , sampled via fast quadrature of its 1-stable continuous CDF.
(3) Sketch Injection: Update a dense Gaussian COUNTSKETCH, injecting the head directly and the aggregate tail as a single .
(4) Recovery: Run a statistical test and extract the maximum coordinate if it succeeds.
Fig. 1: Overview of the framework, reducing update time to an expected poly().
Algorithmic framework: explicit heads and simulated tails. Our goal is to preserve the exact statistical behavior of this duplication process while avoiding its explicit realization. Our approach is based on a simple structural observation: although the duplicated coordinates are numerous, only a small number contribute significantly to the sketch on any given update. We therefore separate the duplicated copies into two components. For a coordinate , the largest duplicated coordinates are generated and maintained explicitly (the “head”), while the remaining coordinates are aggregated into a single random contribution (the “tail”).
Crucially, this decomposition integrates seamlessly into the sketching framework. Following the approach of [SWZ25], we utilize a dense Gaussian COUNTSKETCH. Because Gaussian random variables are exactly 2-stable, the aggregate contribution of the uninstantiated tail duplicates in each sketch row behaves identically to a single Gaussian variable . Rather than explicitly materializing the tail coordinates, we can compress their contribution into a single sampled variance parameter . Thus, as detailed in Algorithm 1, the algorithm maintains only the explicit heavy coordinates , while the remaining copies are implicitly injected into the sketch through the sampled tail variance.
The explicit heavy coordinates and the necessary truncation parameters can be generated efficiently using standard properties of exponential spacings, as shown in Algorithm 2.
Sampling the continuous tail distribution and the barrier. The core algorithmic challenge lies in generating the variance parameter . We simulate the sum of the tail variables as a single random draw from its limiting continuous distribution, . We perform this via inverse transform sampling (Algorithm 3): we draw and compute such that , where is the Cumulative Distribution Function (CDF) of the limiting tail.
To evaluate efficiently inside the binary search, we must rely on numerical inversion of the Gil-Pelaez integral. This requires obtaining the characteristic function of the tail distribution.
Algorithm 1 Perfect stream update processing
Input: Stream update
Output: Update the dense COUNTSKETCH associated with coordinate
1: , ,
2: Generate using Algorithm 2
3: for each row do
4: for each do
5: Draw
6: Update row by
7: Draw
8: Update row by
Algorithm 2 Generation of heavy coordinates and tail variance
Input: Coordinate , duplication count , truncation parameter from Algorithm 1
Output:
1: Seed a pseudorandom generator using the instance ID and coordinate
2: Generate
3: Generate order statistics
4: Set and draw
5: and
6: Compute via inverse CDF using Algorithm 3
7: Set
8: Return
Algorithm 3 Inverse CDF via binary search
Input: , interval
Output: such that
1: while do
2:
3: if then denotes evaluated via Algorithm 5
4:
5: else
6:
7: Draw
8: return
This introduces the main technical barrier distinguishing perfect sampling from prior work. For [SWZ25], the sum of the tail elements has a heavy tail that converges tightly to a -stable distribution. Because , its characteristic function is well-behaved near the origin, allowing the CDF to be evaluated directly using standard quadrature in polylogarithmic time. However, for the regime, the variables are inverse standard exponentials, which have infinite expectation. Consequently, as the number of tail items grows, the sum diverges at a rate of rather than converging to a standard stable limit. This is not merely a different analytic computation; the logarithmic divergence causes the limiting distribution to be exactly 1-stable, where the characteristic function develops a non-integrable logarithmic singularity near the origin in the Fourier domain. Because standard numerical integration techniques require analytic or sufficiently smooth integrands, the singularity at this 1-stable boundary causes classical numerical quadrature to either require exponential time to converge or fail outright.
Recentering and delaying the limit. To stabilize this divergence, we recenter the sum by defining the random variable . Unlike the regime, where the limiting characteristic function possesses an integrable singularity that evaluates cleanly to an incomplete Gamma function, the boundary results in a 1-stable limit with a non-integrable logarithmic singularity () at the origin in the Fourier domain. Naively recentering the random variable and taking the continuous limit fails because this non-integrable singularity prevents the exchange of the limit and the integral, breaking the standard numerical quadrature required for fast evaluation.
We overcome this barrier by delaying the limit and performing analytic surgery at a finite tail size . By considering the characteristic function for finite , we observe that we can express its core integral as:
By explicitly isolating the singular linear term , the extracted component evaluates exactly to an Exponential Integral . Using its asymptotic expansion via the Entire Exponential Integral , , it naturally generates a phase shift. This algebraically annihilates the algorithmic recentering penalty before taking . Thus, delaying the limit completely removes the logarithmic divergence, leaving a smooth, bounded remainder defined by Sine and Cosine Integrals that permits fast Gauss-Legendre quadrature.
Trigonometric integrals and fast quadrature. After cancellation, the remaining regularized expression becomes , where is the truncation parameter for the magnitude of the tail elements. This differs substantially from the setting, which resolves into incomplete Gamma functions. Instead, applying integration by parts transforms the expression into , yielding real and imaginary parts and . These correspond precisely to the Cosine Integral Cin and Sine Integral Si. Consequently, we obtain an explicit analytic form for the characteristic function at the 1-stable boundary:
With the explicit characteristic function derived, we can evaluate its CDF through the Gil-Pelaez inversion formula. To achieve polylogarithmic update time, the infinite integration domain must be truncated to a logarithmic interval while introducing only negligible error. The magnitude of the characteristic function is governed by . We show that the Sine Integral is the dominating term, yielding the global bound for a universal constant . Using standard concentration and anti-concentration properties (c.f., Rényi's representation theorem for exponential spacings), we show the algorithmic truncation parameter satisfies . This exponential decay guarantees that we can truncate the inversion integral to an interval of size while incurring only an additive error of in the sampling distribution.
Finally, before applying numerical integration, we note that the standard Gil-Pelaez formula contains an imaginary-part operator. This introduces non-analytic behavior that prevents the direct use of exponentially convergent quadrature methods. To circumvent this, we rewrite the integrand as and show that extends holomorphically into the complex plane, allowing the integration contour to be enclosed within a Bernstein ellipse. Because the domain integral is truncated at and the inversion integral at , then . Thus, the trigonometric integrals do not exhibit rapid growth, enabling exponentially convergent Gauss-Legendre quadrature to evaluate the CDF using only points. We summarize the main differences between our approach and previous works in Table 1.
| Property | Prior Work [SWZ25] () | Our Work () |
|---|---|---|
| Tail Limit | Convergent ()-stable | Diverges (1-stable) |
| Recentering? | No | Yes ( shift penalty) |
| Singularity | Integrable near origin | Non-integrable |
| Limit Eval. | Direct continuous limit | Delayed limit |
| Integral Form | Incomplete Gamma () | Exp/Trig (, Ein, Si, Cin) |
Table 1: The boundary introduces non-integrable singularities, breaking prior techniques and requiring a fundamentally different analytic toolkit.
4 Preliminaries
In this section, we briefly recall standard concepts that we will use in our algorithmic design and analysis.
Given an integer , we use to denote the set . Recall that the norm of a vector is defined by while the moment of is defined by . We use poly to denote an arbitrary but fixed polynomial in , whose degree can be adjusted by appropriately adjusting corresponding constants. We use polylog to denote poly. We say an event happens with high probability if it occurs with probability .
Theorem 4.1 (Markov's Inequality). For any non-negative random variable and any constant , we have .
4.1 Probability Distributions
Definition 4.2 (Exponential random variable). A continuous random variable follows an exponential distribution with scale , denoted , if its probability density function is given by for , and 0 otherwise.
Fact 4.3. The exponential distribution satisfies the properties:
(1) (Memory-less property) For all , .
(2) (Max-stability) If are independent exponential random variables with rates , then has cumulative distribution function
Definition 4.4 (Gaussian random variable). A continuous random variable follows a standard Gaussian (or normal) distribution, denoted , if its probability density function is .
Definition 4.5 (Cauchy random variable). A continuous random variable follows a standard Cauchy distribution if its probability density function is .
Definition 4.6 (p-stable). A distribution over is called p-stable for if for any independent random variables and any constants , we have
where , so that denotes equality in distribution.
Fact 4.7. The Cauchy distribution is 1-stable, while the Gaussian distribution is 2-stable. Moreover, if are independent standard Gaussian random variables, then follows the standard Cauchy distribution.
4.2 Characteristic Functions and Inversion Formulas
To analyze the continuous limits of the sums of random variable when explicit probability density functions become mathematically intractable, we instead use Fourier-domain transformations.
Definition 4.8 (Characteristic function and cumulant-generating function). The characteristic function of a random variable , denoted , is the expected value of , representing the Fourier transform of its probability measure. For any real :
where is the probability density function of , and . The natural logarithm of the characteristic function, , is known as the cumulant-generating function.
Unlike moment-generating functions, the characteristic function is globally bounded and uniquely exists for all random variables, including those with heavy tails (e.g., Cauchy distributions).
Theorem 4.9 (Gil-Pelaez Inversion Formula). Let be a continuous random variable have characteristic function . Then the cumulative distribution function () can be computed for any real via the integral:
where denotes the imaginary component of a complex number.
A standard approach for generating random samples from a target distribution with continuous and monotonically increasing CDF is inverse transform sampling, which is simply to generate a uniform random variable and then compute .
4.3 Statistical Distances
To quantify the discrepancy between an algorithmic output distribution and the ideal target distribution, we utilize standard statistical distance metrics.
Definition 4.10 (Kolmogorov-Smirnov Distance). The Kolmogorov-Smirnov distance () is the maximum deviation between the Cumulative Distribution Functions and of two probability distributions, i.e., .
Definition 4.11 (Total variation distance). Let and be probability distributions on with probability density functions and . Then the total variation distance is defined by .
4.4 Real Analysis and Special Functions
Evaluating continuous limits mathematically frequently yields classical non-elementary integrals and requires rigorously interchanging limits and integrals.
Theorem 4.12 (Dominated Convergence Theorem). Let be a sequence of measurable functions converging pointwise to a limit function . If there exists an absolutely integrable bounding function such that for all and , then the limit and integral operators may be exchanged:
Definition 4.13 (Special Integral Functions). The mathematical evaluation of limits frequently isolates the following classical analytic functions:
4.5 Order Statistics
Definition 4.14 (Order statistics and anti-ranks). Given a sample of independent and identically distributed random variables , their order statistics are the sequence of values sorted in non-decreasing order, so that . Here are called the anti-ranks for .
Theorem 4.15 (Rényi Representation Theorem for Exponential Spacings). [Nag06] Let be the order statistics of independent standard exponential random variables . The -th order statistic is equal in distribution to
i.e., a linear combination of independent standard exponentials .
Lemma 4.16 (Lemma 2 in [JW18]). Let and define , where the variables are independent exponential random variables and . Set , and let denote a flattened vector obtained from the collection of values . Similarly, define to be the duplicated vector obtained by repeating each coordinate of exactly times. Then for every integer , with probability at least we have
4.6 Streaming Algorithms
We use a dense variant of COUNTSKETCH as the basic estimation primitive throughout our construction, described in Algorithm 4. Unlike sparse hashing-based sketches, dense COUNTSKETCH projects the frequency vector onto independent Gaussian directions, allowing each coordinate estimate to be expressed as an inner product with a corresponding Gaussian column. This representation yields uniform additive error guarantees across all coordinates, with the error proportional to the global norm of the stream. The dense structure is particularly convenient in our setting because the Gaussian random variables interacts naturally with the tail noise introduced by the perfect sampling procedure.
Algorithm 4 Dense COUNTSKETCH
Input: Frequency vector
Output: Estimates of for all
1: Let be a matrix where each entry is drawn from
2: Let denote the -th column of
3: return as the estimate for
Recall the following guarantees for dense COUNTSKETCH in Algorithm 4, e.g., from [SWZ25], by taking the median of groups of tables with rows:
Theorem 4.17. [SWZ25] With probability at least , the dense COUNTSKETCH data structure with rows returns estimates satisfying
for every . The total space complexity is bits.
5 Analysis of the Continuous Tail Distribution
Algorithm 3 replaces the explicit contribution of the tail coordinates with a single sample from a limiting continuous distribution . In this section, we formalize this limiting object and derive the normalization needed to preserve the induced variance distribution. The main challenge is that the reciprocal exponential variables governing the tail are heavy-tailed: before truncation they have infinite expectation, and even after conditioning on the -th order statistic their moments exhibit logarithmic growth, scaling as . As a result, standard concentration arguments and classical central limit heuristics do not apply directly.
Our analysis proceeds in three steps. First, we characterize the conditioning induced by removing the largest coordinates and show that the remaining variables admit a simple truncated inverse-exponential description. Second, we identify the natural normalization under which the aggregate tail contribution converges to a limiting continuous distribution. Unlike Gaussian limits arising from finite-variance settings, the logarithmic divergence of the reciprocal exponential variables leads to a 1-stable phenomenon, requiring a centering correction of . Finally, we derive an explicit representation of the limiting characteristic function and show how it can be evaluated efficiently for use inside the inverse-CDF sampling procedure.
At a high level, the proof may be viewed as an analytic surgery argument. Directly evaluating the characteristic function produces a non-integrable singularity near the origin, preventing a straightforward interchange of limits and integration. We isolate the singular component, show that it exactly cancels the logarithmic centering term, and then evaluate the remaining regularized expression using special-function identities. This converts the limiting law into an explicit form suitable for numerical inversion.
5.1 Base Variables and Conditioning Shift
By the memory-less property of the exponential distribution, c.f., Fact 4.3, conditioning on the -th order statistic implies that the remaining m variables are distributed as independent exponentials shifted by . Equivalently, in the inverse representation, the corresponding variables are distributed as independent samples conditioned on lying below a threshold determined by .
Let denote a random variable distributed as conditioned on . In the algorithmic setting, . The induced density of is
Let be i.i.d. copies of . We denote the exact discrete tail statistic by .
To isolate the dominant scaling behavior, we define the normalized statistic
The tail-variance functional . In Algorithm 2, the tail-variance functional maps the inverse-CDF sample produced via Algorithm 3 back to the variance parameter of the stream. This should correspond to the quantity . However, since the limiting 1-stable law underlying is supported on all of , the sampled value may occasionally satisfy , in which case becomes negative, which cannot correspond to a realizable variance. We therefore define the tail variance functional by the truncation
so that the computation of in Algorithm 1 is well-defined and the total variation distance remains within the overall additive error tolerance.
5.2 Correcting the Order Statistics Boundaries
We now establish the asymptotic behavior for the tail simulation procedure. Specifically, we show that the reciprocal scale parameter is only polylogarithmic in . Throughout, let for a sufficiently large constant, let the explicitly tracked head size be for a sufficiently large constant , so that is the number of tail coordinates. The target additive failure probability is for some input parameter .
Informally, the argument works as follows. Recall that we define the truncation boundary to be , where denotes the -th largest inverse exponential. Equivalently, if denote the ordered standard exponentials, then . Using Rényi's exact representation theorem for exponential order statistics, c.f., Theorem 4.15, we decompose , where the are independent exponential random variables . Since and , then the denominators satisfy for all . Thus,
The sum is distributed as a Gamma random variable with mean and satisfies standard Chernoff concentration bounds. Therefore, with high probability, , which implies and so . Substituting into the definition of and using , we obtain or equivalently, .
The crucial observation is that the polynomial duplication scale cancels completely in the ratio since . Thus, the truncation boundary depends entirely on the logarithmic head parameter , rather than by the underlying duplication factor.
Lemma 5.1 (Parameter bounds for the truncation scale). Let denote the -th largest order statistic among independent inverse exponentials . Let , , and , where are sufficiently large constants. Define the normalized truncation ratio
. Then, with probability at least , we have , where the constant c > 0 may be made arbitrarily large by choosing sufficiently large.
Proof. The proof proceeds by using Rényi’s representation theorem, c.f., Theorem 4.15 to decouple the standard exponential order statistics and then applying concentration bounds. Let be a sequence of independent, identically distributed standard exponential random variables, so that for all . Let denote the corresponding order statistics, so that for all . By the Rényi Representation Theorem, c.f., Theorem 4.15, the -th order statistic of standard exponential random variables is equal in distribution to a linear combination of independent standard exponentials:
where are mutually independent standard exponential random variables. These hidden exponential random variables are generated by Algorithm 2. Since , then we have
Let be the unscaled sum of the hidden exponentials. By the additive property of independent exponentials, follows an exact Gamma distribution with shape parameter and rate parameter 1, denoted , so that .
To show concentration, we apply a standard Chernoff argument to the sum . For a standard exponential random variable , the moment generating function is
for . By independence, the MGF of is . For the upper tail, let and choose . By Markov's inequality, we have
Observe that for the parameter , the upper tail bound becomes
By similarly applying Markov's inequality to , we have
By setting , we have the lower tail bound
Thus, for the fixed relative deviation of , the exponent constant evaluates to for the upper tail and the exponent constant evaluates to for the lower tail. For the upper tail, the exponent constant evaluates to . For the lower tail, the exponent constant evaluates to . Thus for for sufficiently large , we have by a union bound that the probability that deviates outside the interval is at most . Hence, we define the event to be the high-probability event that .
Conditioned on event , we substitute the bounds for back into Equation 1, obtaining
Because , then it follows that we have
Since we set for , then we have:
Since and , so that for sufficiently large , then for , we have
as desired.
5.3 The Continuous Limit and its Characteristic Function
We now analyze the limiting distribution describing the simulated tail contribution. Recall that the algorithm constructs the centered random variable
where the variables are independent and identically distributed with density
for . Our goal is to identify the limiting characteristic function of as .
Theorem 5.2 (Limiting characteristic function). For any parameter , as , the random variable converges in distribution to a continuous random variable with characteristic function , where
Here denotes the Euler-Mascheroni constant, while Si and Cin are the standard sine and cosine integrals, c.f., Definition 4.13.
Proof. Let denote the characteristic function of . By independence,
Then by taking logarithms of both sides,
Let . To apply the Taylor series expansion , we first upper bound . Since for real , we have . Using the density of , its expectation is . For a fixed , as . Thus , which gives as . We may therefore expand the logarithm to obtain
We now evaluate the expectation term. Using the density of the truncated exponential random variable X,
Substituting ,
Multiplying by m,
The integrand has a non-integrable singularity at , since near . To isolate this term, we write
Accordingly,
We evaluate the second integral by substituting and thus , which gives
where denotes the exponential integral, c.f., Definition 4.13. Using the standard expansion together with as , we have
Substituting this back into Equation (3), the logarithmic term cancels the centering shift . For any fixed , the remaining error terms in the expansion of vanish as , and the scaling factor . To evaluate the limit of the first integral, we apply the Dominated Convergence Theorem, c.f., Theorem 4.12. By Taylor's theorem, the complex exponential satisfies . Thus, the magnitude of the integrand is uniformly bounded by a continuous function independent of :
Since is integrable over the finite interval and pointwise for , dominated convergence allows us to pass the limit inside the integral. Therefore, replacing the dummy variable with ,
It remains to evaluate the integral
Applying integration by parts with and , so that and , we have
Using Euler's formula , the remaining integral becomes
Substituting gives
Combining the previous identities, we have
which gives the desired claim after exponentiating.
6 The Algorithmic Oracle: Sampling from
Algorithm 3 and Algorithm 5 generate a sample using inverse transform sampling applied to the cumulative distribution function . We use the analytic form of the Gil-Pelaez inversion formula [GP51] to evaluate this CDF:
We then use the fact that in the oracle implementation in Algorithm 5.
Algorithm 5 Gil-Pelaez oracle for
Input: , truncation parameter from Algorithm 2
Output: Approximation to
1: , ,
2: Retrieve Gauss-Legendre nodes
3: for each do
4:
5:
6:
7:
8: return
6.1 Domain Truncation via Exponential Decay
A direct evaluation of the Gil-Pelaez integral over an unbounded domain is not computationally feasible. The algorithm therefore relies on structural decay of the characteristic function to truncate the integration range while controlling error.
If decayed only polynomially, any truncation achieving error would typically require a polynomial integration bound , leading to a corresponding polynomial number of quadrature nodes. In contrast, the exponential decay established below permits truncation at , which is sufficient for the desired accuracy and preserves polylogarithmic complexity.
Lemma 6.1 (Exponential Decay and Domain Truncation). For , the characteristic function satisfies the global bound
where . Consequently, truncating the Gil-Pelaez integral to bounds the truncation error by at most .
Proof. Recall from Theorem 5.2 that , where and denotes the Euler-Mascheroni constant. Also recall that for any complex number , , since . Thus, , so it suffices to bound the real part of the exponent.
For real , the terms and are purely imaginary and therefore contribute nothing to . Expanding the remaining term using Euler's formula gives
Moreover, recall that . Since is even, is odd, so . We split the analysis into two regimes based on .
First, consider the regime , i.e., . Since , we have
Over the interval , the function remains strictly positive, so
where . Combining the bounds, for the regime we have
Alternatively, consider the complementary regime . Observe that the function satisfies and . Since for , we have , which implies for all . Setting , we obtain . Furthermore, because , we have . Thus, for , we have , which implies . Therefore, in this regime we also trivially have
Hence, the bound
for all .
We now bound the truncation error in the Gil-Pelaez inversion formula due to the integrand . Using the triangle inequality, for real , and the Hermitian symmetry , we obtain
For sufficiently large , we additionally have over the integration domain, so
By Lemma 5.1, we have , so it suffices to set to achieve a desired truncation bound of while preserving polylogarithmic complexity.
6.2 Gauss-Legendre Quadrature on a Bounded Domain
We approximate the truncated integral
using Gauss-Legendre quadrature.
Analyticity considerations. The exponential decay from Lemma 6.1 ensures that the integrand remains well-controlled on a finite interval. This avoids the need to evaluate the characteristic function in regimes where the oscillatory term becomes numerically unstable. Crucially, by utilizing the algebraic continuation , the integrand is an entire function, entirely avoiding the Cauchy-Riemann violations associated with the imaginary projection. Restricting to ensures that uniformly over the complex integration domain, which keeps all special-function evaluations bounded and compatible with standard quadrature convergence theory [Tre19].
Theorem 6.2 (Polylogarithmic CDF Oracle). Given , the can be evaluated to absolute additive error using Gauss-Legendre nodes.
Proof. Let , which is the analytic continuation used to compute the Gil-Pelaez integrand over the truncated interval . Because is composed of entire functions and the quotient has a removable singularity at , extends analytically to the entire complex plane. Thus, classical results for Gauss-Legendre quadrature apply [Tre19]. The convergence rate is determined by how far the integrand can be analytically continued into the complex plane around the integration interval. This neighborhood is measured using a Bernstein ellipse , i.e., an ellipse in the complex plane with foci at that encloses , whose size controls the exponential convergence rate; its parameter is a single scalar describing how “large” the ellipse is (larger corresponds to a fatter ellipse and faster convergence). If remains analytic inside , then the error for the quadrature evaluation satisfies
where [Tre19], and the factor accounts for the affine scaling of the integration interval. We map the standard interval to via . To keep the analytic continuation away from large imaginary values, we choose the ellipse in the t-plane so that its imaginary semi-axis remains bounded by a constant . Under the affine map above, this corresponds to a semi-minor axis in the w-plane. The corresponding Bernstein parameter is
Since by Lemma 6.1, , and therefore .
It remains to bound the maximum modulus . Every point on the contour can be written as , where and . For the phase factors, we have
Since over the bounds of the binary search interval, this complex phase factor is at most , contributing at most upon taking the logarithm. Near the removable singularity at the origin , the analytic continuation evaluates via L'Hôpital's rule to . Thus remains analytically bounded near the origin. For bounded away from the origin, the dominant contribution to the modulus comes from the characteristic functions evaluated at complex arguments :
where we recall by Theorem 5.2. We now upper bound term by term.
First, consider the drift term
The imaginary component contributes only to phase, while the real component satisfies . By Lemma 5.1, , so this term contributes at most .
Next, consider the exponential remainder term. Since , , and , we obtain . Consequently,
Thus the term has real part upper bounded by .
Finally, over the bounded region , the entire functions and remain uniformly bounded. Since , the terms and contribute at most to the real part.
Combining these estimates, we have
To achieve quadrature error at most , it suffices that . Since , , and , it suffices to set quadrature node evaluations to achieve additive error .
7 Statistical Recovery and End-to-End Correctness
To finalize the perfect sampling framework, we formalize the protocol to extract the heavy-hitter index from the compressed linear sketch and prove that the returned index matches the target distribution.
7.1 The Dense Post-Processing Statistical Test
Let represent the fully duplicated frequency vector. Recall that in a dense COUNTSKETCH, the matrix consists of independent standard Gaussian entries, c.f., Algorithm 4. To recover an estimate for any explicitly tracked virtual item , the algorithm computes the scaled dot product between the sketch vector and the explicit tracking weights . To handle the variance, we partition the rows into independent blocks, each containing rows. Let be a 2-approximation of .
(1) Construct the vector with entries given by , where .
(2) Let and denote the dense COUNTSKETCH estimates of the two largest coordinates in , using R rows.
(3) Let be a 2-approximation to computed from the dense COUNTSKETCH.
(4) Sample uniformly from the interval [0.99, 1.01], where is a fixed parameter.
(5) If or , return FAIL.
(6) Otherwise, the statistical test succeeds.
Fig. 2: Statistical test for the perfect sampler.
We directly leverage the statistical gap test properties proven in [SWZ25]. The following statements assert that the dense COUNTSKETCH gap test does not bias the output distribution, and that it succeeds with constant probability.
Lemma 7.1 (Lemma 4.2 in [SWZ25]). For any constant and , we have for all possible .
Lemma 7.2 (Lemma 4.7 in [SWZ25]). Let . Then with probability at least 0.75, we have both and the statistical test succeeds.
Putting together Lemma 7.1 and Lemma 7.2, we have:
Lemma 7.3 (Ideal Distribution and Target Gap). Let be the coordinate that maximizes the unsketched, perfect virtual vector . Then we have .
Proof. To find the maximum magnitude in the virtual vector , we can equivalently look for the minimum of the squared reciprocal values. Let
Because , standard scaling of exponential random variables implies that follows an exponential distribution with rate parameter , denoted . Moreover, the global maximum magnitude corresponds to the global minimum . Since the collection consists of mutually independent exponential random variables, the probability that the minimum belongs to a specific copy of coordinate is given by the ratio of its rate to the total sum of all rates:
Because each coordinate is duplicated times, the total probability that the global maximum corresponds to coordinate is the sum of these mutually exclusive events:
Hence, we recover the desired sampling distribution.
7.2 Bounding the Algorithmic Simulation Error
To show that the sampler is statistically close to the desired distribution, we upper bound two sources of approximation error:
(1) Head approximation error: The discrepancy between the finite distribution governing the largest coordinates and its continuous stable limit.
(2) Tail approximation error: The perturbation introduced by numerically evaluating the limiting tail distribution, including the resulting Kolmogorov-Smirnov (KS) error from the quadrature procedure.
Instead of directly coupling the characteristic functions of the finite and limiting constructions, we work in the point process framework developed by [SWZ25], which is more stable for analyzing extreme order statistics.
Lemma 7.4 (Lemma 4.14 in [SWZ25]). Let denote the region capturing the top normalized inverse exponential variables. Then the total variation distance between the finite point process induced by the exact construction and its limiting continuous point process, restricted to , is bounded by .
The tail component is obtained by numerically evaluating a truncated limiting 1-stable CDF using Gauss-Legendre quadrature. This introduces a controlled additive error in the evaluations of the limiting CDF. Rather than translating this error into a point-wise perturbation of the sampled quantile or of the induced variance, we compare the resulting numerical sampler directly with the limiting distribution in total variation distance. We then propagate this guarantee through the variance transformation and the Gaussian sketch using the data processing inequality.
Lemma 7.5 (Numerical Tail Sampling in Total Variation). Fix constants . Suppose . Let denote the limiting distribution from Theorem 5.2, with and density . Suppose Algorithm 3 performs binary search on , terminates when the interval width is at most , and, after termination, returns a uniformly random point in the final interval. Suppose furthermore that every CDF evaluation has additive error at most . Let denote the resulting sample. Then
Consequently, for every fixed , by taking , , and for sufficiently large constants , we have .
Proof. Let denote the output of the same binary-search procedure when every comparison uses the exact CDF , coupled to using the same random variables and .
The binary-search tree has possible internal comparison points. At any such point , the exact and numerical comparisons can differ only when lies between and its numerical approximation. Since the CDF approximation error is at most , this occurs with probability at most . A union bound therefore gives
We next compare with . On every interior terminal interval of width at most , the density of is the average of over . Hence, for ,
Summing over the intervals contained in gives
Thus
It remains to bound the last two terms. From the proof of Theorem 5.2, for ,
Since , both exponential moments are . Hence, by Markov's inequality, for with sufficiently large,
Moreover, through Fourier inversion and Lemma 6.1, we have
Taking and for sufficiently large constants finishes the proof. The required CDF accuracy is achievable with quadrature nodes by Theorem 6.2.
Lemma 7.6 (Tail Simulation under Post-Processing). Let and be random variables satisfying . Let . Then . Furthermore, for any fixed and any number of sketch rows, if is independent randomness, then
The same bound holds after any subsequent deterministic or randomized post-processing of these sketch values.
Proof. The map is deterministic, so the first claim follows from the data processing inequality for total variation distance. Conditioned on , the Gaussian sketch contribution is generated from the Markov kernel
Applying a Markov kernel cannot increase total variation distance, which proves the second claim. The final statement follows from another application of data processing.
Lemma 7.7 (Rate of convergence for tail simulation). Let , where the variables are independent with probability density function , where . Suppose and for fixed constants . Then for every fixed and for sufficiently large , we have
where denotes the limiting distribution.
Proof. Let and denote the characteristic functions of and , and let and denote their probability density functions. By Fourier inversion,
We split the integral into low and high frequency regimes.
For , the calculation in the proof of Theorem 5.2 can be made quantitative. Uniformly for ,
Indeed, writing
we have , so the error in replacing by is . The remaining difference follows from together with
Since , the displayed error is uniformly. Consequently,
Using Lemma 6.1 and integrating gives
We now consider the region . For , the exponential decay immediately gives
It remains to bound . Note that and let . We split the analysis into two further regimes.
First consider , where is a sufficiently small constant. Since the variance of diverges with , a quadratic Taylor expansion is not useful here. Instead, we use the identity
where are independent copies of . Set . Restricting to the event and , we have . Hence
We next lower bound the probability of these intervals. Since on , then and
Combining the two estimates gives for some constant . Using , we obtain
Substituting therefore gives
Integrating over gives
Finally, consider the regime . Let denote the untruncated random variable with density . Since has an absolutely continuous distribution, the Riemann-Lebesgue lemma implies as . By compactness, there exists such that for all . The truncated characteristic function differs from by at most the discarded tail mass:
Hence for sufficiently large , we have for all .
We now estimate the remaining integral:
By Parseval's identity,
Since , the integral is finite and bounded by an absolute constant. Therefore,
Combining the low and high frequency estimates gives
Finally, the same cumulant formulas evaluated at show that
Thus, for with sufficiently large,
Therefore,
Since , choosing C sufficiently large proves the claim.
Lemma 7.8. Let the target additive failure rate of the perfect sampler be . The numerical execution differs from the exact theoretical distribution by a total variation distance of at most .
Proof. Fix the desired exponent , and apply Lemmas 7.5 and 7.7 with target error .
Condition first on the explicit head randomness. By Lemma 5.1, choosing the constant in sufficiently large and taking a union bound over the original coordinates, with probability at least every corresponding truncation parameter satisfies
for fixed constants 0 < a < b.
On this event, for every coordinate , let denote its exact finite normalized tail statistic and let denote the sample generated by the numerical oracle. By the triangle inequality and Lemmas 7.5 and 7.7,
Conditioned on the head randomness, the tail variables are independent across the original coordinates. Hence, the total variation distance between the joint exact and simulated tail vectors is at most
Equivalently, the two tail vectors admit a coupling under which they agree coordinate-wise except with probability . By Lemma 7.6, applying the tail-variance map, generating the Gaussian sketch contributions, and running the statistical recovery procedure cannot increase this total variation distance.
Finally, Lemma 7.4 contributes from the head construction. Choosing the duplication constant sufficiently large, and adding the probability of the bad truncation event above, gives
7.3 Derandomization
The preceding analysis assumes that independent exponential and normal random variables can be generated and stored efficiently. To implement this algorithm in the streaming model, we now derandomize these components of the linear sketch. We begin by recalling the pseudorandom generator of [GKM18], which fools a class of Fourier transforms.
Definition 7.9. An -Fourier shape is a function of the form
where each acts on a single coordinate.
The following theorem summarizes the guarantees of the Fourier-shape PRG.
Theorem 7.10. [GKM18] Let be an -Fourier shape with
where each . Then for every , there exists a seed length and a deterministic function such that
i.e., all -Fourier shapes are -fooled by .
Furthermore, the PRG of [GKM18] also fools half-space queries, which we now define. For each , let a half-space query on an input be given by
where and for all .
Definition 7.11 (-half-space tester). Given an input , a -half-space tester is a function
where and are half-space queries. We say that the -half-space tester is -bounded if each coordinate is sampled from an integer distribution with magnitude at most , and every coefficient and threshold also has magnitude at most .
The following theorem gives the corresponding guarantees for fooling half-space testers, c.f., Lemma 7 and Proposition 8 of [JW18].
Theorem 7.12. [GKM18, JW18] Let be a distribution on with magnitude bounded by that can be sampled using at most random bits. Let and define . Then for any and , there exists and a deterministic function such that for every -half-space tester ,
Moreover, if , then each coordinate of can be computed using space and polylog time.
Theorem 7.13. [JW18] Let be a streaming algorithm that, given a stream vector and a fixed matrix , whose entries lie in for some , produces an output that depends only on the sketches and . Suppose that the random matrix has i.i.d. entries, each of which can be sampled using random bits. Let be a tester for the success of , i.e., whenever succeeds.
Then for every fixed constant , there exists an implementation of using a random matrix generated from a seed of length such that
Moreover, every entry of can be computed in polylog time using working space proportional to the seed length.
Lemma 7.14 (Derandomizing the dense Gaussian sketch). Let be the number of rows of the dense Gaussian CountSketch. Suppose all inputs and Gaussian entries have bits of precision. Then, for every fixed constant , the Gaussian randomness used by the dense CountSketch and its recovery procedure can be replaced by pseudorandomness generated from a seed of length such that the probability of every output of the recovery procedure changes by at most . Moreover, every required Gaussian entry can be generated from the seed in polylog time.
Proof. This is the Gaussian-sketch derandomization in the proof of Theorem 5.13 in [SWZ25], with the number of sketch rows left as a parameter. That argument further applies Theorem 7.13 of [JW18] to the dense linear sketch and uses the GKM half-space PRG. If the dense sketch has rows, the quantities denoted in that argument are , and hence the seed length is . The argument is otherwise independent of . In our application , giving seed length .
Theorem 7.15. Suppose the input frequency vector has integer entries bounded in magnitude by . Then Algorithm 1 can be derandomized to use bits of space and uses polylog update time per arriving element in expectation.
Proof. We separate the randomness into the Gaussian randomness used by the dense CountSketch and the randomness used to generate the exponential head variables and the simulated tail variables. We first reduce to finite precision. As in the analysis of [SWZ25, JW18], we condition on the high-probability event that every continuous random variable used by the algorithm has magnitude at most poly(n) and retain bits of precision, for a sufficiently large constant . The resulting perturbation of each maintained sketch value is . Hence, the change in each output probability is at most , and so we can take values from discrete set of poly(n)-bit magnitude, having bit complexity.
We next derandomize . The dense CountSketch used here has rows. Therefore, by Lemma 7.14, its Gaussian matrix can be generated from a seed of length , while changing every output probability by at most . Every entry of this pseudorandom matrix can be recomputed from in polylog() time. Fixing , let denote the resulting pseudorandom sketch matrix.
Now, consider any fixed seed and corresponding tester . Note that this determines the sketch matrix and so it suffices to consider the residual tester . It remains to derandomize the randomness used to generate the exponential random variables. Because we truncate and round each of the coordinates to granularity, it suffices to focus on the discrete exponential random variables on a set with bounded support poly.
Instead of decomposing into separate head and tail components, observe that the turnstile stream updates are linear. The simulated randomness used for any single stream coordinate operates completely independently of the randomness used for other coordinates. For each coordinate , the algorithm uses the local seed to generate both its head order statistics and its simulated tail variance, which deterministically constructs a vector representing the sketch updates for that coordinate.
The final virtual vector is exactly the sum of these independent contributions: . Consequently, the sketch vector has a characteristic function that completely factorizes over the coordinates. Specifically, for any , we have
This matches the exact definition of an -Fourier shape, where and each maps into the complex unit disk. We apply the GKM PRG to fool this Fourier shape. For each coordinate , simulating its updates requires drawing discrete exponential random variables and two discrete uniform random variables, which takes bits, giving a domain size .
The vector has coordinates, each discretized to bits, giving a support size . By the Cauchy-Schwarz inequality and Plancherel's theorem, the total variation distance between two probability distributions over a finite support is bounded by times their maximum difference in the Fourier domain. Thus to guarantee the total variation distance changes by at most , it suffices to have Fourier error . By Theorem 7.10, with , , and , the corresponding seed length is .
Since , the required seed length evaluates to exactly . This pseudorandom generator ensures
. Consequently,
7.4 End-to-End Correctness
Finally, we have the end-to-end correctness of our algorithm, combined with the statistical test and the derandomization.
Theorem 7.16 (End-to-End Correctness for Perfect Sampling). Given a dynamic turnstile stream defining a frequency vector , there exists an algorithm using expected polylog update time and bits of space such that, conditioned on returning an index ,
where for any fixed constant c>0.
Proof. Let denote the distribution induced by the exact discrete construction, and let denote the distribution produced by the implemented algorithm. Let denote the event that the statistical test succeeds and the algorithm returns an index.
Under , the dense COUNTSKETCH recovers the unique maximum coordinate of the duplicated vector except with probability . Since the gap test only accepts when the top coordinate is separated from the remainder of the vector, conditioning on implies that the returned coordinate agrees with the true maximizer with high probability. Fix a virtual coordinate . By Lemma 7.1,
By Lemma 7.2, we have that . Therefore,
Let denote the collection of virtual copies associated with coordinate . Summing over all such copies gives
By Lemma 7.3.
Substituting this identity gives
Conditioning on and using ,
We now compare and . By Lemma 7.8, the total variation distance between the ideal distribution and the algorithmic distribution is at most . Finally, the GKM18 pseudorandom generator -fools both the dense COUNTSKETCH queries and the Fourier evaluations used by the oracle while using only random bits, contributing at most additional variation distance.
Combining the three bounds gives
It follows that
Finally, the dense COUNTSKETCH uses blocks with rows each, for a total of sketch rows. Each row stores a single counter using bits, giving overall space complexity bits. Each update involves rows and performs only polylogarithmic additional work for the explicitly tracked head coordinates and simulated tail contribution, giving expected update time polylog().
Acknowledgments
Google DeepThink contributed the main ideas underlying the technical proofs in this work, and several other AI models assisted with verification.
References
[ADK09] Ankit Aggarwal, Amit Deshpande, and Ravi Kannan. Adaptive sampling for k-means clustering. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, 12th International Workshop, APPROX and 13th International Workshop, RANDOM. Proceedings, pages 15–28, 2009. 2
[AKO11] Alexandr Andoni, Robert Krauthgamer, and Krzysztof Onak. Streaming algorithms via precision sampling. In IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS, pages 363–372, 2011. 2, 3, 4
[BOZ12] Vladimir Braverman, Rafail Ostrovsky, and Carlo Zaniolo. Optimal sampling from sliding windows. J. Comput. Syst. Sci., 78(1):260–272, 2012. 3
[CF14] Graham Cormode and Donatella Firmani. A unifying framework for -sampling algorithms. Distributed Parallel Databases, 32(3):315–335, 2014. 2
[CG19] Edith Cohen and Ofir Geri. Sampling sketches for concave sublinear functions of frequencies. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems, NeurIPS, pages 1361–1371, 2019. 2
[CMR05] Graham Cormode, S. Muthukrishnan, and Irina Rozenbaum. Summarizing and mining inverse distributions on data streams via dynamic inverse sampling. In Proceedings of the 31st International Conference on Very Large Data Bases, Trondheim, Norway, August 30 - September 2, 2005, pages 25–36. ACM, 2005. 2
[CMYZ12] Graham Cormode, S. Muthukrishnan, Ke Yi, and Qin Zhang. Continuous sampling from distributed streams. J. ACM, 59(2):10:1–10:25, 2012. 2
[CPW20] Edith Cohen, Rasmus Pagh, and David P. Woodruff. WOR and p's: Sketches for -sampling without replacement. In Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems, NeurIPS, 2020. 2
[DRVW06] Amit Deshpande, Luis Rademacher, Santosh S. Vempala, and Grant Wang. Matrix approximation and projective clustering via volume sampling. Theory of Computing, 2(12):225–247, 2006. 2
[DV07] Amit Deshpande and Kasturi R. Varadarajan. Sampling-based dimension reduction for subspace approximation. In Proceedings of the 39th Annual ACM Symposium on Theory of Computing, pages 641–650, 2007. 2
[EV03] Cristian Estan and George Varghese. New directions in traffic measurement and accounting: Focusing on the elephants, ignoring the mice. ACM Trans. Comput. Syst., 21(3):270–313, 2003. 2
[FKV04] Alan M. Frieze, Ravi Kannan, and Santosh S. Vempala. Fast monte-carlo algorithms for finding low-rank approximations. J. ACM, 51(6):1025–1041, 2004. 2
[GKM18] Parikshit Gopalan, Daniel M. Kane, and Raghu Meka. Pseudorandomness via the discrete fourier transform. SIAM J. Comput., 47(6):2451–2487, 2018. 29, 30
[GKMS01] Anna C Gilbert, Yannis Kotidis, S Muthukrishnan, and Martin Strauss. Quicksand: Quick summary and analysis of network data, 2001. Technical report. 2
[GLW 25] Elena Gribelyuk, Honghao Lin, David P. Woodruff, Huacheng Yu, and Samson Zhou. Lifting linear sketches: Optimal bounds and adversarial robustness. In Proceedings of the 57th Annual ACM Symposium on Theory of Computing, STOC, pages 395–406, 2025. 2
[GM98] Phillip B. Gibbons and Yossi Matias. New sampling-based summary statistics for improving approximate query answers. In SIGMOD, Proceedings ACM SIGMOD International Conference on Management of Data, pages 331–342, 1998. 2
[GMS23] Siddharth Gollapudi, Sepideh Mahabadi, and Varun Sivashankar. Composable coresets for determinant maximization: Greedy is almost optimal. In Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems, NeurIPS, 2023. 2
[GP51] Julio Gil-Pelaez. Note on the inversion theorem. Biometrika, 38(3/4):481–482, 1951. 18
[Haa16] Peter J. Haas. Data-stream sampling: Basic techniques and results. In Data Stream Management - Processing High-Speed Data Streams, Data-Centric Systems and Applications, pages 13–44. Springer, 2016. 2
[HNG 07] Ling Huang, XuanLong Nguyen, Minos N. Garofalakis, Joseph M. Hellerstein, Michael I. Jordan, Anthony D. Joseph, and Nina Taft. Communication-efficient online detection of network-wide anomalies. In INFOCOM. 26th IEEE International Conference on Computer Communications, Joint Conference of the IEEE Computer and Communications Societies, pages 134–142, 2007. 2
[HNSS96] Peter J. Haas, Jeffrey F. Naughton, S. Seshadri, and Arun N. Swami. Selectivity and cost estimation for joins based on random sampling. J. Comput. Syst. Sci., 52(3):550–569, 1996. 2
[HS92] Peter J. Haas and Arun N. Swami. Sequential sampling procedures for query size estimation. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 341–350, 1992. 2
[IMGR20] Piotr Indyk, Sepideh Mahabadi, Shayan Oveis Gharan, and Alireza Rezaei. Composable core-sets for determinant maximization problems via spectral spanners. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 1675–1694, 2020. 2
[IMMM14] Piotr Indyk, Sepideh Mahabadi, Mohammad Mahdian, and Vahab S. Mirrokni. Composable core-sets for diversity and coverage maximization. In Proceedings of the 33rd ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS'14, Snowbird, UT, USA, June 22-27, 2014, pages 100–108. ACM, 2014. 2
[JLY26] Cheng Jiang, Yinchen Liu, and Huacheng Yu. Turnstile streaming algorithms might (still) as well be linear sketches, for polynomial-length streams, 2026. 2, 3
[JST11] Hossein Jowhari, Mert Saglam, and Gábor Tardos. Tight bounds for samplers, finding duplicates in streams, and related problems. In Proceedings of the 30th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS, pages 49–58, 2011. 2, 3
[JSTW19] Rajesh Jayaram, Gokarna Sharma, Srikanta Tirthapura, and David P. Woodruff. Weighted reservoir sampling from distributed streams. In Proceedings of the 38th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS, pages 218–235, 2019. 2
[JSWY21] Rajesh Jayaram, Alireza Samadian, David P. Woodruff, and Peng Ye. In-database regression in input sparsity time. In Proceedings of the 38th International Conference on Machine Learning, ICML, pages 4797–4806, 2021. 2
[JW18] Rajesh Jayaram and David P. Woodruff. Perfect sampling in a data stream. In 59th IEEE Annual Symposium on Foundations of Computer Science, FOCS, pages 544–555, 2018. 2, 3, 4, 5, 11, 29, 30, 31
[JWZ22] Rajesh Jayaram, David P. Woodruff, and Samson Zhou. Truly perfect samplers for data streams and sliding windows. In PODS: International Conference on Management of Data, pages 29–40, 2022. 2
[LN95] Richard J. Lipton and Jeffrey F. Naughton. Query size estimation by adaptive sampling. J. Comput. Syst. Sci., 51(1):18–25, 1995. 2
[LNS90] Richard J. Lipton, Jeffrey F. Naughton, and Donovan A. Schneider. Practical selectivity estimation through adaptive sampling. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 1–11, 1990. 2
[LSW 26] Honghao Lin, Zhao Song, David P. Woodruff, Shenghao Xie, and Samson Zhou. sampling in distributed data streams with applications to adversarial robustness. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 4342–4409, 2026. 2
[MCS 06] Jianning Mai, Chen-Nee Chuah, Ashwin Sridharan, Tao Ye, and Hui Zang. Is sampled data sufficient for anomaly detection? In Proceedings of the 6th ACM SIGCOMM Internet Measurement Conference, IMC, pages 165–176, 2006. 2
[MIGR19] Sepideh Mahabadi, Piotr Indyk, Shayan Oveis Gharan, and Alireza Rezaei. Composable core-sets for determinant maximization: A simple near-optimal algorithm. In Proceedings of the 36th International Conference on Machine Learning, ICML 2019, volume 97, pages 4254–4263, 2019. 2
[MRWZ20] Sepideh Mahabadi, Ilya P. Razenshteyn, David P. Woodruff, and Samson Zhou. Non-adaptive adaptive sampling on turnstile streams. In Proceedings of the 52nd Annual ACM SIGACT Symposium on Theory of Computing, STOC, pages 1251–1264, 2020. 2
[MT23] Sepideh Mahabadi and Stojan Trajanovski. Core-sets for fair and diverse data summarization. In Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems, NeurIPS, 2023. 2
[MW10] Morteza Monemizadeh and David P. Woodruff. 1-pass relative-error -sampling with applications. In Proceedings of the Twenty-First Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 1143–1160, 2010. 2, 3
[MWZ22] Sepideh Mahabadi, David P. Woodruff, and Samson Zhou. Adaptive sketches for robust regression with importance sampling. In Amit Chakrabarti and Chaitanya Swamy, editors, Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, APPROX/RANDOM), pages 31:1–31:21, 2022. 2
[Nag06] Haikady N Nagaraja. Order statistics from independent exponential random variables and the sum of the top order statistics. In Advances in Distribution Theory, Order Statistics, and Inference, pages 173–185. Springer, 2006. 11
[Olk93] Frank Olken. Random Sampling from Databases. PhD thesis, University of California at Berkeley, 1993. 2
[PW25] Seth Pettie and Dingyu Wang. Universal perfect samplers for incremental streams. In Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 3409–3422, 2025. 2
[SW26] William Swartworth and David P. Woodruff. Tight lower bounds for sampling. Proc. ACM Manag. Data, 2026. 3
[SWZ25] William Swartworth, David P. Woodruff, and Samson Zhou. Perfect lp sampling with polylogarithmic update time. In 66th IEEE Annual Symposium on Foundations of Computer Science, FOCS, pages 1936–1960, 2025. 2, 3, 4, 5, 6, 8, 11, 12, 22, 23, 24, 30, 31
[TLJ10] Marina Thottan, Guanglei Liu, and Chuanyi Ji. Anomaly detection approaches for communication networks. In Algorithms for Next Generation Networks, Computer Communications and Networks, pages 239–261. Springer, 2010. 2
[Tre19] Lloyd N Trefethen. Approximation theory and approximation practice, extended edition. SIAM, 2019. 20, 21
[TW11] Srikanta Tirthapura and David P. Woodruff. Optimal random sampling from distributed streams revisited. In Distributed Computing - 25th International Symposium, DISC. Proceedings, volume 6950, pages 283–297, 2011. 2
[Vit85] Jeffrey Scott Vitter. Random sampling with a reservoir. ACM Trans. Math. Softw., 11(1):37–57, 1985. 2
[WXZ25] David P. Woodruff, Shenghao Xie, and Samson Zhou. Perfect sampling in turnstile streams beyond small moments. Proc. ACM Manag. Data, 3(2):106:1–106:27, 2025. 2, 4
[WZ12] David P. Woodruff and Qin Zhang. Tight bounds for distributed functional monitoring. In Proceedings of the 44th Symposium on Theory of Computing Conference, STOC, pages 941–960, 2012. 2
[WZ21] David P. Woodruff and Samson Zhou. Tight bounds for adversarially robust streams and sliding windows via difference estimators. In 62nd Annual Symposium on Foundations of Computer Science, FOCS, pages 1183–1196, 2021. 2