stat.MLMay 15, 2026

MaxSketch: Robust Distinct Counting in Streams via Random Projections

Authors: Nikos TsikourasConstantine CaramanisChristos Tzamos

Organizations: National and Kapodistrian University of Athens, Greece · Archimedes, Athena Research Center, Greece · The University of Texas at Austin, USA

Abstract

Estimating the number of distinct elements in a data stream is well understood when repeated elements are identical. In modern settings, however, observations are high-dimensional and noisy, so repeated instances of the same object are only approximately similar -- for example, different images of the same individual may vary significantly at the pixel level. Classical sketches such as HyperLogLog rely on consistent hash values for identical elements and break down in this regime. Recent work on robust distinct counting in general metric spaces achieves Θ~(n)\widetildeΘ(\sqrt{n}) memory, which is tight in the worst case. We show that substantially improved memory guarantees are possible under geometric structure common in learned representations. We introduce MaxSketch, a simple max-linear sketch built from random Gaussian projections, and prove that it succeeds in estimating the number of distinct latent objects. Concretely, we show that under this assumption m=O~(logn/ε2)m = \widetilde{O} (\log n / \varepsilon^2) random projections (and hence O~(logn/ε2)\widetilde{O} (\log n/\varepsilon^2) memory) suffice to recover the true distinct count within a (1+ε)(1+\varepsilon) factor. Experiments on image streams confirm that MaxSketch accurately estimates distinct counts and generalizes beyond the training regime. Our results bridge classical streaming algorithms and modern representation learning, showing how geometric structure can fundamentally reduce the complexity of distinct counting.

Explore similar work

Oct 27, 2025cs.LG

Sublinear Sketches for Approximate Nearest Neighbor and Kernel Density Estimation

Approximate Nearest Neighbor (ANN) search and Approximate Kernel Density Estimation (A-KDE) are fundamental problems at the core of modern machine learning, with broad applications in data analysis, information systems, and large-scale decision making. In massive and dynamic data streams, a central challenge is to design compact sketches that preserve essential structural properties of the data while enabling efficient queries. In this work, we develop new sketching algorithms that achieve sublinear space and query time guarantees for both ANN and A-KDE for a dynamic stream of data. For ANN in the streaming model, under natural assumptions, we design a sublinear sketch that requires only O(n(1η)(1+ρ))\mathcal{O}(n^{(1-η)(1+ρ)}) memory by storing only a sublinear (nηn^{-η}) fraction of the total inputs, where ρρ is a parameter of the LSH family, and 0<η<10<η<1. Our method supports sublinear query time, batch queries, and extends to the more general Turnstile model. While earlier works have focused on Exact NN, this is the first result on ANN that achieves near-optimal trade-offs between memory size and approximation error. Next, for A-KDE in the Sliding-Window model, we propose a sketch of size O(LW11+ε1log2N)\mathcal{O}\left(LW \cdot \frac{1}{\sqrt{1+ε} - 1} \log^2 N\right), where LL is the number of sketch rows, WW is the LSH range, NN is the window size, and εε is the approximation error. This, to the best of our knowledge, is the first theoretical sublinear sketch guarantee for A-KDE in the Sliding-Window model. We complement our theoretical results with experiments on various real-world datasets, which show that the proposed sketches are lightweight and achieve consistently low error in practice.
Ved Danait, Srijan Das, Sujoy Bhore
Aug 11, 2026cs.DS

Improving TensorSketch Using Complex Random Variables

\texttt{TensorSketch} by~\cite{pham2013fast,kar2012random} provides efficient sketching algorithms for high-dimensional polynomial kernels xpRdp\vec{x}^{\otimes p} \in \R^{d^p}. \cite{kar2012random} uses dense Johnson-Lindenstrauss (JL)-type projections with computational cost O(pDd)O(pDd), where DD denotes the sketch dimension, whereas~\cite{pham2013fast} extends the sparse \texttt{CountSketch}\citep{count_sketch} algorithm, yielding a faster algorithm for high-dimensional sparse inputs with running time O(p(\nnzx+DlogD))O\big(p(\nnz{\vec{x}} + D \log D)\big). However, the variance of both estimators grows exponentially with the polynomial degree pp, scaling as 3p/D3^{p}/D. Recent work by\cite{pmlr-v206-wacker23a} showed that using complex-valued distribution reduces this dependence to 2p/D2^{p}/D for the approach of~\cite{kar2012random}. However, their method relies on dense JL-type projections with computational cost O(pDd)O(pDd) and does not extend to the algorithm of~\cite{pham2013fast}. In this work, we introduce a simple variant of \texttt{TensorSketch}\citep{pham2013fast} that achieves the same variance bound as\cite{pmlr-v206-wacker23a}, while retaining its advantage of the input-sparsity running time. We validate our results with supporting experiments on synthetic and real-world datasets.
Amit Sharma, Mohammad Azhar Khan, Rameshwar Pratap +1
May 19, 2026stat.ML

Optimizing Computational-Statistical Runtime for Wasserstein Distance Estimation

Squared Wasserstein distance is a frequently used tool to measure discrepancy between probability distributions. This distance is typically computed between empirical measures of size nn from two underlying random samples. Unfortunately, even in lower dimensional Euclidean space problems (d{2,3})\left( d \in \{2,3\} \right), algorithms for Wasserstein distance computation with approximate or exact precision guarantees scale poorly in the runtime as a function of nn and the desired precision. In response, we consider the computational-statistical runtime, where the goal is to estimate from samples the Wasserstein distance between potentially smooth measures up to εε-additive error in expectation with respect to the sampling; we allow O(1)O(1) computational cost for collecting a sample. Towards this, we develop a Sample-Sketch-Solve paradigm where we introduce a regular cartesian grid sketch of the samples. We show that (especially under αα-Hölder smooth distributions) this can compress the data without increasing asymptotic error, and also regularizes the structure which enables faster exact algorithms. Ultimately, we approximate W22(P,Q)W_2^2(P,Q) within εε error in εmax(2,d+1+o(1)1+α)ε^{-\max(2,\frac{d+1+o(1)}{1+α})} time for 0<α<10 < α< 1 Hölder smooth distributions P,QP,Q on (0,1)d(0,1)^{d}; an optimal Θ(ε2)Θ(ε^{-2}) for α>1/2α> 1/2 when d=2d=2 and nearly optimal as α1α\to 1 when d=3d = 3.
Peter Matthew Jacobs, Jeff M. Phillips