Estimating Entropy of Distributions in Constant Space

Jayadev Acharya, Sourbh Bhadane, Piotr Indyk, Ziteng Sun

TL;DR

This paper introduces a novel algorithm for estimating the Shannon entropy of a $k$-ary distribution using only constant memory (specifically, about 20 words of space). While previous optimal estimators required memory proportional to the domain size $k$, this approach achieves a near-linear sample complexity while remaining extremely lightweight. This makes it ideal for resource-constrained streaming environments like network routers or IoT devices.

What Problem Does This Paper Address?

In the era of "Big Data," we often need to calculate statistics on the fly. Shannon entropy is a fundamental metric used to measure the randomness or information content of a data source. However, estimating entropy for a distribution over a massive domain of size $k$ (e.g., unique IP addresses or user IDs) presents a significant challenge in a streaming model.

The "gold standard" for entropy estimation uses sub-linear samples—meaning you don't even need to see every possible outcome to guess the entropy. The catch? These state-of-the-art algorithms require "nearly-linear" space (proportional to $k$). If $k$ is in the millions, your memory requirements explode. Conversely, existing streaming algorithms that focus on the empirical entropy of the data stream itself often require $O(\log^2 n)$ space and don't necessarily generalize well to the underlying distribution.

The authors bridge this gap by asking: Can we estimate the entropy of an underlying distribution using only constant memory, without sacrificing too much in terms of sample efficiency?

Methods

The authors build their solution through a "layered sophistication" approach:

  1. The Simple Building Block: They start with a basic observation: Entropy $H(p)$ is the expected value of $-\log p(X)$.
Algorithm 1: Simple Algorithm

A simple algorithm would pick a random sample $X$, watch the next $N$ samples to estimate the frequency of $X$ (let's call it $\hat{p}(X)$), calculate $-\log \hat{p}(X)$, and repeat this $R$ times to average the results. The Problem: To get an accurate estimate for very rare items, $N$ and $R$ have to be very large, leading to a sample complexity of $O(k \log^2 k)$.

  1. Interval Partitioning (The "Aha" Moment): To optimize, the authors partition the probability range $[0, 1]$ into $T$ disjoint intervals. They realize that different probability scales require different treatments:
  2. Large probabilities need many iterations ($R$) for concentration but fewer samples ($N$) to estimate their value.
  3. Small probabilities need many samples ($N$) to be detected at all, but fewer iterations ($R$) because their individual contribution to total entropy is small.
  4. The General Algorithm: By recursively partitioning these intervals (using $T = \log^* k$ intervals, where $\log^*$ is the iterated logarithm), they balance the bias and variance of the estimates across all scales. This allows them to whittle the sample complexity down from $O(k \log^2 k)$ to nearly linear $O(k \cdot \text{poly}(\log(1/\epsilon)))$.

Datasets

This is a theoretical paper focused on algorithmic complexity and mathematical proofs. Consequently, no empirical datasets or experimental benchmarks were used for evaluation. The results are established through rigorous probabilistic analysis (using tools like Hoeffding’s Inequality and bias-variance decomposition).

Key Insights and Ideas

  • Expectation is Key: By reframing entropy estimation as an expectation problem ($\mathbb{E}[-\log p(X)]$), the authors turn a global distribution problem into a local sampling problem that fits naturally into a stream.
  • The Power of $\log^* k$: Using the iterated logarithm to define intervals is a clever way to handle the "long tail" of discrete distributions. It ensures that no matter how large the domain $k$ is, the number of "buckets" needed to manage the trade-off remains effectively constant for all practical purposes.
  • Bypassing Lower Bounds: The paper shows that because the data is generated by an underlying distribution (rather than being an arbitrary, worst-case sequence), they can bypass certain space lower bounds that apply to general data stream entropy estimation.

Key Results

The paper proves the existence of an algorithm (Algorithm 6) with the following properties:

  • Space Complexity: $O(1)$ memory words (specifically, 20 words). This is a massive reduction from the $O(k)$ or $O(\text{poly} \log k)$ required by previous methods.
  • Sample Complexity: $O\left(\frac{k \log(1/\epsilon)^2}{\epsilon^3}\right)$. While this is slightly higher than the absolute theoretical minimum of $O(k/\log k)$, it is linear in $k$, which is a practical "sweet spot" for many applications.
  • Accuracy: It provides an $\pm\epsilon$ estimate of the Shannon entropy $H(p)$ with high probability (at least 2/3).
Comparison of entropy estimation algorithms

Limitations and Future Work

  • The $\log k$ Gap: There is still a multiplicative $\log k$ gap between this constant-space algorithm and the sample-optimal (but memory-heavy) algorithms. The authors leave it as an open question whether an algorithm can achieve both optimal samples and polylogarithmic space.
  • Lower Bounds: The paper does not provide a lower bound for the space requirement of sample-optimal algorithms. Proving that you must use more than constant space to reach the $O(k/\log k)$ sample limit is a key next step for the community.
  • Other Metrics: The current work focuses on Shannon entropy. Extending this constant-space approach to other properties like Rényi entropy or support size estimation is suggested as a future direction.

Summary updated

BibTeX
@inproceedings{acharya2019estimating,
  author = {Jayadev Acharya and Sourbh Bhadane and Piotr Indyk and Ziteng Sun},
  title = {{Estimating Entropy of Distributions in Constant Space}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=hhjS56m6PaI},
}
Figure