arXiv:2609.09622cs.DSSep 2026

Manuscript Offprint

arXiv:2609.09622

Streaming Algorithms for Gaussian Kernel Density Statistics

Qin Zhang

Abstract

Motivated by data produced by generative systems, [LZ26b] formulates similarity-aware statistics via a weighted similarity graph, replacing equality with similarity in classical frequency-based statistics. Although this framework captures semantic relationships between nonidentical items, under general similarity functions even coarse one-pass approximation can require linear space. We therefore ask whether the geometric structure present in natural vector similarities can overcome this barrier. We answer this question affirmatively for the Gaussian kernel. For fixed-dimensional Euclidean vector streams, we study similarity-aware analogues of classical frequency statistics, including the number of distinct elements and frequency moments, through the diversity index and Gaussian density moments. We give one-pass sublinear-space approximation algorithms that exploit the geometric and analytic properties of the Gaussian kernel, and complement them with lower bounds. Our results show that geometric structure can fundamentally change the streaming complexity of similarity-aware statistical analysis.

1 Introduction

Frequency is meaningful only after specifying when two items should count as the same. Classical frequency-based statistics make this choice using exact equality: the frequency of an item is the number of dataset items identical to it. Equivalently, each dataset item contributes either zero or one, according to the equality indicator. For data produced by modern generative systems, however, exact equality is often too rigid. Two texts or images may be distinct as data objects while expressing the same concept or content, and their similarity may be real-valued rather than binary. For frequency-based statistical analysis of such data, it is therefore natural to replace equality with similarity, allowing each dataset item to contribute according to its similarity to the item of interest.

Formally, let S=(s1,…,sn)∈UnS = (s_1, \ldots, s_n) \in \mathcal{U}^n be a dataset, and let sim:U×U→[0,1]sim : \mathcal{U} \times \mathcal{U} \to [0,1] be a symmetric similarity function satisfying sim(x,x)=1sim(x,x) = 1. We define the similarity-aware frequency, or weighted degree, of sis_i by

Di=∑j∈[n]sim(si,sj).D_i = \sum_{j \in [n]} sim(s_i, s_j).

Equivalently, the dataset induces a complete weighted similarity graph with a self-loop at every vertex. The vertices are the input items, and the edge weights are their pairwise similarities. The quantity DiD_i is the weighted degree of vertex ii.

Exact equality is recovered as the special case sim(x,y)=1[x=y]sim(x,y) = 1[x=y]. Thus, the degree moments Mp=∑i∈[n]DipM_p = \sum_{i \in [n]} D_i^p generalize the classical frequency moments Fp+1=∑a:fa>0fap+1F_{p+1} = \sum_{a: f_a > 0} f_a^{p+1}, where faf_a is the number of occurrences of item aa in the dataset. The reciprocal-degree sum M−1=∑i∈[n]Di−1M_{-1} = \sum_{i \in [n]} D_i^{-1} similarly provides a similarity-aware analogue of the number of distinct elements.

We study the computation of these statistics in the standard data stream model [FM85, AMS99]. The items arrive sequentially, and the algorithm must use a small amount of memory to compute a function of the input stream. The similarity graph is not presented explicitly: only its vertices (the items) arrive in the stream, and an edge weight can be obtained only by evaluating sim(⋅,⋅)\text{sim}(\cdot,\cdot) on two items currently stored in memory. Consequently, the algorithm can neither store the entire dataset nor explicitly construct the similarity graph. It must instead estimate global statistics of the implicit graph using a compact streaming sketch.

The study of streaming statistics under general similarity functions was initiated in [LZ26b]. This generality comes at a significant cost: for general similarities, any one-pass constant-factor approximation to M−1M_{-1} requires Ω(n)\Omega(n) bits of space, and analogous linear-space lower bounds hold for MpM_p ( p≥1p \geq 1) [LZ26b]. Thus, unlike their classical frequency-based counterparts, similarity-aware statistics under general similarity functions do not admit sublinear-space one-pass algorithms. This raises the question of whether structure in a specific, natural similarity function can overcome the barrier. Our answer is affirmative for the Gaussian kernel: in fixed dimension, we give one-pass sublinear-space algorithms by exploiting analytic and geometric structure specific to the Gaussian kernel.

Recent work [Zha26] gave a complementary affirmative answer for cosine similarity, where low-rank Gram structure leads to one-pass algorithms whose space depends primarily on the representation dimension rather than on the stream length. Our results show that low-rank algebraic structure is not the only mechanism that can overcome the general-similarity barriers: the spatial decay and Euclidean geometry of the Gaussian kernel provide a different route to sublinear space.

Gaussian kernel similarity and density statistics. Let dd be a fixed dimension, and let P=(p1,…,pn)P = (p_1, \ldots, p_n) be a stream of nn points in Rd\mathbb{R}^d. For a bandwidth parameter σ>0\sigma > 0, the Gaussian kernel is

Kσ(x,y):=exp⁡(−∥x−y∥222σ2).K_{\sigma}(x,y):=\exp\left(-\frac{\|x-y\|_{2}^{2}}{2\sigma^{2}}\right).

The (unnormalized) Gaussian kernel density of a stream point pip_i is defined as DiKσ:=∑j∈[n]Kσ(pi,pj)D_i^{K_\sigma} := \sum_{j \in [n]} K_\sigma(p_i, p_j). Because each point has unit similarity to itself, 1≤DiKσ≤n1 \leq D_i^{K_\sigma} \leq n.

We study three fundamental statistics.

• Diversity index: M−1Kσ(P):=∑i∈[n](DiKσ)−1M_{-1}^{K_{\sigma}}(P) := \sum_{i \in [n]} \left(D_{i}^{K_{\sigma}}\right)^{-1}. To be consistent with prior work [LZ26b], we denote M−1KσM_{-1}^{K_{\sigma}} by DIKσ\mathsf{DI}^{K_{\sigma}}. Intuitively, the diversity index discounts multiplicity and measures the effective number of distinct regions represented by the stream.

  • First density moment: M1Kσ(P):=∑i∈[n]DiKσM_1^{K_\sigma}(P) := \sum_{i \in [n]} D_i^{K_\sigma}. This quantity can be viewed as a soft self-similarity join size. It measures the total amount of pairwise similarity in the stream.

• Higher density moments: MpKσ(P):=∑i∈[n](DiKσ)pM_p^{K_\sigma}(P) := \sum_{i \in [n]} \left(D_i^{K_\sigma}\right)^p for a fixed integer p>1p > 1. Higher density moments place greater weight on dense regions.

When the kernel is clear from context, we omit the superscript KσK_{\sigma} and write the corresponding statistics simply as DiD_{i}, DI\mathsf{DI} (or M−1M_{-1}), M1M_{1}, and MpM_{p}.

Conventions. We consider insertion-only streams and treat the dimension d as a fixed constant. When considering the higher moments MpM_{p}, we assume that p > 1 is a fixed integer.

For our upper bounds, space is measured in words; each coordinate of an input point and each scalar quantity occupies one word; hence a point in Rd\mathbb{R}^d occupies O(d)=O(1)O(d) = O(1) words. We assume access to independent random reals and truly random hash functions. These idealizations can be removed using finite-precision discretization and sufficiently independent hash families, with the resulting errors absorbed into the approximation and failure-probability budgets. Our lower bounds are measured in bits.

For a nonnegative quantity XX, we call X~\widetilde{X} a (1+ϵ,δ)(1+\epsilon,\delta)-approximation to XX if (1−ϵ)X≤X~≤(1+ϵ)X(1-\epsilon)X \leq \widetilde{X} \leq (1+\epsilon)X with probability at least 1−δ1-\delta, and, for α≥1\alpha \geq 1, an α\alpha-approximation if X/α≤X~≤αXX/\alpha \leq \widetilde{X} \leq \alpha X; we use the former for relative-error guarantees and the latter for constant-factor or coarser ones. We drop δ\delta when it is clear from context, and call an algorithm δ\delta-error if it succeeds with probability at least 1−δ1-\delta. We assume 0<ϵ<1/20 < \epsilon < 1/2 throughout, without loss of generality: for ϵ≥1/2\epsilon \geq 1/2 one may run the algorithm with parameter 1/21/2, at only a constant-factor cost in space.

We omit floor and ceiling operators when they do not affect the asymptotic complexity, and, unless otherwise specified, log⁡\log denotes log⁡2\log_2. Constants hidden in Od(⋅)O_d(\cdot) may depend on dd, while those hidden in Op,d(⋅)O_{p,d}(\cdot) may depend on both pp and dd.

Our results. In this paper, we give the following results.

  • Diversity index. We give a one-pass algorithm that outputs a (1+ϵ,δ)(1+\epsilon,\delta)-approximation to DI(P)\mathsf{DI}(P) using Od(ϵ−2d−4log⁡O(d)nϵδ)O_d\left(\epsilon^{-2d-4}\log^{O(d)}\frac{n}{\epsilon\delta}\right) words of space; see Theorem 2.1. For fixed dd, ϵ\epsilon, and δ\delta, the dependence on the stream length is only polylogarithmic. We complement this upper bound by establishing an Ωd(log⁡d/2n)\Omega_d\left(\log^{d/2} n\right)-bit space lower bound for one-pass (1.01,1/3)(1.01,1/3)-approximation to DI(P)\mathsf{DI}(P); see Theorem 2.11.

  • First density moment. We give a one-pass streaming algorithm that outputs a (1+ϵ,δ)(1+\epsilon,\delta)-approximation to M1(P)M_1(P) using O(ϵ−2log⁡1δ)O\left(\epsilon^{-2}\log \frac{1}{\delta}\right) words of space; see Theorem 3.1. We complement this upper bound by a lower bound: there is an absolute constant c0>0c_0 > 0 such that, for every fixed γ>0\gamma > 0 and every n−1/2+γ≤ϵ≤c0n^{-1/2+\gamma} \leq \epsilon \leq c_0, any one-pass 1/3-error algorithm that (1+ϵ)(1+\epsilon)-approximates M1(P)M_1(P) requires Ω(ϵ−2log⁡n)\Omega(\epsilon^{-2}\log n) bits of space; see Theorem 3.7.

  • Higher density moments. For every fixed integer p>1p > 1, we give a one-pass streaming algorithm that outputs a (1+ϵ,δ)(1+\epsilon,\delta)-approximation to Mp(P)M_p(P) using Op,d(ϵ−2n1−1/(p+1)log⁡n⋅log⁡1δ)O_{p,d}\left(\epsilon^{-2}n^{1-1/(p+1)}\log n \cdot \log \frac{1}{\delta}\right) words of space; see Theorem 4.1. We complement this upper bound by a lower bound stating that, for every Cpn−1/(p+1)≤ϵ≤1/20C_p n^{-1/(p+1)} \leq \epsilon \leq 1/20 where CpC_p is a sufficiently large constant, any one-pass 1/3-error algorithm that (1+ϵ)(1+\epsilon)-approximates Mp(P)M_p(P) requires Ωp(ϵ−2n1−2/(p+1)/log⁡n)\Omega_p(\epsilon^{-2}n^{1-2/(p+1)}/\log n) bits of space; see Theorem 4.8.

Table 1 gives a comparison between general similarity functions and the Gaussian kernel. The comparison shows that geometric structure changes the landscape of one-pass space complexity.

References (22)