Introduction
Kernel Density Estimation (KDE) is a cornerstone of non-parametric statistics, used to estimate probability density functions from data. However, its computational cost is a significant bottleneck: calculating the density for a single query point requires $O(nd)$ operations, where $n$ is the dataset size and $d$ is the dimensionality. In high-dimensional spaces, traditional space-partitioning trees like k-d trees suffer from the "curse of dimensionality," and while Locality Sensitive Hashing (LSH) offers theoretical benefits, it often fails to beat simple random sampling in practice.
DEANN (Density Estimation from Approximate Nearest Neighbors) addresses this by combining Approximate Nearest Neighbor (ANN) search with random sampling to create a fast, robust, and mathematically unbiased estimator.
The DEANN Framework
The core innovation of DEANN is a "near-far" decomposition of the KDE sum. The algorithm partitions the dataset into a small set of "near" points and a larger set of "far" points.
As shown in the pseudocode above, DEANN operates in three main steps:
- ANN Partitioning: It uses an ANN algorithm (e.g., FAISS) as a black-box subroutine to identify $k$ points likely to be near the query.
- Exact Calculation: The contribution of these $k$ points to the kernel sum is calculated exactly. Since kernel functions (like Gaussian or Exponential) decay rapidly with distance, these points provide the most significant contribution to the final density value.
- Random Sampling: The contribution of the remaining $n-k$ points is estimated using a size-$m$ uniform random sample.
A key theoretical result is that this estimator is unbiased. Even if the ANN subroutine returns suboptimal neighbors, the expected value of the estimate remains accurate; poor ANN performance only increases the variance, which can be mitigated by increasing the sample size $m$.
Experimental Setup
The authors evaluated DEANN against several baselines, including naive exact computation, standard random sampling (RS), LSH-based estimators (HBE), and scikit-learn's tree-based methods (SKKD, SKBT). Testing was conducted across nine diverse high-dimensional datasets, such as SVHN (3072d), MNIST (784d), and ALOI (128d).
To maximize performance, the implementation utilizes high-performance linear algebra (Intel MKL) and a "permuted random sampling" technique to ensure contiguous memory access, making the algorithm highly hardware-friendly and efficient on modern CPUs.
Key Results
DEANN consistently demonstrates superior performance, particularly in high-dimensional settings where tree-based methods falter.
As seen in the results table, the DEANNP variant (using permuted sampling) often outperforms the previous state-of-the-art HBE by 1–2 orders of magnitude. Furthermore, DEANN is robust: in scenarios where ANN search provides little benefit (e.g., very large bandwidths where many points contribute equally), the algorithm's performance gracefully degrades to match simple random sampling, ensuring it is never significantly slower than the baseline.
Conclusion and Future Work
DEANN provides a practical and theoretically sound framework for scaling KDE to massive, high-dimensional datasets. By leveraging the speed of modern ANN libraries and the unbiased nature of random sampling, it achieves significant speedups while maintaining accuracy. Future work includes automating the selection of parameters $k$ and $m$ and developing a more integrated theoretical analysis of the ANN-KDE interaction.
Summary updated