ArticleslgStudy

mathematics

Kullback–Leibler divergence

Kullback–Leibler divergence is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Kullback–Leibler divergence rather than just read about it. In short: In mathematical statistics, the Kullback–Leibler (KL) divergence (also called relative entropy and I-divergence), denoted D KL ( P ∥ Q ) {\displaystyle D_{\text{KL}}(P\parallel Q)} , is a type of statistical distance: a measure of how much an approximating probability distribution Q is different from a true probability distribution P. Mathematically, it is defined as D KL ( P ∥ Q ) = ∑ x ∈ X P ( x ) log ⁡ P ( x ) Q…

Kullback–Leibler divergence — main illustration
Kullback–Leibler divergence — illustration

Key takeaways

  • Kullback–Leibler divergence belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Kullback–Leibler divergence to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Kullback–Leibler divergence from memory before moving on to harder problems.

Reference excerpt

In mathematical statistics, the Kullback–Leibler (KL) divergence (also called relative entropy and I-divergence), denoted D KL ( P ∥ Q ) {\displaystyle D_{\text{KL}}(P\parallel Q)} , is a type of statistical distance: a measure of how much an approximating probability distribution Q is different from a true probability distribution P. Mathematically, it is defined as

D KL ( P ∥ Q ) = ∑ x ∈ X P ( x ) log ⁡ P ( x ) Q ( x ) . {\displaystyle D_{\text{KL}}(P\parallel Q)=\sum _{x\in {\mathcal {X}}}P(x)\,\log {\frac {P(x)}{Q(x)}}{\text{.}}}

A simple interpretation of the KL divergence of P from Q is the expected excess surprisal from using the approximation Q instead of P when the actual is P. 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, 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). KL divergence 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, a true P and an approximating Q. Often, P represents the data, the observations, or a measured probability distribution and distribution Q represents instead a theory, a model, a description, or another approximation of P. However, sometimes the true distribution P represents a model and the approximating distribution Q represents (simulated) data that are intended to match the true distribution. The Kullback–Leibler divergence D KL ( P ∥ Q ) {\displaystyle D_{\text{KL}}(P\parallel Q)} is then interpreted as the average difference of the number of bits required for encoding samples of P using a code optimized for Q rather than one optimized for P. Note that the roles of P and Q can be reversed in some situations where that is easier to compute and the goal is to minimize D KL ( P ∥ Q ) {\displaystyle D_{\text{KL}}(P\parallel Q)} , such as with the expectation–maximization algorithm (EM) and evidence lower bound (ELBO) computations. This role-reversal approach exploits that D KL ( P ∥ Q ) = 0 {\displaystyle D_{\text{KL}}(P\parallel Q)=0} if and only if D KL ( Q ∥ P ) = 0 {\displaystyle D_{\text{KL}}(Q\parallel P)=0} and that, in many cases, reducing one has the effect of reducing the other.

… excerpt ends here. Continue reading the full article.

Illustrations

Kullback–Leibler divergence: Illustration of the relative entropy for two normal distributions. The typical asymmetry is clearly visible.
Illustration of the relative entropy for two normal distributions. The typical asymmetry is clearly visible.
Kullback–Leibler divergence: Pressure versus volume plot of available work from a mole of argon gas relative to ambient, calculated as 
  
    
      
        
          T
          
            o
          
        
      
    
    {\displaystyle T_{o}}
  
 times the Kullback–Leibler divergence
Pressure versus volume plot of available work from a mole of argon gas relative to ambient, calculated as T o {\displaystyle T_{o}} times the Kullback–Leibler divergence

Worked examples

Example 1 — a first encounter with Kullback–Leibler divergence

Start with the simplest possible case. Write down what Kullback–Leibler divergence claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Kullback–Leibler divergence before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Kullback–Leibler divergence ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Kullback–Leibler divergence

In research
Kullback–Leibler divergence appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Kullback–Leibler divergence in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Kullback–Leibler divergence is common in secondary-school and first-year university syllabi. It links to neighbouring topics Entropy and information, F-divergences, Information geometry, so understanding it makes those chapters shorter.
In everyday life
Look for Kullback–Leibler divergence outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Kullback–Leibler divergence in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Kullback–Leibler divergence means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Kullback–Leibler divergence out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Kullback–Leibler divergence in simple terms?

In mathematical statistics, the Kullback–Leibler (KL) divergence (also called relative entropy and I-divergence), denoted D KL ( P ∥ Q ) {\displaystyle D_{\text{KL}}(P\parallel Q)} , is a type of statistical distance: a measure of how much an approximating probability distribution Q is different fr…

Why does Kullback–Leibler divergence matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Kullback–Leibler divergence?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Kullback–Leibler divergence.

Tags

  • Entropy and information
  • F-divergences
  • Information geometry
  • Thermodynamics

Keep exploring