How do you derive the evidence lower bound (ELBO), and what is the gap?

Probabilistic models, Variational inference
Level L3 Intermediate. Length Long. Nature Th+Mat Both.

What's being asked

Whether you can derive the ELBO in two ways and explain why maximising it performs approximate inference.

Key idea

Let x be the observed data, z the latent (hidden) variables and q(z) an approximate posterior. Then log⁡p(x)=Eq(z)[log⁡p(x,z)−log⁡q(z)]+DKL(q(z) ∥ p(z∣x)). The first term is the ELBO. KL is non-negative, so the ELBO is a lower bound on the evidence log⁡p(x), and the gap is exactly the KL divergence to the true posterior.

Steps

  1. Start from log⁡p(x)=log⁡∫p(x,z) dz, and multiply and divide by q(z). This turns the integral into an expectation under q.
  2. Apply Jensen’s inequality (log is concave) to get log⁡p(x)≥Eq[log⁡p(x,z)−log⁡q(z)].
  3. Derive the exact identity by expanding DKL(q(z)∥p(z∣x)) with p(z∣x)=p(x,z)/p(x).
  4. Rewrite the ELBO as Eq[log⁡p(x∣z)]−DKL(q(z)∥p(z)): reconstruction minus a regulariser, as in VAEs (variational autoencoders).
  5. Conclude that because log⁡p(x) does not depend on q, maximising the ELBO over q minimises the KL to the posterior.

Common mistakes

How long your answer should be

One page; 6–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: You want samples from p(x)=6x(1−x) on [0,1] (the Beta(2,2) density) using a Uniform(0,1) proposal. Find the smallest valid envelope constant M, the acceptance rule and the acceptance probability. What changes if you only know the unnormalised density p~(x)=x(1−x)?
Next in Probabilistic models: How is the forward recursion for a hidden Markov model derived? For the HMM with states Rainy (R) and Sunny (S), π=(0.6,0.4), transitions P(R→R)=0.7, P(R→S)=0.3, P(S→R)=0.4, P(S→S)=0.6, and emissions P(walk∣R)=0.1, P(shop∣R)=0.4, P(walk∣S)=0.6, P(shop∣S)=0.3, what is P(walk,shop)?