NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Density of States Estimation for Out of Distribution Detection

Warren R. Morningstar, Cusuh Ham, Andrew G. Gallagher, Balaji Lakshminarayanan, Alex Alemi, Joshua V. Dillon

Abstract: Perhaps surprisingly, recent studies have shown probabilistic model likelihoods have poor specificity for out-of-distribution (OOD) detection and often assign higher likelihoods to OOD data than in-distribution data. To ameliorate this issue we propose DoSE, the density of states estimator. Drawing on the statistical physics notion of “density of states,” the DoSE decision rule avoids direct comparison of model probabilities, and instead utilizes the “probability of the model probability,” or indeed the frequency of any reasonable statistic. The frequency is calculated using nonparametric density estimators (e.g., KDE and one-class SVM) which measure the typicality of various model statistics given the training data and from which we can flag test points with low typicality as anomalous. Unlike many other methods, DoSE requires neither labeled data nor OOD examples. DoSE is modular and can be trivially applied to any existing, trained model. We demonstrate DoSE’s state-of-the-art performance against other unsupervised OOD detectors on previously established “hard” benchmarks.

Introduction: The Likelihood Paradox

In high-dimensional spaces, standard intuition about probability often fails. For a high-dimensional Gaussian distribution, the point with the highest likelihood is the mean, yet a random sample will almost never be found near the mean. Instead, samples concentrate on a "thin shell" known as the Gaussian Annulus. This phenomenon leads to a major issue in deep generative modeling: a model trained on human faces (CelebA) might assign a higher likelihood to a picture of a truck (CIFAR-10) simply because the truck image has lower variance or simpler statistics that land it in a high-density region of the model's space.

The Gaussian Annulus and the distribution of model statistics. (a) Samples concentrate in a shell, not at the high-likelihood center. (b-e) Distributions of various statistics where the red dashed line indicates the training mean, showing how typical values differ from maximum likelihood points.

This "likelihood paradox" makes standard likelihood-based OOD detection unreliable for safety-critical systems. The core problem is that high probability does not necessarily mean a sample is representative or "typical" of the training distribution.

The DoSE Framework

To address this, we introduce DoSE (Density of States Estimator). Inspired by statistical physics, DoSE shifts the focus from the raw likelihood of the data to the typicality of the model's internal statistics. Instead of asking "how likely is this data point?", DoSE asks "how typical are the statistics of this data point?"

The DoSE method follows a simple two-stage process:

  1. Extract Statistics: For a pre-trained generative model (such as a VAE or Flow-based model), we collect a set of summary statistics $T(x)$—such as log-likelihood, latent entropy, or Jacobian determinants—for all training points.
  2. Estimate Typicality: We fit a non-parametric density estimator, such as a Kernel Density Estimator (KDE) or a One-Class Support Vector Machine (SVM), to these low-dimensional statistics.

At test time, DoSE calculates these statistics for a new input and checks if they fall within the "typical" range observed during training. If the statistics are outliers relative to the training set's distribution of statistics, the point is flagged as OOD.

Experimental Results

We evaluated DoSE across several standard image datasets and "hard" OOD pairings. The most significant tests involved pairings like training on CelebA and testing on CIFAR-10, where standard likelihood methods famously fail.

Comparison of decision boundaries for OOD detection on CelebA (blue) vs CIFAR-10 (red). DoSE (right) achieves a much higher AUC by learning a tight boundary around the typical distribution of statistics compared to raw likelihood (left) or the Typicality Test (middle).

As shown in the comparative analysis, raw log-likelihood $q(X|\theta)$ achieved a dismal AUROC of 0.40 on the CelebA vs. CIFAR-10 task—worse than random guessing. In contrast, DoSE achieved an AUROC of 0.88 (and up to 0.95 with SVM variants). The visualization of decision boundaries reveals that while likelihood and the standard Typicality Test (TT) fail to separate the distributions, DoSE successfully encapsulates the "typical" region of the in-distribution data.

Discussion and Conclusion

DoSE is a modular, unsupervised, and robust approach to OOD detection. One of its most surprising strengths is its robustness to "junk" statistics; adding uninformative diagnostics to the estimator does not significantly degrade performance. Because it models low-dimensional statistics, the second-stage training is computationally efficient.

By explicitly targeting the "typical set" rather than maximum likelihood regions, DoSE provides a principled solution to the likelihood paradox, offering state-of-the-art performance without requiring labeled OOD examples or complex retraining of base models.

Summary updated

BibTeX
@inproceedings{morningstar2021density,
  author = {Warren R. Morningstar and Cusuh Ham and Andrew G. Gallagher and Balaji Lakshminarayanan and Alex Alemi and Joshua V. Dillon},
  title = {{Density of States Estimation for Out of Distribution Detection}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2021},
  url = {https://openreview.net/forum?id=SlN65oKvWc},
}
Figure