Kullback–Leibler divergence explained

In mathematical statistics, the Kullback–Leibler (KL) divergence (also called relative entropy and I-divergence[1]), denoted

DKL(P\parallelQ)

, is a type of statistical distance: a measure of how one probability distribution is different from a second, reference probability distribution .[2] Mathematically, it is defined as

DKL(P\parallelQ)=\sum}P(x) log\left(

P(x)
Q(x)

\right).

A simple interpretation of the KL divergence of from is the expected excess surprise from using as a model instead of when the actual distribution is . While it is a measure of how different two distributions are, and in some sense is thus a "distance", it is not actually a metric, which is the most familiar and formal type of distance. In particular, it is not symmetric in the two distributions (in contrast to variation of information), and does not satisfy the triangle inequality. Instead, in terms of information geometry, it is a type of divergence, a generalization of squared distance, and for certain classes of distributions (notably an exponential family), it satisfies a generalized Pythagorean theorem (which applies to squared distances).

Relative entropy is always a non-negative real number, with value 0 if and only if the two distributions in question are identical. It has diverse applications, both theoretical, such as characterizing the relative (Shannon) entropy in information systems, randomness in continuous time-series, and information gain when comparing statistical models of inference; and practical, such as applied statistics, fluid mechanics, neuroscience, bioinformatics, and machine learning.

Introduction and context

Consider two probability distributions and . Usually, represents the data, the observations, or a measured probability distribution. Distribution represents instead a theory, a model, a description or an approximation of . The Kullback–Leibler divergence

DKL(P\parallelQ)

is then interpreted as the average difference of the number of bits required for encoding samples of using a code optimized for rather than one optimized for . Note that the roles of and can be reversed in some situations where that is easier to compute, such as with the expectation–maximization algorithm (EM) and evidence lower bound (ELBO) computations.

Etymology

The relative entropy was introduced by Solomon Kullback and Richard Leibler in as "the mean information for discrimination between

H1

and

H2

per observation from

\mu1

", where one is comparing two probability measures

\mu1,\mu2

, and

H1,H2

are the hypotheses that one is selecting from measure

\mu1,\mu2

(respectively). They denoted this by

I(1:2)

, and defined the "'divergence' between

\mu1

and

\mu2

" as the symmetrized quantity

J(1,2)=I(1:2)+I(2:1)

, which had already been defined and used by Harold Jeffreys in 1948. In, the symmetrized form is again referred to as the "divergence", and the relative entropies in each direction are referred to as a "directed divergences" between two distributions; Kullback preferred the term discrimination information.[3] The term "divergence" is in contrast to a distance (metric), since the symmetrized divergence does not satisfy the triangle inequality. Numerous references to earlier uses of the symmetrized divergence and to other statistical distances are given in . The asymmetric "directed divergence" has come to be known as the Kullback–Leibler divergence, while the symmetrized "divergence" is now referred to as the Jeffreys divergence.

Definition

For discrete probability distributions and defined on the same sample space,

l{X} ,

the relative entropy from to is defined[4] to be

DKL(P\parallelQ)=\sum}P(x) log\left(

P(x)
Q(x)

\right),

which is equivalent to

DKL(P\parallelQ)=-\sum}P(x) log\left(

Q(x)
P(x)

\right)~.

In other words, it is the expectation of the logarithmic difference between the probabilities and, where the expectation is taken using the probabilities .

Relative entropy is only defined in this way if, for all,

Q(x)=0 

implies

P(x)=0 

(absolute continuity). Otherwise, it is often defined as but the value

 +infty

is possible even if

Q(x)\ne0 

everywhere,[5] [6] provided that

l{X} 

is infinite in extent. Analogous comments apply to the continuous and general measure cases defined below.

Whenever

P(x)

is zero the contribution of the corresponding term is interpreted as zero because
\lim
x\to0+

xlog(x)=0~.

For distributions and of a continuous random variable, relative entropy is defined to be the integral[7]

DKL(P\parallelQ)=

infty
\intp(x) log\left(
-infty
p(x)
q(x)

\right)dx,

where and denote the probability densities of and .

l{X} ,

and is absolutely continuous with respect to, then the relative entropy from to is defined as

DKL(P\parallelQ)=\int} log\left(

P(dx)
Q(dx)

\right)P(dx),

where

P(dx)
Q(dx)
is the Radon–Nikodym derivative of with respect to, i.e. the unique almost everywhere defined function on

l{X} 

such that

P(dx)=r(x)Q(dx)

which exists because is absolutely continuous with respect to . Also we assume the expression on the right-hand side exists. Equivalently (by the chain rule), this can be written as

DKL(P\parallelQ)=\int}

P(dx) log\left(
Q(dx)
P(dx)
Q(dx)

\right)Q(dx),

which is the entropy of relative to . Continuing in this case, if

\mu

is any measure on

l{X}

for which densities and with

P(dx)=p(x)\mu(dx)

and

Q(dx)=q(x)\mu(dx)

exist (meaning that and are both absolutely continuous with respect to

\mu

), then the relative entropy from to is given as

DKL(P\parallelQ)=\intx

} p(x)\ \log\left(\frac \right)\ \mu(\mathrm\ \!x) ~.

Note that such a measure

\mu

for which densities can be defined always exists, since one can take

\mu=

1
2

\left(P+Q\right)

although in practice it will usually be one that in the context like counting measure for discrete distributions, or Lebesgue measure or a convenient variant thereof like Gaussian measure or the uniform measure on the sphere, Haar measure on a Lie group etc. for continuous distributions. The logarithms in these formulae are usually taken to base 2 if information is measured in units of bits, or to base if information is measured in nats. Most formulas involving relative entropy hold regardless of the base of the logarithm.

Various conventions exist for referring to

DKL(P\parallelQ)

in words. Often it is referred to as the divergence between and, but this fails to convey the fundamental asymmetry in the relation. Sometimes, as in this article, it may be described as the divergence of from or as the divergence from to . This reflects the asymmetry in Bayesian inference, which starts from a prior and updates to the posterior . Another common way to refer to

DKL(P\parallelQ)

is as the relative entropy of with respect to or the information gain from over .

Basic example

Kullback gives the following example (Table 2.1, Example 2.1). Let and be the distributions shown in the table and figure. is the distribution on the left side of the figure, a binomial distribution with

N=2

and

p=0.4

. is the distribution on the right side of the figure, a discrete uniform distribution with the three possible outcomes

x=

,, (i.e.

l{X}=\{0,1,2\}

), each with probability

p=1/3

.
0 1 2
Distribution

P(x)

9{25}
12
25
4{25}
Distribution

Q(x)

1
3
1
3
1
3

Relative entropies

DKL(P\parallelQ)

and

DKL(Q\parallelP)

are calculated as follows. This example uses the natural log with base , designated to get results in nats (see units of information):

\begin{align} DKL(P\parallelQ)&=\sumx\inl{X

} P(x) \ln\left(\frac\right) \\ &= \frac \ln\left(\frac\right)+ \frac \ln\left(\frac\right)+ \frac \ln\left(\frac\right) \\& = \frac \left(32 \ln(2) + 55 \ln(3) - 50 \ln(5) \right) \approx 0.0852996,\end

\begin{align} DKL(Q\parallelP)&=\sumx\inl{X

} Q(x) \ln\left(\frac\right) \\ &= \frac \ln\left(\frac\right)+ \frac \ln\left(\frac\right)+ \frac \ln\left(\frac\right) \\ &= \frac \left(-4 \ln(2) - 6 \ln(3) + 6 \ln(5) \right) \approx 0.097455.\end

Interpretations

Statistics

In the field of statistics, the Neyman–Pearson lemma states that the most powerful way to distinguish between the two distributions and based on an observation (drawn from one of them) is through the log of the ratio of their likelihoods:

logP(Y)-logQ(Y)

. The KL divergence is the expected value of this statistic if is actually drawn from . Kullback motivated the statistic as an expected log likelihood ratio.

Coding

In the context of coding theory,

DKL(P\parallelQ)

can be constructed by measuring the expected number of extra bits required to code samples from using a code optimized for rather than the code optimized for .

Inference

In the context of machine learning,

DKL(P\parallelQ)

is often called the information gain achieved if would be used instead of which is currently used. By analogy with information theory, it is called the relative entropy of with respect to .

Expressed in the language of Bayesian inference,

DKL(P\parallelQ)

is a measure of the information gained by revising one's beliefs from the prior probability distribution to the posterior probability distribution . In other words, it is the amount of information lost when is used to approximate .[8]

Information geometry

In applications, typically represents the "true" distribution of data, observations, or a precisely calculated theoretical distribution, while typically represents a theory, model, description, or approximation of . In order to find a distribution that is closest to, we can minimize the KL divergence and compute an information projection.

While it is a statistical distance, it is not a metric, the most familiar type of distance, but instead it is a divergence. While metrics are symmetric and generalize linear distance, satisfying the triangle inequality, divergences are asymmetric and generalize squared distance, in some cases satisfying a generalized Pythagorean theorem. In general

DKL(P\parallelQ)

does not equal

DKL(Q\parallelP)

, and the asymmetry is an important part of the geometry. The infinitesimal form of relative entropy, specifically its Hessian, gives a metric tensor that equals the Fisher information metric; see . Relative entropy satisfies a generalized Pythagorean theorem for exponential families (geometrically interpreted as dually flat manifolds), and this allows one to minimize relative entropy by geometric means, for example by information projection and in maximum likelihood estimation.

The relative entropy is the Bregman divergence generated by the negative entropy, but it is also of the form of an -divergence. For probabilities over a finite alphabet, it is unique in being a member of both of these classes of statistical divergences.

Finance (game theory)

Consider a growth-optimizing investor in a fair game with mutually exclusive outcomes (e.g. a “horse race” in which the official odds add up to one).The rate of return expected by such an investor is equal to the relative entropy between the investor's believed probabilities and the official odds.[9] This is a special case of a much more general connection between financial returns and divergence measures.[10]

Financial risks are connected to

DKL

via information geometry.[11] Investors' views, the prevailing market view, and risky scenarios form triangles on the relevant manifold of probability distributions. The shape of the triangles determines key financial risks (both qualitatively and quantitatively). For instance, obtuse triangles in which investors' views and risk scenarios appear on “opposite sides” relative to the market describe negative risks, acute triangles describe positive exposure, and the right-angled situation in the middle corresponds to zero risk.

Motivation

In information theory, the Kraft–McMillan theorem establishes that any directly decodable coding scheme for coding a message to identify one value

xi

out of a set of possibilities can be seen as representing an implicit probability distribution
-\elli
q(x
i)=2
over, where

\elli

is the length of the code for

xi

in bits. Therefore, relative entropy can be interpreted as the expected extra message-length per datum that must be communicated if a code that is optimal for a given (wrong) distribution is used, compared to using a code based on the true distribution : it is the excess entropy.

\begin{align} DKL(P\parallelQ)&=\sumx\inl{X

} p(x) \log \frac - \sum_ p(x) \log \frac \\[5pt] &= \Eta(P, Q) - \Eta(P)\end

where

Η(P,Q)

is the cross entropy of and, and

Η(P)

is the entropy of (which is the same as the cross-entropy of P with itself).

The relative entropy

DKL(P\parallelQ)

can be thought of geometrically as a statistical distance, a measure of how far the distribution is from the distribution . Geometrically it is a divergence: an asymmetric, generalized form of squared distance. The cross-entropy

H(P,Q)

is itself such a measurement (formally a loss function), but it cannot be thought of as a distance, since

H(P,P)=:H(P)

is not zero. This can be fixed by subtracting

H(P)

to make

DKL(P\parallelQ)

agree more closely with our notion of distance, as the excess loss. The resulting function is asymmetric, and while this can be symmetrized (see), the asymmetric form is more useful. See for more on the geometric interpretation.

Relative entropy relates to "rate function" in the theory of large deviations.[12] [13]

Arthur Hobson proved that relative entropy is the only measure of difference between probability distributions that satisfies some desired properties, which are the canonical extension to those appearing in a commonly used characterization of entropy.[14] Consequently, mutual information is the only measure of mutual dependence that obeys certain related conditions, since it can be defined in terms of Kullback–Leibler divergence.

Properties

DKL(P\parallelQ)

equals zero if and only if

P=Q

as measures.

In particular, if

P(dx)=p(x)\mu(dx)

and

Q(dx)=q(x)\mu(dx)

, then

p(x)=q(x)

\mu

-almost everywhere. The entropy

Η(P)

thus sets a minimum value for the cross-entropy

Η(P,Q)

, the expected number of bits required when using a code based on rather than ; and the Kullback–Leibler divergence therefore represents the expected number of extra bits that must be transmitted to identify a value drawn from, if a code is used corresponding to the probability distribution, rather than the "true" distribution .

DKL(P\parallelQ)

can be calculated.[15]

y(x)

, then, since

P(dx)=p(x)dx=\tilde{p}(y)dy=\tilde{p}(y(x))|\tfrac{dy}{dx}(x)|dx

and

Q(dx)=q(x)dx=\tilde{q}(y)dy=\tilde{q}(y)|\tfrac{dy}{dx}(x)|dx

where

|\tfrac{dy}{dx}(x)|

is the absolute value of the derivative or more generally of the Jacobian, the relative entropy may be rewritten: \begin D_\text(P \parallel Q) &= \int_^ p(x) \log\left(\frac\right)\, dx \\[6pt] &= \int_^ \tilde(y(x)) |\frac(x)| \log\left(\frac\right)\, dx \\ &= \int_^ \tilde(y)\log\left(\frac\right)\, dy\end where

ya=y(xa)

and

yb=y(xb)

. Although it was assumed that the transformation was continuous, this need not be the case. This also shows that the relative entropy produces a dimensionally consistent quantity, since if is a dimensioned variable,

p(x)

and

q(x)

are also dimensioned, since e.g.

P(dx)=p(x)dx

is dimensionless. The argument of the logarithmic term is and remains dimensionless, as it must. It can therefore be seen as in some ways a more fundamental quantity than some other properties in information theory[16] (such as self-information or Shannon entropy), which can become undefined or negative for non-discrete probabilities.

P1,P2

are independent distributions, and

P(dx,dy)=P1(dx)P2(dy)

, and likewise

Q(dx,dy)=Q1(dx)Q2(dy)

for independent distributions

Q1,Q2

then D_\text(P \parallel Q) = D_\text(P_1 \parallel Q_1) + D_\text(P_2 \parallel Q_2).

DKL(P\parallelQ)

is convex in the pair of probability measures

(P,Q)

, i.e. if

(P1,Q1)

and

(P2,Q2)

are two pairs of probability measures then D_\text(\lambda P_1 + (1 - \lambda) P_2 \parallel \lambda Q_1 + (1 - \lambda) Q_2) \le \lambda D_\text(P_1 \parallel Q_1) + (1 - \lambda)D_\text(P_2 \parallel Q_2) \text 0 \le \lambda \le 1.

DKL(P\parallelQ)

may be Taylor expanded about its minimum (i.e.

P=Q

) as D_\text(P \parallel Q) = \sum_^\infty \frac \sum_ \frac which converges if and only if

P\leq2Q

almost surely w.r.t

Q

.Denote

f(\alpha):=DKL((1-\alpha)Q+\alphaP\parallelQ)

and note that

DKL(P\parallelQ)=f(1)

. The first derivative of

f

may be derived and evaluated as follows\beginf'(\alpha) &= \sum_ (P(x) - Q(x)) \left(\log\left(\frac\right) + 1\right)\\ &= \sum_ (P(x) - Q(x)) \log\left(\frac\right)\\ f'(0) &= 0\endFurther derivatives may be derived and evaluated as follows\beginf(\alpha) &= \sum_ \frac\\ f(0) &= \sum_ \frac\\ f^(\alpha) &= (-1)^n (n-2)!\sum_ \frac\\ f^(0) &= (-1)^n (n-2)!\sum_ \frac\endHence solving for

DKL(P\parallelQ)

via the Taylor expansion of

f

about

0

evaluated at

\alpha=1

yields\beginD_\text(P \parallel Q) &= \sum_^\infty \frac\\ &= \sum_^\infty \frac \sum_ \frac\end

P\leq2Q

a.s. is a sufficient condition for convergence of the series by the following absolute convergence argument\begin\sum_^\infty \left\vert\frac \sum_ \frac\right\vert &= \sum_^\infty \frac \sum_ \left\vert Q(x) - P(x) \right\vert \left\vert 1 - \frac \right\vert^\\ &\leq \sum_^\infty \frac \sum_ \left\vert Q(x) - P(x) \right\vert\\ &\leq \sum_^\infty \frac\\ &= 1\end

P\leq2Q

a.s. is also a necessary condition for convergence of the series by the following proof by contradiction. Assume that

P>2Q

with measure strictly greater than

0

. It then follows that there must exist some values

\epsilon>0

,

\rho>0

, and

U<infty

such that

P\geq2Q+\epsilon

and

Q\leqU

with measure

\rho

. The previous proof of sufficiency demonstrated that the measure

1-\rho

component of the series where

P\leq2Q

is bounded, so we need only concern ourselves with the behavior of the measure

\rho

component of the series where

P\geq2Q+\epsilon

. The absolute value of the

n

th term of this component of the series is then lower bounded by
1{n(n-1)}
\rho

\left(1+

\epsilon
U

\right)n

, which is unbounded as

n\toinfty

, so the series diverges.

Duality formula for variational inference

The following result, due to Donsker and Varadhan,[17] is known as Donsker and Varadhan's variational formula.

For alternative proof using measure theory, see.[18]

Examples

Multivariate normal distributions

Suppose that we have two multivariate normal distributions, with means

\mu0,\mu1

and with (non-singular) covariance matrices

\Sigma0,\Sigma1.

If the two distributions have the same dimension,, then the relative entropy between the distributions is as follows:[19]

DKL\left(l{N}0\parallell{N}1\right)=

1
2

\left(

-1
\operatorname{tr}\left(\Sigma
1

\Sigma0\right)-k+ \left(\mu1-

T
\mu
0\right)
-1
\Sigma
1

\left(\mu1-\mu0\right)+ ln\left(

\det\Sigma1
\det\Sigma0

\right) \right).

The logarithm in the last term must be taken to base since all terms apart from the last are base- logarithms of expressions that are either factors of the density function or otherwise arise naturally. The equation therefore gives a result measured in nats. Dividing the entire expression above by

ln(2)

yields the divergence in bits.

In a numerical implementation, it is helpful to express the result in terms of the Cholesky decompositions

L0,L1

such that

\Sigma0=L0L

T
0
and

\Sigma1=L1L

T
1
. Then with and solutions to the triangular linear systems

L1M=L0

, and

L1y=\mu1-\mu0

,

DKL\left(l{N}0\parallell{N}1\right)=

1
2

\left(

k
\sum
i,j=1

(Mij)2-k+ |y|2+

k
2\sum
i=1

ln

(L1)ii
(L0)ii

\right).

A special case, and a common quantity in variational inference, is the relative entropy between a diagonal multivariate normal, and a standard normal distribution (with zero mean and unit variance):

DKL\left(l{N}\left(\left(\mu1,\ldots,

T,
\mu
k\right)

\operatorname{diag}

2,
\left(\sigma
1

\ldots,

2\right)\right)
\sigma
k

\parallel l{N}\left(0,I\right) \right)= {1\over2}

k
\sum
i=1
2
\left(\sigma
i

+

2
\mu
i

-1-

2\right)\right).
ln\left(\sigma
i

For two univariate normal distributions and the above simplifies to[20]

DKL\left(l{p}\parallell{q}\right)=log

\sigma1
\sigma0

+

2
\sigma+(\mu0-\mu
2
1)
0
2
2\sigma
1

-

1
2

In the case of co-centered normal distributions with

k=\sigma1/\sigma0

, this simplifies[21] to:

DKL\left(l{p}\parallell{q}\right)=log2k+(k-2-1)/2/ln(2)bits

Uniform distributions

Consider two uniform distributions, with the support of

p=[A,B]

enclosed within

q=[C,D]

(

C\leA<B\leD

). Then the information gain is:

DKL\left(l{p}\parallell{q}\right)=log

D-C
B-A

Intuitively,[21] the information gain to a times narrower uniform distribution contains

log2k

bits. This connects with the use of bits in computing, where

log2k

bits would be needed to identify one element of a long stream.

Relation to metrics

While relative entropy is a statistical distance, it is not a metric on the space of probability distributions, but instead it is a divergence. While metrics are symmetric and generalize linear distance, satisfying the triangle inequality, divergences are asymmetric in general and generalize squared distance, in some cases satisfying a generalized Pythagorean theorem. In general

DKL(P\parallelQ)

does not equal

DKL(Q\parallelP)

, and while this can be symmetrized (see), the asymmetry is an important part of the geometry.

It generates a topology on the space of probability distributions. More concretely, if

\{P1,P2,\ldots\}

is a sequence of distributions such that

\limnDKL(Pn\parallelQ)=0

,

then it is said that

Pn\xrightarrow{D}Q

.

Pinsker's inequality entails that

Pn\xrightarrow{D}PPn\xrightarrow{TV}P

,

where the latter stands for the usual convergence in total variation.

Fisher information metric

Relative entropy is directly related to the Fisher information metric. This can be made explicit as follows. Assume that the probability distributions and are both parameterized by some (possibly multi-dimensional) parameter

\theta

. Consider then two close by values of

P=P(\theta)

and

Q=P(\theta0)

so that the parameter

\theta

differs by only a small amount from the parameter value

\theta0

. Specifically, up to first order one has (using the Einstein summation convention)

P(\theta)=P(\theta0)+\Delta\thetajPj(\theta0)+

with

\Delta\thetaj=(\theta-\theta0)j

a small change of

\theta

in the direction, and

Pj\left(\theta0\right)=

\partialP
\partial\thetaj

(\theta0)

the corresponding rate of change in the probability distribution. Since relative entropy has an absolute minimum 0 for

P=Q

, i.e.

\theta=\theta0

, it changes only to second order in the small parameters

\Delta\thetaj

. More formally, as for any minimum, the first derivatives of the divergence vanish
\left.\partial
\partial\thetaj
\right|
\theta=\theta0

DKL(P(\theta)\parallelP(\theta0))=0,

and by the Taylor expansion one has up to second order

DKL(P(\theta)\parallelP(\theta0))=

1
2

\Delta\thetaj\Delta\thetakgjk(\theta0)+

where the Hessian matrix of the divergence

gjk(\theta0)=\left.

\partial2
\partial\thetaj\partial\thetak
\right|
\theta=\theta0

DKL(P(\theta)\parallelP(\theta0))

must be positive semidefinite. Letting

\theta0

vary (and dropping the subindex 0) the Hessian

gjk(\theta)

defines a (possibly degenerate) Riemannian metric on the parameter space, called the Fisher information metric.

Fisher information metric theorem

When

p(x,

satisfies the following regularity conditions:
\partiallog(p)
\partial\rho

,

\partial2log(p)
\partial\rho2

,

\partial3log(p)
\partial\rho3
exist,

\begin{align} \left|

\partialp
\partial\rho

\right|&<F(x):

infty
\int
x=0

F(x)dx<infty,\ \left|

\partial2p
\partial\rho2

\right|&<G(x):

infty
\int
x=0

G(x)dx<infty\ \left|

\partial3log(p)
\partial\rho3

\right|&<H(x):

infty
\int
x=0

p(x,0)H(x)dx<\xi<infty \end{align}

where is independent of

infty
\left.\int
x=0
\partialp(x,\rho)
\partial\rho

\right|\rho=0dx=

infty
\left.\int
x=0
\partial2p(x,\rho)
\partial\rho2

\right|\rho=0dx=0

then:

l{D}(p(x,0)\parallelp(x,\rho))=

c\rho2
2

+l{O}\left(\rho3\right)as\rho\to0.

Variation of information

Another information-theoretic metric is variation of information, which is roughly a symmetrization of conditional entropy. It is a metric on the set of partitions of a discrete probability space.

Relation to other quantities of information theory

Many of the other quantities of information theory can be interpreted as applications of relative entropy to specific cases.

Self-information

See main article: Information content. The self-information, also known as the information content of a signal, random variable, or event is defined as the negative logarithm of the probability of the given outcome occurring.

When applied to a discrete random variable, the self-information can be represented as

\operatorname\operatorname{I}(m)=DKL\left(\deltaim\parallel\{pi\}\right),

is the relative entropy of the probability distribution

P(i)

from a Kronecker delta representing certainty that

i=m

— i.e. the number of extra bits that must be transmitted to identify if only the probability distribution

P(i)

is available to the receiver, not the fact that

i=m

.

Mutual information

The mutual information,

\begin{align} \operatorname{I}(X;Y) &=DKL(P(X,Y)\parallelP(X)P(Y))\\[5pt] &=\operatorname{E}X\{DKL(P(Y\midX)\parallelP(Y))\}\\[5pt] &=\operatorname{E}Y\{DKL(P(X\midY)\parallelP(X))\} \end{align}

P(X,Y)

from the product

P(X)P(Y)

of the two marginal probability distributions — i.e. the expected number of extra bits that must be transmitted to identify and if they are coded using only their marginal distributions instead of the joint distribution. Equivalently, if the joint probability

P(X,Y)

is known, it is the expected number of extra bits that must on average be sent to identify if the value of is not already known to the receiver.

Shannon entropy

The Shannon entropy,

\begin{align} Η(X)&=\operatorname{E}\left[\operatorname{I}X(x)\right]\\ &=log(N)-DKL\left(pX(x)\parallelPU(X)\right) \end{align}

is the number of bits which would have to be transmitted to identify from equally likely possibilities, less the relative entropy of the uniform distribution on the random variates of,

PU(X)

, from the true distribution

P(X)

— i.e. less the expected number of bits saved, which would have had to be sent if the value of were coded according to the uniform distribution

PU(X)

rather than the true distribution

P(X)

. This definition of Shannon entropy forms the basis of E.T. Jaynes's alternative generalization to continuous distributions, the limiting density of discrete points (as opposed to the usual differential entropy), which defines the continuous entropy as

\limNHN(X)=log(N)-\intp(x)log

p(x)
m(x)

dx,

which is equivalent to:

log(N)-DKL(p(x)||m(x))

Conditional entropy

The conditional entropy,

\begin{align} Η(X\midY) &=log(N)-DKL(P(X,Y)\parallelPU(X)P(Y))\\[5pt] &=log(N)-DKL(P(X,Y)\parallelP(X)P(Y))-DKL(P(X)\parallelPU(X))\\[5pt] &=Η(X)-\operatorname{I}(X;Y)\\[5pt] &=log(N)-\operatorname{E}Y\left[DKL\left(P\left(X\midY\right)\parallelPU(X)\right)\right] \end{align}

is the number of bits which would have to be transmitted to identify from equally likely possibilities, less the relative entropy of the product distribution

PU(X)P(Y)

from the true joint distribution

P(X,Y)

— i.e. less the expected number of bits saved which would have had to be sent if the value of were coded according to the uniform distribution

PU(X)

rather than the conditional distribution

P(X|Y)

of given .

Cross entropy

When we have a set of possible events, coming from the distribution, we can encode them (with a lossless data compression) using entropy encoding. This compresses the data by replacing each fixed-length input symbol with a corresponding unique, variable-length, prefix-free code (e.g.: the events (A, B, C) with probabilities p = (1/2, 1/4, 1/4) can be encoded as the bits (0, 10, 11)). If we know the distribution in advance, we can devise an encoding that would be optimal (e.g.: using Huffman coding). Meaning the messages we encode will have the shortest length on average (assuming the encoded events are sampled from), which will be equal to Shannon's Entropy of (denoted as

Η(p)

). However, if we use a different probability distribution when creating the entropy encoding scheme, then a larger number of bits will be used (on average) to identify an event from a set of possibilities. This new (larger) number is measured by the cross entropy between and .

The cross entropy between two probability distributions (and) measures the average number of bits needed to identify an event from a set of possibilities, if a coding scheme is used based on a given probability distribution, rather than the "true" distribution . The cross entropy for two distributions and over the same probability space is thus defined as follows.

Η(p,q)=\operatorname{E}p[-log(q)]=Η(p)+DKL(p\parallelq).

For explicit derivation of this, see the Motivation section above.

Under this scenario, relative entropies (kl-divergence) can be interpreted as the extra number of bits, on average, that are needed (beyond

Η(p)

) for encoding the events because of using for constructing the encoding scheme instead of .

Bayesian updating

In Bayesian statistics, relative entropy can be used as a measure of the information gain in moving from a prior distribution to a posterior distribution:

p(x)\top(x\midI)

. If some new fact

Y=y

is discovered, it can be used to update the posterior distribution for from

p(x\midI)

to a new posterior distribution

p(x\midy,I)

using Bayes' theorem:

p(x\midy,I)=

p(y\midx,I)p(x\midI)
p(y\midI)

This distribution has a new entropy:

Η(p(x\midy,I))=-\sumxp(x\midy,I)logp(x\midy,I),

which may be less than or greater than the original entropy

Η(p(x\midI))

. However, from the standpoint of the new probability distribution one can estimate that to have used the original code based on

p(x\midI)

instead of a new code based on

p(x\midy,I)

would have added an expected number of bits:

DKL(p(x\midy,I)\parallelp(x\midI))=\sumxp(x\midy,I)log\left(

p(x\midy,I)
p(x\midI)

\right)

to the message length. This therefore represents the amount of useful information, or information gain, about, that has been learned by discovering

Y=y

.

If a further piece of data,

Y2=y2

, subsequently comes in, the probability distribution for can be updated further, to give a new best guess

p(x\midy1,y2,I)

. If one reinvestigates the information gain for using

p(x\midy1,I)

rather than

p(x\midI)

, it turns out that it may be either greater or less than previously estimated:

\sumxp(x\midy1,y2,I)log\left(

p(x\midy1,y2,I)
p(x\midI)

\right)

may be ≤ or > than

\displaystyle\sumxp(x\midy1,I)log\left(

p(x\midy1,I)
p(x\midI)

\right)

and so the combined information gain does not obey the triangle inequality:

DKL(p(x\midy1,y2,I)\parallelp(x\midI))

may be <, = or > than

DKL(p(x\midy1,y2,I)\parallelp(x\midy1,I))+DKL(p(x\midy1,I)\parallelp(x\midI))

All one can say is that on average, averaging using

p(y2\midy1,x,I)

, the two sides will average out.

Bayesian experimental design

A common goal in Bayesian experimental design is to maximise the expected relative entropy between the prior and the posterior.[22] When posteriors are approximated to be Gaussian distributions, a design maximising the expected relative entropy is called Bayes d-optimal.

Discrimination information

Relative entropy D_\text\bigl(p(x \mid H_1) \parallel p(x \mid H_0)\bigr) can also be interpreted as the expected discrimination information for

H1

over

H0

: the mean information per sample for discriminating in favor of a hypothesis

H1

against a hypothesis

H0

, when hypothesis

H1

is true.[23] Another name for this quantity, given to it by I. J. Good, is the expected weight of evidence for

H1

over

H0

to be expected from each sample.

The expected weight of evidence for

H1

over

H0

is not the same as the information gain expected per sample about the probability distribution

p(H)

of the hypotheses,

DKL(p(x\midH1)\parallelp(x\midH0))IG=DKL(p(H\midx)\parallelp(H\midI)).

Either of the two quantities can be used as a utility function in Bayesian experimental design, to choose an optimal next question to investigate: but they will in general lead to rather different experimental strategies.

On the entropy scale of information gain there is very little difference between near certainty and absolute certainty—coding according to a near certainty requires hardly any more bits than coding according to an absolute certainty. On the other hand, on the logit scale implied by weight of evidence, the difference between the two is enormous – infinite perhaps; this might reflect the difference between being almost sure (on a probabilistic level) that, say, the Riemann hypothesis is correct, compared to being certain that it is correct because one has a mathematical proof. These two different scales of loss function for uncertainty are both useful, according to how well each reflects the particular circumstances of the problem in question.

Principle of minimum discrimination information

The idea of relative entropy as discrimination information led Kullback to propose the Principle of (MDI): given new facts, a new distribution should be chosen which is as hard to discriminate from the original distribution

f0

as possible; so that the new data produces as small an information gain

DKL(f\parallelf0)

as possible.

For example, if one had a prior distribution

p(x,a)

over and, and subsequently learnt the true distribution of was

u(a)

, then the relative entropy between the new joint distribution for and,

q(x\mida)u(a)

, and the earlier prior distribution would be:

DKL(q(x\mida)u(a)\parallelp(x,a))=\operatorname{E}u(a)\left\{DKL(q(x\mida)\parallelp(x\mida))\right\}+DKL(u(a)\parallelp(a)),

i.e. the sum of the relative entropy of

p(a)

the prior distribution for from the updated distribution

u(a)

, plus the expected value (using the probability distribution

u(a)

) of the relative entropy of the prior conditional distribution

p(x\mida)

from the new conditional distribution

q(x\mida)

. (Note that often the later expected value is called the conditional relative entropy (or conditional Kullback–Leibler divergence) and denoted by

DKL(q(x\mida)\parallelp(x\mida))

) This is minimized if

q(x\mida)=p(x\mida)

over the whole support of

u(a)

; and we note that this result incorporates Bayes' theorem, if the new distribution

u(a)

is in fact a δ function representing certainty that has one particular value.

MDI can be seen as an extension of Laplace's Principle of Insufficient Reason, and the Principle of Maximum Entropy of E.T. Jaynes. In particular, it is the natural extension of the principle of maximum entropy from discrete to continuous distributions, for which Shannon entropy ceases to be so useful (see differential entropy), but the relative entropy continues to be just as relevant.

In the engineering literature, MDI is sometimes called the Principle of Minimum Cross-Entropy (MCE) or Minxent for short. Minimising relative entropy from to with respect to is equivalent to minimizing the cross-entropy of and, since

Η(p,m)=Η(p)+DKL(p\parallelm),

which is appropriate if one is trying to choose an adequate approximation to . However, this is just as often not the task one is trying to achieve. Instead, just as often it is that is some fixed prior reference measure, and that one is attempting to optimise by minimising

DKL(p\parallelm)

subject to some constraint. This has led to some ambiguity in the literature, with some authors attempting to resolve the inconsistency by redefining cross-entropy to be

DKL(p\parallelm)

, rather than

Η(p,m)

.

Relationship to available work

Surprisals[24] add where probabilities multiply. The surprisal for an event of probability is defined as

s=kln(1/p)

. If is

\left\{1,1/ln2,1.38 x 10-23\right\}

then surprisal is in

\{

nats, bits, or

J/K\}

so that, for instance, there are bits of surprisal for landing all "heads" on a toss of coins.

Best-guess states (e.g. for atoms in a gas) are inferred by maximizing the average surprisal (entropy) for a given set of control parameters (like pressure or volume). This constrained entropy maximization, both classically[25] and quantum mechanically,[26] minimizes Gibbs availability in entropy units[27]

A\equiv-kln(Z)

where is a constrained multiplicity or partition function.

When temperature is fixed, free energy (

T x A

) is also minimized. Thus if

T,V

and number of molecules are constant, the Helmholtz free energy

F\equivU-TS

(where is energy and is entropy) is minimized as a system "equilibrates." If and are held constant (say during processes in your body), the Gibbs free energy

G=U+PV-TS

is minimized instead. The change in free energy under these conditions is a measure of available work that might be done in the process. Thus available work for an ideal gas at constant temperature

To

and pressure

Po

is

W=\DeltaG=NkTo\Theta(V/Vo)

where

Vo=NkTo/Po

and

\Theta(x)=x-1-lnx\ge0

(see also Gibbs inequality).

More generally[28] the work available relative to some ambient is obtained by multiplying ambient temperature

To

by relative entropy or net surprisal

\DeltaI\ge0,

defined as the average value of

kln(p/po)

where

po

is the probability of a given state under ambient conditions. For instance, the work available in equilibrating a monatomic ideal gas to ambient values of

Vo

and

To

is thus

W=To\DeltaI

, where relative entropy

\DeltaI=Nk\left[\Theta\left(

V
Vo

\right)+

3\Theta\left(
2
T
To

\right)\right].

The resulting contours of constant relative entropy, shown at right for a mole of Argon at standard temperature and pressure, for example put limits on the conversion of hot to cold as in flame-powered air-conditioning or in the unpowered device to convert boiling-water to ice-water discussed here.[29] Thus relative entropy measures thermodynamic availability in bits.

Quantum information theory

For density matrices and on a Hilbert space, the quantum relative entropy from to is defined to be

DKL(P\parallelQ)=\operatorname{Tr}(P(log(P)-log(Q))).

In quantum information science the minimum of

DKL(P\parallelQ)

over all separable states can also be used as a measure of entanglement in the state .

Relationship between models and reality

Just as relative entropy of "actual from ambient" measures thermodynamic availability, relative entropy of "reality from a model" is also useful even if the only clues we have about reality are some experimental measurements. In the former case relative entropy describes distance to equilibrium or (when multiplied by ambient temperature) the amount of available work, while in the latter case it tells you about surprises that reality has up its sleeve or, in other words, how much the model has yet to learn.

Although this tool for evaluating models against systems that are accessible experimentally may be applied in any field, its application to selecting a statistical model via Akaike information criterion are particularly well described in papers[30] and a book[31] by Burnham and Anderson. In a nutshell the relative entropy of reality from a model may be estimated, to within a constant additive term, by a function of the deviations observed between data and the model's predictions (like the mean squared deviation) . Estimates of such divergence for models that share the same additive term can in turn be used to select among models.

When trying to fit parametrized models to data there are various estimators which attempt to minimize relative entropy, such as maximum likelihood and maximum spacing estimators.

Symmetrised divergence

also considered the symmetrized function:

DKL(P\parallelQ)+DKL(Q\parallelP)

which they referred to as the "divergence", though today the "KL divergence" refers to the asymmetric function (see for the evolution of the term). This function is symmetric and nonnegative, and had already been defined and used by Harold Jeffreys in 1948; it is accordingly called the Jeffreys divergence.

This quantity has sometimes been used for feature selection in classification problems, where and are the conditional pdfs of a feature under two different classes. In the Banking and Finance industries, this quantity is referred to as Population Stability Index (PSI), and is used to assess distributional shifts in model features through time.

An alternative is given via the

λ

-divergence,

Dλ(P\parallelQ)=λDKL(P\parallelλP+(1-λ)Q)+(1-λ)DKL(Q\parallelλP+(1-λ)Q),

which can be interpreted as the expected information gain about from discovering which probability distribution is drawn from, or, if they currently have probabilities

λ

and

1-λ

respectively.

The value

λ=0.5

gives the Jensen–Shannon divergence, defined by

DJS=

1
2

DKL(P\parallelM)+

1
2

DKL(Q\parallelM)

where is the average of the two distributions,

M=

1
2

(P+Q).

We can also interpret

DJS

as the capacity of a noisy information channel with two inputs giving the output distributions and . The Jensen–Shannon divergence, like all -divergences, is locally proportional to the Fisher information metric. It is similar to the Hellinger metric (in the sense that it induces the same affine connection on a statistical manifold).

Furthermore, the Jensen–Shannon divergence can be generalized using abstract statistical M-mixtures relying on an abstract mean M.[32] [33]

Relationship to other probability-distance measures

There are many other important measures of probability distance. Some of these are particularly connected with relative entropy. For example:

\delta(p,q)

. This is connected to the divergence through Pinsker's inequality: \delta(P, Q) \le \sqrt. Pinsker's inequality is vacuous for any distributions where

DKL(P\parallelQ)>2

, since the total variation distance is at most . For such distributions, an alternative bound can be used, due to Bretagnolle and Huber[34] (see, also, Tsybakov[35]): \delta(P,Q) \le \sqrt.

\alpha

, various inequalities may be deduced.

Other notable measures of distance include the Hellinger distance, histogram intersection, Chi-squared statistic, quadratic form distance, match distance, Kolmogorov–Smirnov distance, and earth mover's distance.[36]

Data differencing

See main article: Data differencing. Just as absolute entropy serves as theoretical background for data compression, relative entropy serves as theoretical background for data differencing – the absolute entropy of a set of data in this sense being the data required to reconstruct it (minimum compressed size), while the relative entropy of a target set of data, given a source set of data, is the data required to reconstruct the target given the source (minimum size of a patch).

See also

References

External links

Notes and References

  1. Csiszar. I. I-Divergence Geometry of Probability Distributions and Minimization Problems. Ann. Probab.. 3. 1. 146–158. February 1975. 10.1214/aop/1176996454. free.
  2. Kullback . S. . Solomon Kullback . Leibler . R.A. . Richard Leibler . 1951 . On information and sufficiency . . 22 . 1 . 79–86 . 10.1214/aoms/1177729694 . 39968. 2236703 . free.
  3. S. . Kullback . Solomon Kullback . 1987 . Letter to the Editor: The Kullback–Leibler distance . . 41 . 4 . 340–341 . 2684769 . 10.1080/00031305.1987.10475510.
  4. Book: MacKay, David J.C. . 2003 . [{{google books| plainurl=y |id=AKuMj4PN_EMC}} Information Theory, Inference, and Learning Algorithms ]. Cambridge University Press . 9780521642989 . 1st . 34 . Google Books .
  5. Web site: What's the maximum value of Kullback-Leibler (KL) divergence? . Machine learning . Cross validated . Statistics Stack Exchange (stats.stackexchange.com) .
  6. Web site: In what situations is the integral equal to infinity? . Integration . Mathematics Stack Exchange (math.stackexchange.com) .
  7. Book: Bishop, Christopher M. . Pattern recognition and machine learning . 1334664824 . 55 .
  8. Book: Burnham . K. P. . Anderson . D. R. . 2002 . Model Selection and Multi-Model Inference . Springer . 2nd . 51 . registration . 9780387953649 .
  9. Kelly . J. L. Jr. . 1956 . A New Interpretation of Information Rate . Bell Syst. Tech. J. . 2 . 4 . 917–926 . 10.1002/j.1538-7305.1956.tb03809.x .
  10. Soklakov . A. N. . 2020 . Economics of Disagreement—Financial Intuition for the Rényi Divergence . Entropy . 22 . 8 . 860 . 10.3390/e22080860 . 33286632 . 7517462 . 1811.08308 . 2020Entrp..22..860S . free .
  11. Soklakov . A. N. . 2023 . Information Geometry of Risks and Returns . Risk . June . 4134885.
  12. Sanov . I.N. . 1957 . On the probability of large deviations of random magnitudes . Mat. Sbornik . 42 . 84. 11–44 .
  13. Novak S.Y. (2011), Extreme Value Methods with Applications to Finance ch. 14.5 (Chapman & Hall). .
  14. Book: Hobson. Arthur. Concepts in statistical mechanics.. 1971. Gordon and Breach. New York. 978-0677032405.
  15. Bonnici . V. . Vincenzo Bonnici . 2020 . Kullback-Leibler divergence between quantum distributions, and its upper-bound . cs.LG . 2008.05932.
  16. See the section "differential entropy – 4" in Relative Entropy video lecture by Sergio Verdú NIPS 2009
  17. Donsker . Monroe D. . Varadhan . SR Srinivasa . Asymptotic evaluation of certain Markov process expectations for large time. IV.. Communications on Pure and Applied Mathematics. 1983. 36 . 2 . 183–212. 10.1002/cpa.3160360204 .
  18. Lee. Se Yoon. Gibbs sampler and coordinate ascent variational inference: A set-theoretical review. Communications in Statistics - Theory and Methods. 2021. 51 . 6 . 1549–1568 . 10.1080/03610926.2021.1921214. 2008.01006. 220935477 .
  19. Web site: Duchi J.. Derivations for Linear Algebra and Optimization. 13.
  20. Belov . Dmitry I. . Armstrong . Ronald D. . 2011-04-15 . Distributions of the Kullback-Leibler divergence with applications . British Journal of Mathematical and Statistical Psychology . 64 . 2 . 291–309 . 10.1348/000711010x522227 . 21492134 . 0007-1102.
  21. Book: Buchner, Johannes . An intuition for physicists: information gain from experiments . 2022-04-29 . 1363563215.
  22. Chaloner . K. . Verdinelli . I. . 1995 . Bayesian experimental design: a review . . 10 . 3. 273–304 . 10.1214/ss/1177009939 . free . 11299/199630 . free .
  23. Book: Press . W.H. . Teukolsky . S.A. . Vetterling . W.T. . Flannery . B.P. . 2007 . Numerical Recipes: The Art of Scientific Computing . 3rd . Cambridge University Press . 978-0-521-88068-8 . Section 14.7.2. Kullback–Leibler Distance . http://apps.nrbook.com/empanel/index.html#pg=756 . Numerical Recipes .
  24. Book: Tribus, Myron . [{{google books |plainurl=y |id=eyrYrQEACAAJ}} Thermostatics and Thermodynamics: An Introduction to Energy, Information and States of Matter, with Engineering Applications ]. 1959 . Van Nostrand . en.
  25. Jaynes . E. T. . 1957 . Information theory and statistical mechanics . Physical Review . 106 . 4. 620–630 . 10.1103/physrev.106.620 . 1957PhRv..106..620J . 17870175 .
  26. Jaynes . E. T. . 1957 . Information theory and statistical mechanics II . Physical Review . 108 . 2. 171–190 . 10.1103/physrev.108.171 . 1957PhRv..108..171J .
  27. Book: Gibbs, Josiah Willard . [{{google books |plainurl=y |id=6ijzXwAACAAJ}} A Method of Geometrical Representation of the Thermodynamic Properties of Substances by Means of Surfaces ]. 1871 . The Academy . en. footnote page 52.
  28. Tribus . M. . McIrvine . E. C. . 1971 . Energy and information . Scientific American . 224 . 3. 179–186 . 10.1038/scientificamerican0971-179. 1971SciAm.225c.179T .
  29. Fraundorf . P. . 2007 . Thermal roots of correlation-based complexity . https://archive.today/20110813083358/http://www3.interscience.wiley.com/cgi-bin/abstract/117861985/ABSTRACT. dead. 2011-08-13. Complexity . 13 . 3. 18–26 . 10.1002/cplx.20195. 2008Cmplx..13c..18F. 1103.2481. 20794688 .
  30. Burnham . K.P. . Anderson . D.R. . 2001 . Kullback–Leibler information as a basis for strong inference in ecological studies . Wildlife Research . 28 . 2. 111–119 . 10.1071/WR99107 . free .
  31. Book: Burnham, Kenneth P. . Model selection and multimodel inference : a practical information-theoretic approach . December 2010 . Springer . 978-1-4419-2973-0 . 878132909.
  32. Nielsen . Frank . 2019 . On the Jensen–Shannon Symmetrization of Distances Relying on Abstract Means . . 21 . 5 . 485 . 10.3390/e21050485. 33267199 . 7514974 . 1904.04017 . 2019Entrp..21..485N . free.
  33. Nielsen . Frank . 2020 . On a Generalization of the Jensen–Shannon Divergence and the Jensen–Shannon Centroid . . 22 . 2 . 221 . 10.3390/e22020221. 33285995 . 7516653 . 1912.00610 . 2020Entrp..22..221N . free.
  34. Lemma 2.1
  35. Book: B.), Tsybakov, A. B. (Alexandre . Introduction to nonparametric estimation . 2010 . Springer . 978-1-4419-2709-5 . 757859245. Equation 2.25.
  36. Rubner . Y. . Leonidas J. Guibas . Tomasi . C. . Guibas . L. J. . 2000 . The earth mover's distance as a metric for image retrieval . . 40 . 2. 99–121 . 10.1023/A:1026543900054 . 14106275 .