Tutorials › Statistical Learning (Graduate) › Deriving Gibbs Weights from Entropy Penalization

Exponential Weights and Convex Aggregation · Tutorial 322 of 989

Deriving Gibbs Weights from Entropy Penalization

See how entropy penalization turns empirical risks into unique, normalized Gibbs weights over a finite dictionary.

Advanced 11 min read

What You'll Learn

  • Define the empirical-risk-plus-KL objective over a finite predictor dictionary.
  • Derive the normalized exponential-weights formula from the penalized objective.
  • Prove optimality and uniqueness using a relative-entropy identity.
  • Identify the conditions under which every Gibbs weight is positive.
  • Check the formula with explicit risks, temperatures, and normalizing constants.
  • Distinguish the positive-temperature solution from unpenalized empirical-risk minimization.

Why Entropy Penalization Produces Weights

A finite dictionary offers several candidate predictors, each with an empirical risk computed on the observed sample. Selecting only the candidate with the smallest risk is one option; another is to assign a probability to every candidate and optimize over those distributions. An entropy penalty discourages a distribution from concentrating entirely on one candidate. The resulting optimization problem has a particularly simple solution: each candidate receives a weight proportional to an exponential of its negative empirical risk.

This tutorial derives that formula and establishes when it is the unique minimizer. The dictionary is finite, the empirical risks are finite real numbers, and the temperature parameter is strictly positive. The penalty uses the uniform distribution on the dictionary; replacing it with a nonuniform prior leads to a related but distinct formulation.

Objective Over the Simplex

Let \(f_1,\ldots,f_M\) be a finite predictor dictionary, where \(M\geq 1\). For a sample of size \(n\), write \(\widehat R_j\) for the empirical risk of predictor \(f_j\). Assume each \(\widehat R_j\) is a finite real number. A distribution over the dictionary is a vector \(q=(q_1,\ldots,q_M)\) in the probability simplex \( \Delta_M=\{q\in[0,1]^M:\sum_{j=1}^M q_j=1\} \).

Let \(u\) be the uniform distribution, with \(u_j=1/M\). For any \(q\in\Delta_M\), define its Kullback–Leibler divergence from \(u\) by \( \operatorname{KL}(q\|u)=\sum_{j=1}^M q_j\log(q_j/u_j) \), using the convention \(0\log 0=0\). For a temperature \(\tau>0\), the penalized objective is

$$ J_\tau(q) = \sum_{j=1}^M q_j\widehat R_j + \tau\,\operatorname{KL}(q\|u), \qquad q\in\Delta_M. $$

The first term is the average empirical risk under the distribution \(q\). The second term penalizes departure from uniform weights, scaled by \(\tau\). Since \(u_j=1/M\), this divergence can also be written \( \operatorname{KL}(q\|u)=\sum_j q_j\log q_j+\log M \). The additive constant \(\log M\) matters for the objective's value, even though it does not change its minimizer.

Definition: The Gibbs weights associated with risks \(\widehat R_1,\ldots,\widehat R_M\) and temperature \(\tau>0\) are \( q_j^\star=\exp(-\widehat R_j/\tau)/Z_\tau \), where \( Z_\tau=\sum_{k=1}^M\exp(-\widehat R_k/\tau) \). The quantity \(Z_\tau\) is the normalizing constant, which makes the weights sum to one.

The Variational Identity and the Minimizer

The formula follows from an exact identity, not an approximation. Because the dictionary is finite and every risk is finite, each term in the normalizing constant \( Z_\tau=\sum_k\exp(-\widehat R_k/\tau) \) is strictly positive and finite. Thus \(0<Z_\tau<\infty\), and every Gibbs weight \(q_j^\star\) is positive.

Theorem: Suppose \(M\geq1\), each \(\widehat R_j\) is finite, and \(\tau>0\). Then \(J_\tau\) has the unique minimizer \( q_j^\star=\exp(-\widehat R_j/\tau)/Z_\tau \). For every \(q\in\Delta_M\), \( J_\tau(q)=\tau\operatorname{KL}(q\|q^\star)+\tau\log M-\tau\log Z_\tau \). Consequently, the minimum objective value is \( \tau\log M-\tau\log Z_\tau \).

Proof. Since \(q_j^\star>0\), the divergence \(\operatorname{KL}(q\|q^\star)\) is defined for every \(q\in\Delta_M\), including distributions with zero coordinates. From the Gibbs formula, \( \log q_j^\star=-\widehat R_j/\tau-\log Z_\tau \). Therefore

$$ \begin{aligned} \tau\operatorname{KL}(q\|q^\star) &=\tau\sum_{j=1}^M q_j\log\!\left(\frac{q_j}{q_j^\star}\right)\\ &=\tau\sum_{j=1}^M q_j\log q_j +\sum_{j=1}^M q_j\widehat R_j +\tau\log Z_\tau. \end{aligned} $$

Here the convention \(0\log 0=0\) justifies the expression when \(q_j=0\), and \(\sum_jq_j=1\) gives the final term. Adding \(\tau\log M-\tau\log Z_\tau\) to both sides yields exactly \(J_\tau(q)\), because \( \operatorname{KL}(q\|u)=\sum_jq_j\log q_j+\log M \).

For completeness, relative entropy is nonnegative, and it is zero only when its two distributions agree. In this case, that fact can be checked directly. For every coordinate with \(q_j>0\), the inequality \(\log x\leq x-1\) gives \(q_j\log(q_j^\star/q_j)\leq q_j^\star-q_j\). Summing over those coordinates and changing signs gives

$$ \operatorname{KL}(q\|q^\star) \geq \sum_{j:q_j>0}(q_j-q_j^\star) = 1-\sum_{j:q_j>0}q_j^\star \geq 0. $$

Equality requires every positive coordinate to satisfy \(q_j=q_j^\star\), and it also requires no \(q_j^\star\) mass to lie outside the support of \(q\). Since all \(q_j^\star\) are positive, these conditions together hold only if \(q=q^\star\). The identity therefore shows that \(J_\tau(q)\) is minimized at \(q^\star\), with equality nowhere else. Substitution of \(q=q^\star\) gives the stated minimum value. \(\square\)

A Calculus Derivation

The same formula can be obtained by differentiating the objective. The variational identity has already established that the minimizer is interior: all its coordinates are positive. On the interior of the simplex, write \( J_\tau(q)=\sum_jq_j\widehat R_j+\tau\sum_jq_j\log q_j+\tau\log M \). To impose the constraint \(\sum_jq_j=1\), introduce a Lagrange multiplier \(\lambda\). The derivative with respect to \(q_j\) of the constrained expression is \( \widehat R_j+\tau(\log q_j+1)+\lambda \). At an interior stationary point, each such derivative is zero, so

$$ \log q_j=-\frac{\widehat R_j}{\tau}-1-\frac{\lambda}{\tau}. $$

The last two terms do not depend on \(j\). Exponentiating shows that \(q_j=C\exp(-\widehat R_j/\tau)\) for a common positive constant \(C\). Enforcing \(\sum_jq_j=1\) requires \(C=1/Z_\tau\). This recovers the Gibbs weights. The preceding theorem supplies the global optimality and uniqueness justification, so stationarity alone is not being used to claim a global minimum.

The curvature also explains why the solution is unique. In the interior, the Hessian of \(J_\tau\) is diagonal with entries \(\tau/q_j\). For any nonzero direction \(v\), \( v^\mathsf{T}\nabla^2J_\tau(q)v=\tau\sum_jv_j^2/q_j>0 \). In particular, this is positive for every nonzero direction tangent to the simplex, where \(\sum_jv_j=0\). Thus the objective is strictly convex in the interior. The variational identity additionally handles the boundary and confirms the unique minimizer over the entire closed simplex.

Worked Example: Three Risks With Temperature One

Suppose the three empirical risks are \(1,2,3\), and let \(\tau=1\). The unnormalized weights are \(e^{-1},e^{-2},e^{-3}\), so

$$ Z_1=e^{-1}+e^{-2}+e^{-3} \approx 0.367879+0.135335+0.049787 =0.553002. $$

Dividing each unnormalized weight by this same normalizing constant gives \(q_1^\star\approx0.66524\), \(q_2^\star\approx0.24473\), and \(q_3^\star\approx0.09003\). The rounded weights sum to \(1.00000\). The smallest-risk candidate has the largest weight, but every candidate has positive weight at this finite positive temperature.

The minimum objective can also be checked from the identity: \(J_1(q^\star)=\log 3-\log Z_1\approx1.098612-(-0.592394)=1.691006\).

Worked Example: Risks Separated by Different Amounts

Take risks \(0\), \(0.5\), and \(2\), with \(\tau=0.5\). Then the exponents \(-\widehat R_j/\tau\) are \(0,-1,-4\). Thus

$$ Z_{0.5}=1+e^{-1}+e^{-4} \approx1+0.367879+0.018316 =1.386195. $$

The normalized weights are \( q_1^\star=1/Z_{0.5}\approx0.7214 \), \( q_2^\star=e^{-1}/Z_{0.5}\approx0.2654 \), and \( q_3^\star=e^{-4}/Z_{0.5}\approx0.0132 \). They sum to one up to rounding. For example, the second weight is obtained by dividing \(0.367879\) by \(1.386195\), not by dividing by the number of candidates. The normalization uses the sum of all three unnormalized weights.

Worked Example: Tied Minimum Risks

Let the risks be \(2,2,4\), and take \(\tau=2\). The unnormalized weights are \(e^{-1},e^{-1},e^{-2}\). Dividing numerator and denominator by \(e^{-1}\) makes the normalization especially simple:

$$ Z_2=e^{-1}(2+e^{-1}),\qquad q_1^\star=q_2^\star=\frac{1}{2+e^{-1}}\approx0.42232,\qquad q_3^\star=\frac{e^{-1}}{2+e^{-1}}\approx0.15536. $$

The two tied candidates receive equal weights because their risks are equal. The third weight is smaller because its risk is higher, but it is not zero. The weights sum to one: the first two contribute \(2/(2+e^{-1})\), and the third contributes \(e^{-1}/(2+e^{-1})\).

Risk Differences, Shifts, and the Zero-Temperature Boundary

The Gibbs formula depends on differences among risks rather than their common baseline. If every risk is increased by the same constant \(c\), then \( \exp(-(\widehat R_j+c)/\tau)=e^{-c/\tau}\exp(-\widehat R_j/\tau) \). The common factor \(e^{-c/\tau}\) appears in both numerator and normalizing constant and cancels. Hence the weights do not change. Likewise, the odds between any two candidates satisfy the exact relation

$$ \frac{q_j^\star}{q_k^\star} = \exp\!\left(-\frac{\widehat R_j-\widehat R_k}{\tau}\right). $$

This follows by dividing the two normalized weights; the common \(Z_\tau\) cancels. These identities are useful checks on a calculation: equal risks must give equal weights, and adding a constant to every risk must preserve all weights.

The positivity condition \(\tau>0\) is essential to the theorem. At \(\tau=0\), the objective reduces to \(\sum_jq_j\widehat R_j\). Its minimizers are distributions supported on the candidates with smallest empirical risk. That minimizer is unique only when there is a single risk-minimizing candidate. For \(\tau>0\), by contrast, the KL penalty yields the unique Gibbs distribution even when several candidates tie.

Common Pitfall

A frequent error is to write \(q_j^\star=\exp(-\widehat R_j/\tau)\) and call these values probabilities. They are unnormalized positive numbers; in general, they do not sum to one. The required denominator is \( Z_\tau=\sum_k\exp(-\widehat R_k/\tau) \), and every coordinate must be divided by it. A second bookkeeping error is to replace \(\operatorname{KL}(q\|u)\) by \(\sum_jq_j\log q_j\) when reporting the objective value. These expressions differ by \(\log M\). They have the same minimizer because the difference is constant in \(q\), but they do not have the same minimum value.

Key takeaway: For finite empirical risks and \(\tau>0\), minimizing average empirical risk plus \(\tau\operatorname{KL}(q\|u)\) gives a unique distribution with weights proportional to \(\exp(-\widehat R_j/\tau)\). The normalizing constant is the sum of all unnormalized weights.

Check Your Understanding

Use the definitions and identity above to answer the following questions.

  1. For risks \(0,1\) and \(\tau=1\), write the exact two Gibbs weights and verify that they sum to one.
  2. Why does the Gibbs distribution assign positive weight to every candidate when all risks are finite and \(\tau>0\)?
  3. If the same constant is added to every empirical risk, what happens to the normalized Gibbs weights? Show the cancellation.
  4. When \(\tau=0\), describe all minimizers if exactly two candidates tie for the smallest empirical risk.
  5. Explain why the Gibbs formula alone establishes a stationary point, while the relative-entropy identity establishes global optimality and uniqueness.
Clinical Biostats