A Spectral Framework for Closed-Form Relative Density Estimation

Francis BachNeurIPS 2026

TL;DR

What if you could do logistic regression, estimate mutual information, or compute the Kullback-Leibler (KL) divergence without iterative optimization? By rewriting the KL divergence as a continuous mixture of simple least-squares problems, Francis Bach shows how to compute relative log-densities in closed form using basic linear algebra (means, covariances, and generalized eigenvalues). It turns messy, unstable exponential optimization problems into clean, one-shot spectral calculations—and can even drop right into the last layer of a neural network.

What Problem Does This Paper Address?

Comparing two probability distributions $p$ and $q$ from data samples—specifically estimating their relative density $dp/dq$ or their KL divergence—is at the heart of machine learning, powering everything from mutual information estimation to classification.

Normally, if you want to avoid computing intractable normalizing constants, you use a variational formulation, turning divergence estimation into an optimization problem. Here’s the catch:

  • If you use the Pearson chi-squared divergence, the math is a dream. It reduces to a quadratic least-squares problem with an instant, closed-form solution based on first and second moments (means and covariances). However, its density ratio estimates can accidentally dip below zero, which makes no physical sense for probabilities.
  • If you use the KL divergence (which naturally models log-densities and stays positive), the variational objective requires taking the empirical average of exponentials ($e^u$). Anyone who has trained energy-based models knows that averaging exponentials over finite samples is numerically and statistically explosive, and requires iterative solvers like Newton's method or gradient descent.

Can we get the best of both worlds—the numerical stability and closed-form linear algebra of least-squares, applied to the geometry of the KL divergence?

Methods

The author bridges this gap through a sequence of mathematical sleights of hand:

  1. Dual-Potential Relaxation: Instead of estimating a single potential function $v(x)$ as in standard variational methods, the paper uses a constrained formulation with two potentials, $v(x)$ and $w(x)$. Estimating both introduces a tiny bit of bias, but drastically reduces variance and unlocks quadratic approximations.
  2. Integrating Chi-Squared Divergences: A broad class of $f$-divergences ("operator-convex" functions, including KL) can be written as a weighted integral of chi-squared divergences over a parameter $\rho \in [0, 1]$. Because each individual chi-squared problem has a closed-form least-squares solution, the KL divergence becomes an integral of infinitely many ridge-regression solutions.
  3. The Spectral Trick: Nobody wants to numerically integrate matrix inverses over $\rho$. By taking the generalized eigenvalue decomposition of the feature covariance matrices $(\Sigma_p, \Sigma_q)$, the entire integral collapses into an exact, explicit spectral formula. Given fixed features $\varphi(x)$, both the divergence estimate and the log-density ratio (which turns out to be a quadratic form in $\varphi(x)$) are computed in one shot!
  4. Debiasing & Feature Learning: Because plugging empirical covariances into a nonlinear formula creates statistical bias, the author introduces a V-statistic style debiasing term. Furthermore, while fixed features (or kernels) give a 100% closed-form estimator, you can also parameterize the features with a neural network—solving the last layer in closed form while training the hidden layers via stochastic gradient ascent (similar to online EM).

Datasets

All empirical evaluations are conducted on controlled synthetic datasets (no external or newly named benchmark suites are introduced):

  • 1D Smooth Densities: $q$ uniform on $[0, 1]$ vs. a smooth density $p$ with one square-integrable derivative, used to test convergence rates.
  • 2D Periodic Data (Torus): Uniform $q$ on $[0, 1]^2$ mapped to unit circles vs. $p$ defined such that $\log(dp/dq)$ is a combination of cosines.
  • Synthetic Classification & Mutual Information: 2D inputs with cosine-based class-conditional distributions to test conditional density estimation against softmax regression.
  • High-Dimensional Latent Subspace ($d$ up to 128): Uniform $q$ on $[0, 1]^d$ embedded into $\mathbb{R}^{2d}$, where $\log(dp/dq)$ depends only on the first coordinate ($2\cos(8\pi x) - 2\cos(6\pi x) + \sin(4\pi x)$), testing whether neural networks can find the low-dimensional signal.

Key Insights and Ideas

  • Softmax Regression Without Iterations: Mutual information between features $x_1$ and one-hot labels $x_2$ is just a KL divergence. Applying this spectral framework yields a closed-form alternative to logistic/softmax regression! Because it integrates linear least-squares estimators, the resulting log-probability estimate is actually quadratic in the features—giving it extra expressive power at a lower computational cost than Newton's method ($O(m_2 m_1^3)$ vs. $O(m_2^2 m_1^2 n + m_2^3 m_1^3)$ per iteration), though the resulting class probabilities aren't strictly normalized to sum to 1.
  • Dropping Feature Normalization: Previous "quantum" kernel divergences also used spectral formulas, but required feature vectors to have unit norm—a massive headache when training neural networks. This framework works out-of-the-box with unnormalized features.
  • Escaping the Curse of Dimensionality: Standard kernel methods choke when dimension $d$ grows unless the target density is ultra-smooth. By pairing the closed-form spectral head with a one-hidden-layer ReLU network, the estimator adapts to low-dimensional linear latent variables, achieving $O(n^{-1/2})$ convergence regardless of ambient dimension.

Key Results

  • Minimax Optimal Scaling Laws: Theory predicts an additive error rate of $n^{-\frac{t}{t+d/2}}$ (or $\sigma = 2/3$ for $t=1, d=1$). Empirically, the regular spectral estimator hits a power-law decay of $0.67$, matching theory on the nose. Adding the debiasing correction slashes absolute error across sample sizes ($n = 32$ to $1024$) and improves the theoretical rate to minimax optimal $n^{-\frac{t}{t+d/4}}$.
Comparison of estimators on 1D and 2D synthetic tasks
  • Beating Variational & KDE Baselines: On 2D periodic data ($n = 512$ to $4096$, 512 random ReLU features), the spectral estimator—especially KL*, which pairs the closed-form potential $v$ with its exact conjugate $1 - e^v$—consistently achieves lower relative estimation error than Pearson chi-squared, standard variational KL optimization, and Kernel Density Estimation (KDE), particularly in low-sample regimes ($n = 512, 1024$).
  • High-Dimensional Adaptivity: When scaling ambient dimension from $d = 2$ to $d = 128$ ($n = 10,000$, $m = 100$ hidden neurons), fixed-feature methods (KL and variational) completely flatline due to the curse of dimensionality. Meanwhile, the neural-network-backed spectral method (KL-NN) maintains low error all the way to $d = 128$, handily outperforming the neural variational baseline (variational-NN).

Limitations and Future Work

  • Asymptotic Normalization Bias: Because the relaxation estimates two separate potentials ($v$ and $w$), conditional density estimates (like in the softmax setting) do not sum to 1. This is an inherent approximation bias that does not vanish even with infinite data, leading to slightly worse test-time performance than exact softmax regression on normalized models.
  • Missing Optimization Guarantees for Feature Learning: While the fixed-feature estimator and infinite-width neural network ERM have rigorous statistical guarantees, the practical alternating/stochastic gradient ascent algorithms used to train finite representations currently lack formal global convergence proofs.
  • Future Directions: The author envisions using this spectral cost function as a parallelizable, sketchable drop-in replacement for standard softmax layers in deep learning, as well as extending the framework to variational inference (where $p$ is optimized rather than sampled), sampling algorithms, and Independent Component Analysis (ICA).

Summary updated

Abstract

We propose a closed-form spectral framework for relative log-density estimation in linearly parameterized probabilistic models, including unnormalized and conditional models. This is achieved by representing the Kullback-Leibler (KL) divergence as an integral of weighted chi-squared divergences, converting KL estimation into a family of least-squares problems. We derive an explicit spectral formula based only on first- and second-order feature moments, yielding closed-form estimators of both divergences and log-density potentials for fixed features. The framework extends to a broad class of $f$-divergences and can be combined with kernelization or feature learning with neural networks (with then only a closed form for the last layer). We prove convergence guarantees for the resulting estimators and empirically compare them on synthetic data with optimization-based variational formulations, including logistic and softmax regression for normalized conditional models.
BibTeX
@inproceedings{bach2026spectral,
  author = {Francis Bach},
  title = {{A Spectral Framework for Closed-Form Relative Density Estimation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=Q5UGhwLahz},
}
Figure