A relative entropy (Kullback–Leibler divergence) is an extended real number DKL(P∥Q) associated to two probability measures
P and Q on the same measurable space, defined (when P is absolutely continuous with respect to Q) by
DKL(P∥Q)=∫log(dQdP)dP,where dQdP is the Radon–Nikodym derivative (see the Radon–Nikodym theorem
). If P is not absolutely continuous with respect to Q, one sets DKL(P∥Q)=+∞.
In the discrete case with mass functions p,q on a countable set, this becomes
DKL(P∥Q)=x∑p(x)logq(x)p(x),with the convention that terms with p(x)=0 contribute 0, and any x with p(x)>0 and q(x)=0 forces DKL(P∥Q)=+∞. Relative entropy is always nonnegative by Gibbs' inequality
, equals 0 iff P=Q (in the appropriate sense), and is not symmetric in general. It is related to other discrepancy notions such as total variation distance
(for example via Pinsker's inequality
).
Examples:
- If P=Bernoulli(p) and Q=Bernoulli(q) with p,q∈(0,1), then
DKL(P∥Q)=plogqp+(1−p)log1−q1−p.
- If P=N(μ1,σ2) and Q=N(μ2,σ2) with the same variance σ2>0, then
DKL(P∥Q)=2σ2(μ1−μ2)2.