Kullback–Leibler Divergence (Relative Entropy)
- Kullback–Leibler divergence is a nonnegative, asymmetric measure of discrepancy between two probability distributions that becomes infinite when the reference assigns zero probability to an observed event.
- It supports maximum-likelihood estimation, hypothesis testing, Bayesian updating, maximum-entropy reconstruction, and machine-learning objectives by quantifying excess logarithmic loss or information gain.
- Its data-processing inequality makes it decrease under coarse-graining, while applications in thermodynamics, kinetic theory, diffusion models, and molecular simulation interpret it as free-energy excess, irreversibility, or model error.
Kullback–Leibler entropy is an informal name for the Kullback–Leibler (KL) divergence, also called relative entropy or information divergence. For probability measures and on a common measurable space, with , it is defined by
For densities and relative to a common dominating measure,
The first argument is the distribution being averaged over, conventionally interpreted as the empirical, true, or observed distribution; the second is the reference, theoretical, or model distribution. KL divergence is nonnegative, vanishes exactly when the two distributions coincide almost everywhere, and is generally asymmetric. Strictly, Shannon entropy is a one-distribution functional, whereas KL divergence compares two distributions. This distinction is central to statistical inference, information theory, kinetic theory, Bayesian analysis, stochastic dynamics, machine learning, and multiscale modeling.
1. Definition, terminology, and fundamental properties
For a finite distribution and reference distribution ,
The usual conventions are
0
Consequently,
1
meaning that every event assigned zero probability by 2 is also assigned zero probability by 3. If 4 and 5, the divergence is infinite. This is the mathematical basis for interpreting a zero-probability model prediction contradicted by an observation as strict falsification (0808.4111).
KL divergence satisfies Gibbs’ inequality:
6
with equality if and only if 7. It is not a metric: generally,
8
and it does not satisfy the triangle inequality. The asymmetry is not a defect of notation but expresses the distinct inferential roles of data and model. Reversing the arguments changes both the weighting distribution and the support condition.
Using natural logarithms gives units of nats; logarithms to base 9 give bits. KL divergence is invariant under a common invertible change of variables because the Jacobian factors cancel in the density ratio. This contrasts with differential Shannon entropy, which changes under rescaling.
The divergence decomposes into cross-entropy and Shannon entropy:
0
where
1
Thus KL divergence is the excess expected logarithmic loss or coding cost incurred when data generated by 2 are encoded using 3. Shannon entropy measures uncertainty within one distribution; cross-entropy measures the average code length under another; KL divergence measures their difference.
The divergence is jointly convex:
4
It is also convex in either argument separately under the usual domain conditions. For a measurable transformation or Markov kernel 5, the data-processing inequality states
6
Coarse-graining, marginalization, or stochastic processing therefore cannot increase distinguishability. In finite spaces, aggregating categories into super-categories 7 and 8 gives
9
2. Statistical inference, likelihood, and information geometry
Let 0 be independent observations with 1 possible outcomes. If 2 observations fall in category 3, the empirical distribution or type is
4
For a model distribution 5, the likelihood of the ordered sample is
6
Since 7 is fixed for observed data, maximizing likelihood is equivalent to minimizing
8
Thus maximum likelihood is a forward-KL projection of the empirical distribution onto the model family.
The probability of observing a type includes the multiplicity of ordered sequences having that type:
9
Stirling’s approximation yields the large-deviation relation
0
where 1 means
2
KL divergence is therefore the exponential rate at which an empirical distribution becomes unlikely under a model.
For a single hypothesis 3, the statistic
4
is asymptotically chi-square distributed with 5 degrees of freedom. The model is rejected at significance level 6 when
7
For a model family 8, the maximum-likelihood projection is
9
and the residual statistic is
0
Its asymptotic degrees of freedom are
1
For nested families 2, the likelihood-ratio statistic becomes
3
In exponential families, the difference admits the Pythagorean form
4
For two simple hypotheses 5 and 6, the Neyman–Pearson rejection region can be written asymptotically in terms of a difference of KL divergences:
7
The optimal equal-prior error exponent is the Chernoff information,
8
Near equality of 9 and 0, KL divergence has a quadratic expansion related to Pearson’s chi-square discrepancy:
1
This local quadratic structure is the information-geometric origin of the Fisher information metric. For discrete normal distributions, KL divergence is a reverse Bregman divergence in natural coordinates:
2
where 3 is the log-normalizing function associated with the Riemann theta function (Nielsen, 2021).
Unrestricted maximum likelihood gives
4
Although this minimizes empirical forward KL exactly, it can overfit sampling noise. Restricted model families, likelihood-ratio tests, complexity penalties, Bayesian priors, maximum-entropy reconstruction, and Markov-order restrictions address this limitation.
3. Relation to entropy families and variational principles
KL divergence is the order-one member of the Rényi-divergence family. For 5, 6,
7
The limit 8 is
9
Rényi divergence is nonnegative, obeys data processing, is monotone in 0 under the stated finiteness conditions, and is additive for product measures. In particular,
1
The order-2 and order-3 cases connect KL divergence to Hellinger and 4 distances:
5
and
6
Consequently,
7
Shannon entropy can be recovered by selecting a reference measure. For a discrete probability mass function 8, taking 9 to be counting measure gives
0
so
1
Taking 2 to be the uniform probability on 3 points gives
4
Thus entropy is not itself a two-distribution divergence; it is obtained from relative entropy after specifying a reference measure.
A variational representation is
5
under suitable integrability conditions. A categorical characterization shows that, on finite statistical systems, KL divergence is uniquely determined up to a nonnegative scalar by functorial additivity under composition, convex linearity, lower semicontinuity, and vanishing for optimal Bayesian inverses (Baez et al., 2014). In that framework, a deterministic map is a measurement, a stochastic right inverse is a hypothesis about the preimage state, and relative entropy quantifies the information gained when the induced prior is updated to the true distribution.
If a probability kernel 6 supplies a reference distribution on each fiber of 7, then the generalized entropy
8
is the negative KL divergence between the actual joint law 9 and the law obtained by retaining its 0-marginal 1 while replacing its conditional distribution on 2 by 3. Choosing 4 yields mutual information:
5
This conditional-kernel formulation extends entropy and information gain to general measurable spaces (Lopes et al., 2020).
4. Maximum entropy, Bayesian updating, and reconstruction
For incomplete observations, KL projection provides a principled reconstruction mechanism. If the compatible empirical distributions form a set 6, the most probable reconstruction under a model 7 is
8
Sanov’s theorem gives
9
If 00 is uniform, then
01
so minimizing relative entropy is equivalent to maximizing Shannon entropy. Maximum entropy is therefore a prior-dependent information projection, not a reconstruction generated without assumptions.
For a linear constraint
02
the KL projection has exponential-family form
03
For energy constraints and a uniform prior, this becomes the Boltzmann–Gibbs distribution
04
The same construction produces gravity-type models under constraints on distances, costs, origin profiles, destination profiles, stayers, or balanced flows (0808.4111).
For a Dirichlet prior 05 with 06, the prior has the asymptotic form
07
After observing counts, the posterior remains Dirichlet with parameters 08, and
09
The prior strength 10 consequently acts in effective sample-size units.
Pólya Tree priors exploit a multiplicative binary partition structure. The logarithm of a Pólya Tree density becomes an additive series of independent beta-branching contributions, yielding a representation of the form
11
Under summability conditions on the beta parameters, posterior expected KL divergence converges to zero, and posterior mass also concentrates in total variation. A related posterior estimator of differential entropy is consistent in probability for compactly supported vectors under the stated regularity assumptions. In one dimension, truncation at depth approximately
12
is theoretically sufficient for retaining the data-relevant part of the tree (Corrêa et al., 3 Apr 2025).
5. Dynamical, thermodynamic, and physical interpretations
KL divergence frequently acts as a Lyapunov functional when one distribution evolves toward a reference equilibrium. For finite-state Markov dynamics,
13
where 14 is infinitesimal stochastic. If 15 and 16 evolve under the same Markov process, then
17
If 18 is stationary, 19, then both
20
have corresponding monotonicity results under the conditions considered. Detailed balance is not required for the general contraction theorem (Baez et al., 2015).
When 21 is a Boltzmann distribution,
22
the free-energy difference satisfies
23
under the paper’s convention for 24. KL divergence is therefore a nonequilibrium free-energy excess, and its decrease corresponds to relaxation toward equilibrium.
For reaction networks, populations need not be normalized. The appropriate generalized divergence is
25
For a complex-balanced equilibrium 26, mass-action dynamics satisfies
27
This extends the Lyapunov interpretation from normalized Markov distributions to nonlinear chemical reaction networks.
In kinetic theory, if 28 evolves under the Boltzmann equation and 29 is the Maxwellian with the same mass, mean velocity, and temperature, then
30
The Boltzmann 31-theorem implies that physical entropy increases and the relative entropy to the Maxwellian decreases. KL divergence thus quantifies convergence toward equilibrium (Auricchio et al., 15 Jul 2025).
For stationary trajectories, temporal irreversibility is quantified by comparing a forward block probability with the probability of its reverse:
32
The asymptotic KLD rate is
33
The observable rate provides a lower bound on physical entropy production:
34
Equality requires complete microscopic information or conditions under which the observed variables determine entropy production. Hidden variables and discarded transition-time information reduce the observable bound (Roldán et al., 2012).
For a stationary first-order Markov process,
35
Two-point statistics then suffice. Non-Markovian observations can remain time-asymmetric even when all one-step probability currents vanish, so higher-order blocks may be necessary.
In cosmology, a domain-averaged KL functional compares an inhomogeneous matter density 36 with its homogeneous domain average:
37
It vanishes for homogeneous density and measures information lost when the spatial density field is replaced by its average. In the Lemaître–Tolman–Bondi dust model, the leading perturbative contribution is
38
The first nonzero term is therefore second order and proportional to the variance of the first-order density perturbation. For spherical LTB domains, the perturbative backreaction vanishes and the domain-averaged KL entropy is proportional to the averaged Weyl curvature squared through second order:
39
This is an averaged perturbative relation, not a pointwise or fully nonlinear identity (Li et al., 2014).
6. Estimation, mixtures, spatial models, and modern applications
KL divergence is often analytically tractable for individual members of a common exponential family but generally lacks a finite closed form for mixture distributions. For
40
the problematic term is
41
The logarithm prevents separation of mixture components, and even univariate Gaussian-mixture KL can be mathematically nonanalytic as a function of mixture parameters.
Deterministic mixture bounds can be constructed from piecewise log-sum-exp inequalities. Defining the weighted upper envelope
42
one has
43
Partitioning the real line into intervals on which one weighted component dominates gives computable lower and upper bounds on cross-entropy, entropy, and KL divergence. The basic additive width is bounded by
44
Adaptive bounds replace worst-case 45 terms by local residuals measuring the separation of nondominant components. They are tighter but may require pairwise intersection calculations. These methods are especially effective for univariate Gaussian mixtures, where component intersections reduce to quadratic equations (Nielsen et al., 2016).
For multivariate continuous distributions, nearest-neighbor estimators avoid full density estimation. The Kozachenko–Leonenko entropy estimator is
46
Given independent samples from 47 and 48, a kNN estimator of forward KL is
49
Under continuity, tail, moment, and support conditions, these estimators have consistency and asymptotic convergence properties. A related goodness-of-fit statistic compares the entropy of the moment-matched Gaussian with a kNN estimate of the unknown entropy:
50
Because the Gaussian uniquely maximizes differential entropy among distributions with fixed mean and covariance,
51
The statistic converges to zero under multivariate normality and to a positive limit under fixed non-Gaussian alternatives. Parametric bootstrap calibration is used for finite samples (Cadirci et al., 6 Mar 2026).
For pairwise isotropic Gaussian-Markov random fields, local conditional KL expressions reduce to determinants, traces, quadratic forms, and spatial covariance summaries. In the multivariate case, the divergence includes covariance matrices, precision matrices, cross-covariances, and a coupling-modulated Mahalanobis mean term. When the spatial dependence parameters vanish, the expression reduces to the standard multivariate Gaussian KL divergence. The resulting symmetrized divergence can be used for image denoising, texture analysis, multichannel image comparison, and unsupervised metric learning (Levada, 2022).
In multiscale molecular simulation, KL divergence compares a reference canonical ensemble with an approximate ensemble:
52
For potential-energy discrepancy
53
the exact canonical expression is
54
For small discrepancies, the leading approximation is
55
This provides an intensive measure of multiscale error and a workflow for selecting a switching distance in Relative Resolution simulations (Chaimovich et al., 2024).
KL divergence also supports information-theoretic causation measures. An intervention that shifts 56 changes the conditional distribution of a future variable 57. The local response divergence compares the perturbed and unperturbed conditional laws, while the perturbation divergence measures the information cost of the intervention. Their small-perturbation ratio is an information response:
58
The expansion is governed by a ratio of Fisher informations. In linear Gaussian systems, information response is nonlinearly related to transfer entropy:
59
This equivalence does not generally persist for nonlinear systems (Auconi et al., 2021).
Recent diffusion-model analyses use marginal KL entropy production to decompose terminal generation error into initialization, score-approximation, and time-discretization contributions. For Euler–Maruyama sampling, the marginal KL discretization contribution is bounded at order
60
under smoothness, ellipticity, and finite-Fisher-information assumptions. This is distinct from path-space KL estimates obtained through Girsanov arguments, which commonly yield order 61. The decomposition is schematically
62
The framework also compares score-based SDEs, probability-flow ODEs, flow matching, and stochastic interpolants through their current velocities and diffusion coefficients (Wu et al., 3 Aug 2026).
7. Interpretive limits and related divergences
The phrase “Kullback–Leibler entropy” can obscure three distinctions.
First, KL divergence is not Shannon entropy. 63 measures uncertainty in one law, whereas 64 measures the discrepancy between an ordered pair. Entropy can be negative in the differential case; KL divergence remains nonnegative when defined.
Second, a signed difference of KL divergences is not itself a divergence:
65
It can be positive, zero, or negative. Expanding gives
66
Its sign reflects a weighted category-wise log-ratio contrast, not support inclusion, coverage, breadth, or generality. Positive and negative category contributions can cancel. After smoothing discrete empirical distributions, all categories may have full support, so literal support comparisons are no longer available (Osaki, 3 Jun 2026).
Third, KL divergence is not universally the most appropriate discrepancy. Wasserstein distances are symmetric metrics under suitable moment assumptions and remain meaningful for singular or disjointly supported distributions. Fourier-based metrics compare characteristic functions but require moment conditions. Energy distances are symmetric, sample-computable, and metric-like under their stated conditions. These alternatives can be preferable in high-dimensional settings where density-ratio estimation is unstable, support mismatch causes infinite KL, or reliable density estimation is difficult (Auricchio et al., 15 Jul 2025).
For unbalanced optimal transport, KL penalties on marginals must be distinguished from entropy regularization of the coupling. For finite measures 67 and 68,
69
This generalized KL includes mass discrepancy. In Gaussian unbalanced transport with no coupling-entropy term, the optimizer is a mass-scaled quadratic Wasserstein coupling between adjusted Gaussian marginals and can be supported on an affine graph. Adding a coupling-entropy penalty produces a nondegenerate joint plan instead (Yang et al., 4 May 2026).
KL divergence is therefore best understood as a directional, reference-dependent information functional. Its core properties—nonnegativity, support sensitivity, convexity, data processing, large-deviation rates, variational representations, and local Fisher geometry—explain its central role in inference. The same functional appears as likelihood loss, free-energy excess, entropy-production rate, Bayesian information gain, maximum-entropy projection, model discrepancy, and predictive regret. Its interpretation always depends on the ordered distributions, the reference measure or kernel, the support conditions, and the level of coarse-graining used to represent the underlying system.