Fast and Sample Near-Optimal Algorithms for Learning Multidimensional Histograms

Ilias Diakonikolas, Jerry Li, Ludwig Schmidt

Abstract

We study the problem of robustly learning multi-dimensional histograms. A $d$-dimensional function $h: D \to \R$ is called a $k$-histogram if there exists a partition of the domain $D \subseteq \R^d$ into $k$ axis-aligned rectangles such that $h$ is constant within each such rectangle. Let $f: D \to \R$ be a $d$-dimensional probability density function and suppose that $f$ is $\mathrm{OPT}$-close, in $L_1$-distance, to an unknown $k$-histogram (with unknown partition). Our goal is to output a hypothesis that is $O(\mathrm{OPT}) + \epsilon$ close to $f$, in $L_1$-distance. We give an algorithm for this learning problem that uses $n = \tilde{O}_d(k/\eps^2)$ samples and runs in time $\tilde{O}_d(n)$. For any fixed dimension, our algorithm has optimal sample complexity, up to logarithmic factors, and runs in near-linear time. Prior to our work, the time complexity of the $d=1$ case was well-understood, but significant gaps in our understanding remained even for $d=2$.

Introduction

Learning histograms is a fundamental task in non-parametric density estimation. A $k$-histogram partitions a domain into $k$ axis-aligned rectangles, with the function remaining constant within each. While histograms are ubiquitous in statistics and database systems, learning them from data is computationally challenging when the partition boundaries are unknown.

In one dimension ($d=1$), dynamic programming provides an efficient solution. However, in higher dimensions, the number of potential partitions grows exponentially, and the geometric complexity of rectangles makes the problem significantly harder. Previous algorithms for $d \ge 2$ were often heuristic, required excessive samples, or suffered from prohibitive runtimes. This paper introduces the first near-linear time algorithm for robustly learning multidimensional histograms in any fixed dimension, achieving near-optimal sample complexity and overcoming the "curse of dimensionality" for practical applications.

Algorithmic Framework

The authors propose two primary innovations to achieve efficiency and robustness:

  1. Greedy Hierarchical Splitting (GREEDYSPLIT): Rather than searching for a globally optimal partition—an NP-hard task in high dimensions—the algorithm employs a top-down hierarchical approach. It begins with the entire domain and iteratively splits rectangles that exhibit the highest error. The search is restricted to "hierarchical histograms," which follow a dyadic tree structure similar to a quadtree.
  2. Adaptive Gridding: To handle continuous or large discrete domains without a logarithmic dependence on domain size, the algorithm constructs a grid based on the samples themselves. This ensures that complexity depends on the number of samples ($n$) and pieces ($k$), rather than the resolution of the underlying space.
Hierarchical splitting process: (a) current partition, (b) possible refinements, and (c) the selected next partition.

The algorithm also utilizes the $\mathcal{D}$-distance, an error metric inspired by Vapnik–Chervonenkis (VC) theory. This metric allows for reliable splitting decisions even with limited samples by focusing on the maximum discrepancy over all possible dyadic rectangles, bridging the gap between empirical raw samples and the true underlying distribution.

Key Insights

  • Hierarchical Approximation: A critical insight is that any arbitrary $k$-histogram can be approximated by a hierarchical histogram with only a logarithmic increase in the number of pieces. This structural shift simplifies the infinite search space into a manageable tree-search problem.
  • Semi-Proper Learning: The algorithm is "semi-proper," meaning it outputs a histogram with slightly more than $k$ pieces (specifically, $k \cdot \text{polylog}(k/\epsilon)$). This relaxation is essential for achieving near-linear running time.
  • VC Theory for $L_1$ Optimization: By minimizing the $\mathcal{D}$-distance, the algorithm indirectly minimizes the $L_1$ distance, which is the standard for distribution learning but notoriously difficult to optimize directly.

Results and Performance

The proposed algorithm provides several provable guarantees:

  • Optimal Sample Complexity: For a fixed dimension $d$, the algorithm uses $n = \tilde{O}_d(k/\epsilon^2)$ samples, matching the information-theoretic lower bound up to logarithmic factors.
  • Near-Linear Runtime: The algorithm runs in $\tilde{O}_d(n)$ time, a significant improvement over previous methods that were exponential in key parameters.
  • Agnostic Robustness: If the best $k$-histogram has an error of $OPT$, the algorithm's output has an error of at most $11 \cdot OPT + \epsilon$.
  • Generalization: The techniques are also applicable to learning histograms under the $L_2$ (mean squared error) norm.

Limitations and Future Work

While the algorithm is near-linear for a fixed dimension $d$, the constant factors grow exponentially with $d$ (e.g., $2^d$). This makes the approach highly practical for $d=2$ or $d=3$, but truly high-dimensional histograms remain an open challenge. Additionally, the output histogram contains more than $k$ pieces; finding a "proper" learner that outputs exactly $k$ pieces in near-linear time remains a goal for future research. Finally, reducing the multiplicative constant in the error guarantee (currently 11) toward $1 \cdot OPT + \epsilon$ is another area for potential improvement.

Summary updated

BibTeX
@inproceedings{diakonikolas2018fast,
  author = {Ilias Diakonikolas and Jerry Li and Ludwig Schmidt},
  title = {{Fast and Sample Near-Optimal Algorithms for Learning Multidimensional Histograms}},
  booktitle = {Conference on Learning Theory},
  year = {2018},
  url = {https://openreview.net/forum?id=ZslBZB9DVjc},
}
Figure