Why Changing Measures Has a Cost
In PAC-Bayesian analysis, a prior \(\Pi\) describes a reference distribution over predictors, while a posterior \(\rho\) may place more weight on predictors that appear useful. This change of weights can increase the average of a function \(g\), such as a loss or a risk. The change-of-measure inequality quantifies how large that increase can be using two ingredients: the log moment-generating function of \(g\) under \(\Pi\), and the Kullback–Leibler divergence from \(\rho\) to \(\Pi\).
The inequality is deterministic once \(\Pi\), \(\rho\), and \(g\) are fixed. In applications, a posterior can depend on observed data; the inequality still applies to the resulting measures for each fixed data set. It does not, by itself, give a probability statement about data or a bound on the difference between empirical and population risk.
The direction of the divergence matters: \(\operatorname{KL}(\rho\|\Pi)\) measures the cost of using \(\rho\) in place of the reference measure \(\Pi\). A posterior that assigns positive probability to a set to which the prior assigns zero probability has infinite divergence.
Nonnegativity of KL Divergence
The change-of-measure result rests on nonnegativity of KL divergence. The density used in its proof must be the density of the first measure with respect to the second.
Proof. If \(\rho\) is not absolutely continuous with respect to \(\Pi\), the divergence is \(+\infty\), so the claim holds. Otherwise let \(f=d\rho/d\Pi\). The function \(\phi(x)=x\log x\), extended continuously by \(\phi(0)=0\), is convex on \([0,\infty)\). Since \(\int f\,d\Pi=1\), Jensen's inequality gives
The inequality remains valid if the integral on the left is infinite. \(\square\)
The Change-of-Measure Inequality
For a bounded measurable function \(g\), its exponential moment under the prior is \(E_\Pi[e^g]\). It is finite and strictly positive. The log of this moment is the variational quantity that balances a posterior's average of \(g\) against its KL cost.
Proof. Define \(Z=E_\Pi[e^g]\), which satisfies \(0<Z<\infty\), and define a probability measure \(\Pi_g\) by its density with respect to \(\Pi\):
Because \(g\) is bounded, this density is positive and bounded above and below by positive constants. In particular, \(\rho\ll\Pi_g\), and the log-density identity gives
All terms are finite: the KL divergence to \(\Pi\) is finite by assumption, and \(g\) is bounded. Nonnegativity of \(\operatorname{KL}(\rho\|\Pi_g)\) therefore implies \[ E_\rho[g]\leq \operatorname{KL}(\rho\|\Pi)+\log Z, \] which is the claimed inequality. \(\square\)
Worked Example: A Three-Predictor Prior
Let the predictor space be \(\{1,2,3\}\), with prior probabilities \((1/2,1/3,1/6)\). Take \(\rho=\Pi\), and let \(g\) have values \((0,1,2)\). Calculate the posterior expectation and the right-hand side of the inequality.
Since \(\rho=\Pi\), the divergence is zero. The expectation is
The prior exponential moment is
Thus \(\log E_\Pi[e^g]\approx0.9699\), and the inequality reads \(0.6667\leq0+0.9699\). This example also shows that the log moment-generating function can be larger than the prior average of \(g\): it accounts for the upper values of \(g\) exponentially.
The Variational Formula and Its Equality Case
The inequality is one side of an exact variational identity. For bounded measurable \(g\), define \(\Pi_g\) as above. For every \(\rho\) with finite KL divergence, the proof established the identity \(\ E_\rho[g]-\operatorname{KL}(\rho\|\Pi)=\log E_\Pi[e^g]-\operatorname{KL}(\rho\|\Pi_g)\). Taking a supremum over \(\rho\) gives the formula below.
Derivation. For every admissible \(\rho\), the identity just established and KL nonnegativity yield
For \(\rho=\Pi_g\), its KL divergence relative to \(\Pi\) is finite because \(g\) is bounded, and \(\operatorname{KL}(\Pi_g\|\Pi_g)=0\). Substitution in the identity gives equality. This proves both the supremum formula and its attainment. \(\square\)
Worked Example: The Tilt That Attains Equality
Let \(\Pi\) assign probabilities \((1/4,3/4)\) to two outcomes, and let \(g=(\log 3,0)\). The unnormalized tilted probabilities are \((3/4,3/4)\), so \(E_\Pi[e^g]=3/2\), and the normalized tilt is \(\rho=(1/2,1/2)\).
Its expectation and divergence are
Consequently,
The posterior emphasizes the outcome with larger \(g\), but the divergence records the cost of that reweighting. Here the cost is exactly what makes the variational expression equal the log moment-generating function.
Using KL to Bound a Posterior Expectation
When the posterior is chosen for a practical reason, it need not be the exponential tilt of the function being bounded. The change-of-measure inequality still applies. It says that a posterior expectation can be large only if the prior exponential moment is large, the posterior departs sufficiently from the prior, or both.
Worked Example: A Posterior Expectation with a KL Penalty
Let \(\Pi=(1/4,3/4)\), \(\rho=(3/4,1/4)\), and \(g=(1,0)\). First calculate the divergence:
The posterior expectation is \(E_\rho[g]=(3/4)(1)+(1/4)(0)=0.75\). Under the prior,
The bound is therefore \(E_\rho[g]\leq0.5493+0.3574\approx0.9067\), which is valid since \(0.75\leq0.9067\). The posterior puts three times as much probability as the prior on the outcome where \(g=1\), and the positive KL term accounts for that shift.
The inequality is useful because it holds for every posterior with finite KL divergence, not just for a posterior selected by exponential tilting. In PAC-Bayesian arguments, it lets an average under a data-dependent posterior be related to an exponential moment under a reference prior. Further assumptions and probability arguments are needed to turn that deterministic relation into generalization bounds.
Common Mistake
A tempting but incorrect shortcut is to say that a posterior expectation is at most the prior expectation plus KL divergence. The theorem does not give \(E_\rho[g]\leq E_\Pi[g]+\operatorname{KL}(\rho\|\Pi)\). The term involving the prior is \(\log E_\Pi[e^g]\), not \(E_\Pi[g]\). Exponentiation makes this a different quantity, especially when \(g\) can take large values.
For instance, in the three-outcome example, \(E_\Pi[g]=2/3\), while \(\log E_\Pi[e^g]\approx0.9699\). The proven upper bound uses the latter. Replacing it with the prior mean would require a separate argument and is not justified by change of measure. A second frequent error is to reverse the KL arguments: the penalty here is \(\operatorname{KL}(\rho\|\Pi)\), because the posterior is being compared with the prior.
Check Your Understanding
Use the definitions and derivations above to answer the following.
- Why does \(\rho\not\ll\Pi\) imply that \(\operatorname{KL}(\rho\|\Pi)=+\infty\)?
- In the proof of nonnegativity, which Radon–Nikodym derivative is integrated, and why does its integral equal one?
- For a bounded measurable \(g\), write the density of the exponentially tilted measure \(\Pi_g\) and state when equality holds in the change-of-measure inequality.
- For \(\Pi=(1/4,3/4)\) and \(g=(\log 3,0)\), verify the two probabilities of the tilted measure by normalizing the unnormalized weights.
- Why can the prior mean \(E_\Pi[g]\) not be substituted for \(\log E_\Pi[e^g]\) in the change-of-measure inequality without additional justification?