Kullback–Leibler divergence

From testwiki
Jump to navigation Jump to search

Template:Short description In mathematical statistics, the Kullback–Leibler (KL) divergence (also called relative entropy and I-divergence[1]), denoted DKL(PQ), is a type of statistical distance: a measure of how much a model probability distribution Template:Mvar is different from a true probability distribution Template:Mvar.[2]Template:Sfn Mathematically, it is defined as

DKL(PQ)=x𝒳P(x) log( P(x) Q(x)).

A simple interpretation of the KL divergence of Template:Mvar from Template:Mvar is the expected excess surprise from using Template:Mvar as a model instead of Template:Mvar when the actual distribution is Template:Mvar. While it is a measure of how different two distributions are and is thus a "distance" in some sense, 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,Template:Sfn 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).Template:Sfn

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.

Template:Toclimit

Introduction and context

Consider two probability distributions Template:Mvar and Template:Mvar. Usually, Template:Mvar represents the data, the observations, or a measured probability distribution. Distribution Template:Mvar represents instead a theory, a model, a description or an approximation of Template:Mvar. The Kullback–Leibler divergence DKL(PQ) is then interpreted as the average difference of the number of bits required for encoding samples of Template:Mvar using a code optimized for Template:Mvar rather than one optimized for Template:Mvar. Note that the roles of Template:Mvar and Template:Mvar 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 Template:Harvtxt as "the mean information for discrimination between H1 and H2 per observation from μ1",Template:Sfn where one is comparing two probability measures μ1,μ2, and H1,H2 are the hypotheses that one is selecting from measure μ1,μ2 (respectively). They denoted this by I(1:2), and defined the "'divergence' between μ1 and μ2" 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.Template:Sfn In Template:Harvtxt, 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;Template:Sfn 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.Template:Sfn Numerous references to earlier uses of the symmetrized divergence and to other statistical distances are given in Template:Harvtxt. 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 Template:Mvar and Template:Mvar defined on the same sample space,  𝒳 , the relative entropy from Template:Mvar to Template:Mvar is defined[4] to be

DKL(PQ)=x𝒳P(x) log( P(x) Q(x)) ,

which is equivalent to

DKL(PQ)=x𝒳P(x) log( Q(x) P(x)).

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

Relative entropy is only defined in this way if, for all Template:Mvar,  Q(x)=0  implies  P(x)=0  (absolute continuity). Otherwise, it is often defined as Template:Nobr but the value  +  is possible even if  Q(x)0  everywhere,[5][6] provided that  𝒳  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

limx0+xlog(x)=0.

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

DKL(PQ)=p(x) log(p(x)q(x)) d x ,

where Template:Mvar and Template:Mvar denote the probability densities of Template:Mvar and Template:Mvar.

More generally, if Template:Mvar and Template:Mvar are probability measures on a measurable space  𝒳 , and Template:Mvar is absolutely continuous with respect to Template:Mvar, then the relative entropy from Template:Mvar to Template:Mvar is defined as

DKL(PQ)=x𝒳 log(P(d x)Q(d x)) P(d x) ,

where   P(d x) Q(d x)  is the Radon–Nikodym derivative of Template:Mvar with respect to Template:Mvar, i.e. the unique Template:Mvar almost everywhere defined function Template:Mvar on  𝒳  such that  P(d x)=r(x)Q(d x)  which exists because Template:Mvar is absolutely continuous with respect to Template:Mvar. Also we assume the expression on the right-hand side exists. Equivalently (by the chain rule), this can be written as

DKL(PQ)=x𝒳P(d x)Q(d x) log(P(d x)Q(d x)) Q(d x) ,

which is the entropy of Template:Mvar relative to Template:Mvar. Continuing in this case, if μ is any measure on 𝒳 for which densities Template:Mvar and Template:Mvar with  P(d x)=p(x)μ(d x)  and  Q(d x)=q(x)μ(d x)  exist (meaning that Template:Mvar and Template:Mvar are both absolutely continuous with respect to  μ ), then the relative entropy from Template:Mvar to Template:Mvar is given as

DKL(PQ)=x𝒳p(x) log( p(x) q(x)) μ(d x).

Note that such a measure μ for which densities can be defined always exists, since one can take  μ=12(P+Q)  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 Template:Mvar 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(PQ)  in words. Often it is referred to as the divergence between Template:Mvar and Template:Mvar, but this fails to convey the fundamental asymmetry in the relation. Sometimes, as in this article, it may be described as the divergence of Template:Mvar from Template:Mvar or as the divergence from Template:Mvar to Template:Mvar. This reflects the asymmetry in Bayesian inference, which starts from a prior Template:Mvar and updates to the posterior Template:Mvar. Another common way to refer to  DKL(PQ)  is as the relative entropy of Template:Mvar with respect to Template:Mvar or the information gain from Template:Mvar over Template:Mvar.

Basic example

KullbackTemplate:Sfn gives the following example (Table 2.1, Example 2.1). Let Template:Mvar and Template:Mvar be the distributions shown in the table and figure. Template:Mvar is the distribution on the left side of the figure, a binomial distribution with N=2 and p=0.4. Template:Mvar is the distribution on the right side of the figure, a discrete uniform distribution with the three possible outcomes Template:Math (i.e. 𝒳={0,1,2}), each with probability p=1/3.

Two distributions to illustrate relative entropy
Template:Diagonal split header 0 1 2
P(x) Template:Sfrac Template:Sfrac Template:Sfrac
Q(x) Template:Sfrac Template:Sfrac Template:Sfrac

Relative entropies DKL(PQ) and DKL(QP) are calculated as follows. This example uses the natural log with base [[E (mathematical constant)|Template:Mvar]], designated Template:Math to get results in nats (see units of information):

DKL(PQ)=x𝒳P(x)ln(P(x)Q(x))=925ln(9/251/3)+1225ln(12/251/3)+425ln(4/251/3)=125(32ln(2)+55ln(3)50ln(5))0.0852996,
DKL(QP)=x𝒳Q(x)ln(Q(x)P(x))=13ln(1/39/25)+13ln(1/312/25)+13ln(1/34/25)=13(4ln(2)6ln(3)+6ln(5))0.097455.

Interpretations

Statistics

In the field of statistics, the Neyman–Pearson lemma states that the most powerful way to distinguish between the two distributions Template:Mvar and Template:Mvar based on an observation Template:Mvar (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 Template:Mvar is actually drawn from Template:Mvar. Kullback motivated the statistic as an expected log likelihood ratio.Template:Sfn

Coding

In the context of coding theory, DKL(PQ) can be constructed by measuring the expected number of extra bits required to code samples from Template:Mvar using a code optimized for Template:Mvar rather than the code optimized for Template:Mvar.

Inference

In the context of machine learning, DKL(PQ) is often called the information gain achieved if Template:Mvar would be used instead of Template:Mvar which is currently used. By analogy with information theory, it is called the relative entropy of Template:Mvar with respect to Template:Mvar.

Expressed in the language of Bayesian inference, DKL(PQ) is a measure of the information gained by revising one's beliefs from the prior probability distribution Template:Mvar to the posterior probability distribution Template:Mvar. In other words, it is the amount of information lost when Template:Mvar is used to approximate Template:Mvar.[8]

Information geometry

In applications, Template:Mvar typically represents the "true" distribution of data, observations, or a precisely calculated theoretical distribution, while Template:Mvar typically represents a theory, model, description, or approximation of Template:Mvar. In order to find a distribution Template:Mvar that is closest to Template:Mvar, 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.Template:Sfn 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(PQ) does not equal DKL(QP), and the asymmetry is an important part of the geometry.Template:Sfn The infinitesimal form of relative entropy, specifically its Hessian, gives a metric tensor that equals the Fisher information metric; see Template:Slink. Fisher information metric on the certain probability distribution let determine the natural gradient for information-geometric optimization algorithms.[9] Its quantum version is Fubini-study metric.[10] 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.Template:Sfn

The relative entropy is the Bregman divergence generated by the negative entropy, but it is also of the form of an [[f-divergence|Template:Mvar-divergence]]. For probabilities over a finite alphabet, it is unique in being a member of both of these classes of statistical divergences. The application of Bregman divergence can be found in mirror descent.[11]

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.[12] This is a special case of a much more general connection between financial returns and divergence measures.[13]

Financial risks are connected to DKL via information geometry.[14] 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. Extending this concept, relative entropy can be hypothetically utilised to identify the behaviour of informed investors, if one takes this to be represented by the magnitude and deviations away from the prior expectations of fund flows, for example.[15]

Motivation

Illustration of the relative entropy for two normal distributions. The typical asymmetry is clearly visible.

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 Template:Mvar can be seen as representing an implicit probability distribution q(xi)=2i over Template:Mvar, where i 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 Template:Mvar is used, compared to using a code based on the true distribution Template:Mvar: it is the excess entropy.

DKL(PQ)=x𝒳p(x)log1q(x)x𝒳p(x)log1p(x)=H(P,Q)H(P)

where H(P,Q) is the cross entropy of Template:Mvar relative to Template:Mvar and H(P) is the entropy of Template:Mvar (which is the same as the cross-entropy of P with itself).

The relative entropy DKL(PQ) can be thought of geometrically as a statistical distance, a measure of how far the distribution Template:Mvar is from the distribution Template:Mvar. 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(PQ) agree more closely with our notion of distance, as the excess loss. The resulting function is asymmetric, and while this can be symmetrized (see Template:Slink), the asymmetric form is more useful. See Template:Slink for more on the geometric interpretation.

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

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.[18] 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

In particular, if P(dx)=p(x)μ(dx) and Q(dx)=q(x)μ(dx), then p(x)=q(x) μ-almost everywhere. The entropy H(P) thus sets a minimum value for the cross-entropy H(P,Q), the expected number of bits required when using a code based on Template:Mvar rather than Template:Mvar; and the Kullback–Leibler divergence therefore represents the expected number of extra bits that must be transmitted to identify a value Template:Mvar drawn from Template:Mvar, if a code is used corresponding to the probability distribution Template:Mvar, rather than the "true" distribution Template:Mvar.

  • No upper-bound exists for the general case. However, it is shown that if Template:Mvar and Template:Mvar are two discrete probability distributions built by distributing the same discrete quantity, then the maximum value of DKL(PQ) can be calculated.[19]
  • Relative entropy remains well-defined for continuous distributions, and furthermore is invariant under parameter transformations. For example, if a transformation is made from variable Template:Mvar to variable y(x), then, since P(dx)=p(x)dx=p~(y)dy=p~(y(x))|dydx(x)|dx and Q(dx)=q(x)dx=q~(y)dy=q~(y)|dydx(x)|dx where |dydx(x)| is the absolute value of the derivative or more generally of the Jacobian, the relative entropy may be rewritten: DKL(PQ)=xaxbp(x)log(p(x)q(x))dx=xaxbp~(y(x))|dydx(x)|log(p~(y(x))|dydx(x)|q~(y(x))|dydx(x)|)dx=yaybp~(y)log(p~(y)q~(y))dy 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 Template:Mvar 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[20] (such as self-information or Shannon entropy), which can become undefined or negative for non-discrete probabilities.
  • Relative entropy is additive for independent distributions in much the same way as Shannon entropy. If 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 DKL(PQ)=DKL(P1Q1)+DKL(P2Q2).
  • Relative entropy DKL(PQ) 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 DKL(λP1+(1λ)P2λQ1+(1λ)Q2)λDKL(P1Q1)+(1λ)DKL(P2Q2) for 0λ1.
  • DKL(PQ) may be Taylor expanded about its minimum (i.e. P=Q) as DKL(PQ)=n=21n(n1)x𝒳(Q(x)P(x))nQ(x)n1 which converges if and only if P2Q almost surely w.r.t Q.

Template:Hidden begin Denote f(α):=DKL((1α)Q+αPQ) and note that DKL(PQ)=f(1). The first derivative of f may be derived and evaluated as follows f(α)=x𝒳(P(x)Q(x))(log((1α)Q(x)+αP(x)Q(x))+1)=x𝒳(P(x)Q(x))log((1α)Q(x)+αP(x)Q(x))f(0)=0 Further derivatives may be derived and evaluated as follows f(α)=x𝒳(P(x)Q(x))2(1α)Q(x)+αP(x)f(0)=x𝒳(P(x)Q(x))2Q(x)f(n)(α)=(1)n(n2)!x𝒳(P(x)Q(x))n((1α)Q(x)+αP(x))n1f(n)(0)=(1)n(n2)!x𝒳(P(x)Q(x))nQ(x)n1 Hence solving for DKL(PQ) via the Taylor expansion of f about 0 evaluated at α=1 yields DKL(PQ)=n=0f(n)(0)n!=n=21n(n1)x𝒳(Q(x)P(x))nQ(x)n1 P2Q a.s. is a sufficient condition for convergence of the series by the following absolute convergence argument n=2|1n(n1)x𝒳(Q(x)P(x))nQ(x)n1|=n=21n(n1)x𝒳|Q(x)P(x)||1P(x)Q(x)|n1n=21n(n1)x𝒳|Q(x)P(x)|n=21n(n1)=1 P2Q 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 ϵ>0, ρ>0, and U< such that P2Q+ϵ and QU with measure ρ. The previous proof of sufficiency demonstrated that the measure 1ρ component of the series where P2Q is bounded, so we need only concern ourselves with the behavior of the measure ρ component of the series where P2Q+ϵ. The absolute value of the nth term of this component of the series is then lower bounded by 1n(n1)ρ(1+ϵU)n, which is unbounded as n, so the series diverges. Template:Hidden end

Duality formula for variational inference

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

Template:Math theorem

Template:Math proof

Examples

Multivariate normal distributions

Suppose that we have two multivariate normal distributions, with means μ0,μ1 and with (non-singular) covariance matrices Σ0,Σ1. If the two distributions have the same dimension, Template:Mvar, then the relative entropy between the distributions is as follows:[22]

DKL(𝒩0𝒩1)=12(tr(Σ11Σ0)k+(μ1μ0)𝖳Σ11(μ1μ0)+ln(detΣ1detΣ0)).

The logarithm in the last term must be taken to base [[e (mathematical constant)|Template:Mvar]] since all terms apart from the last are base-Template:Mvar 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 Σ0=L0L0T and Σ1=L1L1T. Then with Template:Mvar and Template:Mvar solutions to the triangular linear systems L1M=L0, and L1y=μ1μ0,

DKL(𝒩0𝒩1)=12(i,j=1k(Mij)2k+|y|2+2i=1kln(L1)ii(L0)ii).

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(𝒩((μ1,,μk)𝖳,diag(σ12,,σk2))𝒩(𝟎,𝐈))=12i=1k(σi2+μi21ln(σi2)).

For two univariate normal distributions Template:Mvar and Template:Mvar the above simplifies to[23]

DKL(𝓅𝓆)=logσ1σ0+σ02+(μ0μ1)22σ1212

In the case of co-centered normal distributions with k=σ1/σ0, this simplifies[24] to:

DKL(𝓅𝓆)=log2k+(k21)/2/ln(2)bits

Uniform distributions

Consider two uniform distributions, with the support of p=[A,B] enclosed within q=[C,D] (CA<BD). Then the information gain is:

DKL(𝓅𝓆)=logDCBA

Intuitively,[24] the information gain to a Template:Mvar 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 Template:Mvar long stream.

Exponential family

The exponential family of distribution is given by

pX(x|θ)=h(x)exp(θTT(x)A(θ))

where h(x) is reference measure, T(x) is sufficient statistics, θ is canonical natural parameters, and A(θ) is the log-partition function.

The KL divergence between two distributions p(x|θ1) and p(x|θ2) is given by[25]

DKL(θ1θ2)=(θ1θ2)Tμ1A(θ1)+A(θ2)

where μ1=Eθ1[T(X)]=A(θ1) is the mean parameter of p(x|θ1).

For example, for the Poisson distribution with mean λ, the sufficient statistics T(x)=x, the natural parameter θ=logλ, and log partition function A(θ)=eθ. As such, the divergence between two Poisson distributions with means λ1 and λ2 is

DKL(λ1λ2)=λ1logλ1λ2λ1+λ2.

As another example, for a normal distribution with unit variance N(μ,1), the sufficient statistics T(x)=x, the natural parameter θ=μ, and log partition function A(θ)=μ2/2. Thus, the divergence between two normal distributions N(μ1,1) and N(μ2,1) is

DKL(μ1μ2)=(μ1μ2)μ1μ122+μ222=(μ2μ1)22.

As final example, the divergence between a normal distribution with unit variance N(μ,1) and a Poisson distribution with mean λ is

DKL(μλ)=(μlogλ)μμ22+λ.

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.Template:Sfn 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(PQ) does not equal DKL(QP), and while this can be symmetrized (see Template:Slink), the asymmetry is an important part of the geometry.Template:Sfn

It generates a topology on the space of probability distributions. More concretely, if {P1,P2,} is a sequence of distributions such that

limnDKL(PnQ)=0,

then it is said that

PnDQ.

Pinsker's inequality entails that

PnDPPnTVP,

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 Template:Mvar and Template:Mvar are both parameterized by some (possibly multi-dimensional) parameter θ. Consider then two close by values of P=P(θ) and Q=P(θ0) so that the parameter θ differs by only a small amount from the parameter value θ0. Specifically, up to first order one has (using the Einstein summation convention)

P(θ)=P(θ0)+ΔθjPj(θ0)+

with Δθj=(θθ0)j a small change of θ in the Template:Mvar direction, and Pj(θ0)=Pθj(θ0) the corresponding rate of change in the probability distribution. Since relative entropy has an absolute minimum 0 for P=Q, i.e. θ=θ0, it changes only to second order in the small parameters Δθj. More formally, as for any minimum, the first derivatives of the divergence vanish

θj|θ=θ0DKL(P(θ)P(θ0))=0,

and by the Taylor expansion one has up to second order

DKL(P(θ)P(θ0))=12ΔθjΔθkgjk(θ0)+

where the Hessian matrix of the divergence

gjk(θ0)=2θjθk|θ=θ0DKL(P(θ)P(θ0))

must be positive semidefinite. Letting θ0 vary (and dropping the subindex 0) the Hessian gjk(θ) defines a (possibly degenerate) Riemannian metric on the Template:Mvar parameter space, called the Fisher information metric.

Fisher information metric theorem

When p(x,ρ) satisfies the following regularity conditions:

log(p)ρ,2log(p)ρ2,3log(p)ρ3 exist,
|pρ|<F(x):x=0F(x)dx<,|2pρ2|<G(x):x=0G(x)dx<|3log(p)ρ3|<H(x):x=0p(x,0)H(x)dx<ξ<

where Template:Mvar is independent of Template:Mvar

x=0p(x,ρ)ρ|ρ=0dx=x=02p(x,ρ)ρ2|ρ=0dx=0

then:

𝒟(p(x,0)p(x,ρ))=cρ22+𝒪(ρ3) as ρ0.

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.

MAUVE Metric

MAUVE is a measure of the statistical gap between two text distributions, such as the difference between text generated by a model and human-written text. This measure is computed using Kullback-Leibler divergences between the two distributions in a quantized embedding space of a foundation model.

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

Template:Main 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 asTemplate:Citation needed

I(m)=DKL(δim{pi}),

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 Template:Mvar if only the probability distribution P(i) is available to the receiver, not the fact that i=m.

Mutual information

The mutual information,

I(X;Y)=DKL(P(X,Y)P(X)P(Y))=EX{DKL(P(YX)P(Y))}=EY{DKL(P(XY)P(X))}

is the relative entropy of the joint probability distribution 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 Template:Mvar and Template:Mvar 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 Template:Mvar if the value of Template:Mvar is not already known to the receiver.

Shannon entropy

The Shannon entropy,

H(X)=E[IX(x)]=log(N)DKL(pX(x)PU(X))

is the number of bits which would have to be transmitted to identify Template:Mvar from Template:Mvar equally likely possibilities, less the relative entropy of the uniform distribution on the random variates of Template:Mvar, 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 Template:Mvar 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)p(x)logp(x)m(x)dx,

which is equivalent to:

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

Conditional entropy

The conditional entropyTemplate:R,

H(XY)=log(N)DKL(P(X,Y)PU(X)P(Y))=log(N)DKL(P(X,Y)P(X)P(Y))DKL(P(X)PU(X))=H(X)I(X;Y)=log(N)EY[DKL(P(XY)PU(X))]

is the number of bits which would have to be transmitted to identify Template:Mvar from Template:Mvar 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 Template:Mvar were coded according to the uniform distribution PU(X) rather than the conditional distribution P(X|Y) of Template:Mvar given Template:Mvar.

Cross entropy

When we have a set of possible events, coming from the distribution Template:Mvar, 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 Template:Mvar 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 Template:Mvar), which will be equal to Shannon's Entropy of Template:Mvar (denoted as H(p)). However, if we use a different probability distribution (Template:Mvar) 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 Template:Mvar and Template:Mvar.

The cross entropy between two probability distributions (Template:Mvar and Template:Mvar) 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 Template:Mvar, rather than the "true" distribution Template:Mvar. The cross entropy for two distributions Template:Mvar and Template:Mvar over the same probability space is thus defined as follows.

H(p,q)=Ep[log(q)]=H(p)+DKL(pq).

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 H(p)) for encoding the events because of using Template:Mvar for constructing the encoding scheme instead of Template:Mvar.

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)p(xI). If some new fact Y=y is discovered, it can be used to update the posterior distribution for Template:Mvar from p(xI) to a new posterior distribution p(xy,I) using Bayes' theorem:

p(xy,I)=p(yx,I)p(xI)p(yI)

This distribution has a new entropy:

H(p(xy,I))=xp(xy,I)logp(xy,I),

which may be less than or greater than the original entropy H(p(xI)). However, from the standpoint of the new probability distribution one can estimate that to have used the original code based on p(xI) instead of a new code based on p(xy,I) would have added an expected number of bits:

DKL(p(xy,I)p(xI))=xp(xy,I)log(p(xy,I)p(xI))

to the message length. This therefore represents the amount of useful information, or information gain, about Template:Mvar, that has been learned by discovering Y=y.

If a further piece of data, Y2=y2, subsequently comes in, the probability distribution for Template:Mvar can be updated further, to give a new best guess p(xy1,y2,I). If one reinvestigates the information gain for using p(xy1,I) rather than p(xI), it turns out that it may be either greater or less than previously estimated:

xp(xy1,y2,I)log(p(xy1,y2,I)p(xI)) may be ≤ or > than xp(xy1,I)log(p(xy1,I)p(xI))

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

DKL(p(xy1,y2,I)p(xI)) may be <, = or > than DKL(p(xy1,y2,I)p(xy1,I))+DKL(p(xy1,I)p(xI))

All one can say is that on average, averaging using p(y2y1,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.[26] When posteriors are approximated to be Gaussian distributions, a design maximising the expected relative entropy is called Bayes d-optimal.

Discrimination information

Relative entropy DKL(p(xH1)p(xH0)) 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.[27] 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(xH1)p(xH0))IG=DKL(p(Hx)p(HI)).

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 Template:Visible anchor (MDI): given new facts, a new distribution Template:Mvar 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(ff0) as possible.

For example, if one had a prior distribution p(x,a) over Template:Mvar and Template:Mvar, and subsequently learnt the true distribution of Template:Mvar was u(a), then the relative entropy between the new joint distribution for Template:Mvar and Template:Mvar, q(xa)u(a), and the earlier prior distribution would be:

DKL(q(xa)u(a)p(x,a))=Eu(a){DKL(q(xa)p(xa))}+DKL(u(a)p(a)),

i.e. the sum of the relative entropy of p(a) the prior distribution for Template:Mvar 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(xa) from the new conditional distribution q(xa). (Note that often the later expected value is called the conditional relative entropy (or conditional Kullback–Leibler divergence) and denoted by DKL(q(xa)p(xa))Template:Sfn[28]) This is minimized if q(xa)=p(xa) 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 Template:Mvar 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 Template:Mvar to Template:Mvar with respect to Template:Mvar is equivalent to minimizing the cross-entropy of Template:Mvar and Template:Mvar, since

H(p,m)=H(p)+DKL(pm),

which is appropriate if one is trying to choose an adequate approximation to Template:Mvar. However, this is just as often not the task one is trying to achieve. Instead, just as often it is Template:Mvar that is some fixed prior reference measure, and Template:Mvar that one is attempting to optimise by minimising DKL(pm) 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(pm), rather than H(p,m) Template:Citation needed.

Relationship to available work

Pressure versus volume plot of available work from a mole of argon gas relative to ambient, calculated as To times the Kullback–Leibler divergence

Surprisals[29] add where probabilities multiply. The surprisal for an event of probability Template:Mvar is defined as s=kln(1/p). If Template:Mvar is {1,1/ln2,1.38×1023} then surprisal is in {nats, bits, or J/K} so that, for instance, there are Template:Mvar bits of surprisal for landing all "heads" on a toss of Template:Mvar coins.

Best-guess states (e.g. for atoms in a gas) are inferred by maximizing the average surprisal Template:Mvar (entropy) for a given set of control parameters (like pressure Template:Mvar or volume Template:Mvar). This constrained entropy maximization, both classically[30] and quantum mechanically,[31] minimizes Gibbs availability in entropy units[32] Akln(Z) where Template:Mvar is a constrained multiplicity or partition function.

When temperature Template:Mvar is fixed, free energy (T×A) is also minimized. Thus if T,V and number of molecules Template:Mvar are constant, the Helmholtz free energy FUTS (where Template:Mvar is energy and Template:Mvar is entropy) is minimized as a system "equilibrates." If Template:Mvar and Template:Mvar are held constant (say during processes in your body), the Gibbs free energy G=U+PVTS 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=ΔG=NkToΘ(V/Vo) where Vo=NkTo/Po and Θ(x)=x1lnx0 (see also Gibbs inequality).

More generally[33] the work available relative to some ambient is obtained by multiplying ambient temperature To by relative entropy or net surprisal ΔI0, 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ΔI, where relative entropy

ΔI=Nk[Θ(VVo)+32Θ(TTo)].

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.[34] Thus relative entropy measures thermodynamic availability in bits.

Quantum information theory

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

DKL(PQ)=Tr(P(log(P)log(Q))).

In quantum information science the minimum of DKL(PQ) over all separable states Template:Mvar can also be used as a measure of entanglement in the state Template:Mvar.

Relationship between models and reality

Template:See also Template:Further

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[35] and a book[36] 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.Template:Citation needed

Symmetrised divergence

Template:Harvtxt also considered the symmetrized function:Template:Sfn

DKL(PQ)+DKL(QP)

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

This quantity has sometimes been used for feature selection in classification problems, where Template:Mvar and Template:Mvar 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λ(PQ)=λDKL(PλP+(1λ)Q)+(1λ)DKL(QλP+(1λ)Q),

which can be interpreted as the expected information gain about Template:Mvar from discovering which probability distribution Template:Mvar is drawn from, Template:Mvar or Template:Mvar, if they currently have probabilities λ and 1λ respectively.Template:Clarify Template:Citation needed

The value λ=0.5 gives the Jensen–Shannon divergence, defined by

DJS=12DKL(PM)+12DKL(QM)

where Template:Mvar is the average of the two distributions,

M=12(P+Q).

We can also interpret DJS as the capacity of a noisy information channel with two inputs giving the output distributions Template:Mvar and Template:Mvar. The Jensen–Shannon divergence, like all Template:Mvar-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.[37][38]

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:

  • The total-variation distance, δ(p,q). This is connected to the divergence through Pinsker's inequality: δ(P,Q)12DKL(PQ). Pinsker's inequality is vacuous for any distributions where DKL(PQ)>2, since the total variation distance is at most Template:Mvar. For such distributions, an alternative bound can be used, due to Bretagnolle and Huber[39] (see, also, Tsybakov[40]): δ(P,Q)1eDKL(PQ).
  • The family of Rényi divergences generalize relative entropy. Depending on the value of a certain parameter, α, 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.[41]

Data differencing

Template:Main 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

Template:Div col

Template:Div col end

References

Template:Reflist Template:Refbegin

Template:Refend