Tutorials › Statistical Learning (Graduate) › Diagnosing Temperature and Normalization Errors

Exponential Weights and Convex Aggregation · Tutorial 343 of 989

Diagnosing Temperature and Normalization Errors

Learn to check the exponent, prior, normalization, and loss-range conditions before interpreting exponential weights or their guarantees.

Advanced 10 min read

What You'll Learn

  • Distinguish an inverse temperature from a temperature and translate between conventions.
  • Convert correctly between summed empirical loss and averaged empirical loss.
  • Compute normalized Gibbs weights while retaining the prior mass of each candidate.
  • Use a variational identity to understand the role of the prior penalty.
  • Identify when an exponential-weights regret bound requires an exp-concavity assumption.
  • Diagnose why a loss-range guarantee cannot be reused after an unaccounted rescaling.

Why Small Notational Choices Matter

Exponential weights can look deceptively simple: multiply each candidate’s prior weight by an exponential of its loss, then normalize. Yet four choices determine what that calculation means: whether loss is summed or averaged, whether the exponent uses a temperature or its reciprocal, whether prior weights are included, and whether the loss satisfies the assumptions behind the claimed guarantee. A mistake in any one of them can change the weights substantially or make a valid bound inapplicable.

This tutorial uses a finite dictionary of \(M\) candidates. Candidate \(j\) incurs loss \(\ell_{t,j}\) at round \(t\), and its cumulative loss through round \(n\) is \(L_{n,j}=\sum_{t=1}^n \ell_{t,j}\). Its average empirical loss is \(\hat R_n(j)=L_{n,j}/n\). The prior weights \(\pi_1,\ldots,\pi_M\) satisfy \(\pi_j\geq 0\) and \(\sum_j\pi_j=1\).

Definition: Given an inverse temperature \(\eta>0\), the Gibbs weights based on cumulative loss are \(q_{n,j}=\pi_j\exp(-\eta L_{n,j})/\sum_{k=1}^M\pi_k\exp(-\eta L_{n,k})\). Using average empirical loss instead gives \(q_{n,j}=\pi_j\exp(-\eta_{\mathrm{avg}}\hat R_n(j))/\sum_{k=1}^M\pi_k\exp(-\eta_{\mathrm{avg}}\hat R_n(k))\). The parameter multiplying loss in the negative exponent is the inverse temperature. If a convention calls \(T>0\) the temperature, then \(\eta=1/T\).

Sum Versus Average: The Factor of \(n\)

The two loss conventions are equivalent only when their inverse temperatures are adjusted. Since \(L_{n,j}=n\hat R_n(j)\), the summed-loss exponent \(-\eta_{\mathrm{sum}}L_{n,j}\) equals the averaged-loss exponent \(-\eta_{\mathrm{avg}}\hat R_n(j)\) exactly when \(\eta_{\mathrm{avg}}=n\eta_{\mathrm{sum}}\). Keeping the same numerical value of \(\eta\) while switching conventions changes the distribution over candidates.

Worked Example: How Averaging Changes the Weights

There are two candidates with equal prior weights, \(\pi_1=\pi_2=1/2\). Over \(n=3\) observations, their cumulative losses are \(L_{3,1}=3\) and \(L_{3,2}=1\). Compare the weights using inverse temperature \(0.5\) in the summed-loss and averaged-loss formulas.

Summed loss. The unnormalized weights are \((1/2)e^{-0.5(3)}\) and \((1/2)e^{-0.5(1)}\). The common factor \(1/2\) cancels, so \(q_{3,1}/q_{3,2}=e^{-1}\). Thus \(q_{3,1}=1/(1+e)\approx0.26894\) and \(q_{3,2}=e/(1+e)\approx0.73106\).

Averaged loss, same numerical inverse temperature. The average losses are \(1\) and \(1/3\), so \(q_{3,1}/q_{3,2}=\exp[-0.5(1-1/3)]=e^{-1/3}\). Therefore \(q_{3,1}=1/(1+e^{1/3})\approx0.41743\) and \(q_{3,2}\approx0.58257\).

The discrepancy is not a numerical error: the second calculation used a different effective exponent. To reproduce the summed-loss weights from average loss, use \(\eta_{\mathrm{avg}}=3(0.5)=1.5\). Then the ratio is \(\exp[-1.5(2/3)]=e^{-1}\), as required.

A related convention error is reversing temperature and inverse temperature. Increasing \(\eta\) concentrates weight more strongly on low-loss candidates; increasing \(T=1/\eta\) makes weights more diffuse. If a formula is written as \(\exp(-L/T)\), its coefficient is \(1/T\), not \(T\). Checking the exponent directly is safer than relying on the word “temperature.”

The Prior Belongs in the Numerator

The prior is not an optional decoration. It determines the initial mass assigned to each candidate, and that mass affects the normalized weights and the complexity term in standard oracle bounds. A candidate with \(\pi_j=0\) receives zero Gibbs weight for every finite loss and cannot be recovered by normalization. In a finite-dictionary bound involving \(\log(1/\pi_j)\), a zero prior also makes the penalty infinite.

For positive prior weights, define the normalizing constant \(Z_n=\sum_j\pi_j e^{-\eta L_{n,j}}\). The identity below makes the prior’s role precise: the normalized exponential weights minimize empirical loss plus a divergence penalty relative to that prior.

Theorem: Suppose \(\pi_j>0\) for every \(j\), \(\sum_j\pi_j=1\), and all \(L_{n,j}\) are finite. For any probability vector \(\rho=(\rho_1,\ldots,\rho_M)\), define \(\operatorname{KL}(\rho\|\pi)=\sum_{j:\rho_j>0}\rho_j\log(\rho_j/\pi_j)\). Then \(-\eta^{-1}\log Z_n=\min_{\rho}\{\sum_j\rho_jL_{n,j}+\eta^{-1}\operatorname{KL}(\rho\|\pi)\}\). The minimum is attained at \(q_{n,j}=\pi_je^{-\eta L_{n,j}}/Z_n\).

Proof. From the definition of \(q_{n,j}\), for each \(j\), \(\log(q_{n,j}/\pi_j)=-\eta L_{n,j}-\log Z_n\). For any probability vector \(\rho\), \(\operatorname{KL}(\rho\|q_n)=\operatorname{KL}(\rho\|\pi)+\eta\sum_j\rho_jL_{n,j}+\log Z_n\). Rearranging gives \(\sum_j\rho_jL_{n,j}+\eta^{-1}\operatorname{KL}(\rho\|\pi)=-\eta^{-1}\log Z_n+\eta^{-1}\operatorname{KL}(\rho\|q_n)\). The final term is nonnegative and equals zero when \(\rho=q_n\). This proves both the minimum value and its minimizer. \(\square\)

Worked Example: Prior-Weighted Normalization

Take three candidates with prior weights \((0.8,0.15,0.05)\), losses \((0.4,0.8,0.2)\), and inverse temperature \(\eta=1\). The unnormalized Gibbs weights are \(0.8e^{-0.4}=0.53625604\), \(0.15e^{-0.8}=0.06739934\), and \(0.05e^{-0.2}=0.04093654\).

Their sum is \(Z=0.64459192\). Dividing each by this same normalizer gives \(q_1=0.83193\), \(q_2=0.10456\), and \(q_3=0.06351\), which sum to \(1.00000\) up to rounding.

If the prior is mistakenly omitted, the unnormalized values become \(e^{-0.4}\), \(e^{-0.8}\), and \(e^{-0.2}\), whose sum is \(1.93837976\). The resulting weights are approximately \((0.34581,0.23181,0.42238)\). In particular, the third candidate’s small prior mass is no longer represented. The corrected prior-weighted third weight is \(0.06351\), not \(0.063\); retaining enough digits matters when checking normalized values.

What a Standard Exponential-Weights Bound Requires

The normalization calculation alone is always valid for finite losses and \(\eta>0\). A prediction guarantee needs more. One common deterministic guarantee uses exp-concavity: for each outcome \(y\), the map \(a\mapsto \exp[-\eta\ell(y,a)]\) must be concave on the convex prediction set. The aggregated prediction must be the corresponding convex combination of candidate predictions, and the same loss function and value of \(\eta\) must be used in the concavity condition and in the weight update. This is a substantive assumption, not a consequence of merely having exponential weights.

Theorem: Suppose there are finitely many candidates with prior weights \(\pi_j>0\) summing to one. At each round \(t\), candidate \(j\) predicts \(a_{t,j}\) in a convex set, and the aggregate predicts \(a_t=\sum_jq_{t,j}a_{t,j}\). Assume \(a\mapsto e^{-\eta\ell(y_t,a)}\) is concave on that set for every observed \(y_t\). Initialize \(q_{1,j}=\pi_j\) and update proportionally to \(q_{t,j}e^{-\eta\ell(y_t,a_{t,j})}\). Then, for every candidate \(j\) and every \(n\), \(\sum_{t=1}^n\ell(y_t,a_t)\leq\sum_{t=1}^n\ell(y_t,a_{t,j})+\eta^{-1}\log(1/\pi_j)\).

Proof. Concavity and the definition of \(a_t\) give \(e^{-\eta\ell(y_t,a_t)}\geq\sum_jq_{t,j}e^{-\eta\ell(y_t,a_{t,j})}\). Taking negative logarithms and dividing by \(\eta>0\) yields \(\ell(y_t,a_t)\leq-\eta^{-1}\log\sum_jq_{t,j}e^{-\eta\ell(y_t,a_{t,j})}\). Let \(W_1=1\) and \(W_{t+1}=\sum_j\pi_j\exp[-\eta\sum_{s=1}^t\ell(y_s,a_{s,j})]\). The update gives \(q_{t,j}=\pi_j\exp[-\eta\sum_{s<t}\ell(y_s,a_{s,j})]/W_t\), so the right side of the preceding loss inequality equals \(-\eta^{-1}\log(W_{t+1}/W_t)\). Summing over \(t\) telescopes to aggregate loss at most \(-\eta^{-1}\log W_{n+1}\). Since \(W_{n+1}\geq\pi_j\exp[-\eta\sum_{t=1}^n\ell(y_t,a_{t,j})]\), taking negative logarithms and dividing by \(\eta\) proves the result. \(\square\)

Loss-Range Assumptions and Scaling

Some guarantees instead use a stated bounded-loss condition, such as \(0\leq\ell\leq1\), or a range of width \(B\). These conditions must be checked for the actual loss entering the formula. A result proved for unit-range losses cannot simply be applied to losses that may be 100 times larger with the same numerical inverse temperature. The exponential weights then respond to a 100-fold larger exponent.

A constant shift of all candidate losses at a given observation does not alter normalized weights: multiplying every unnormalized weight by the same positive factor cancels in the denominator. Rescaling is different. Replacing \(\ell\) by \(c\ell\), \(c>0\), preserves weights only if \(\eta\) is replaced by \(\eta/c\), since \((\eta/c)(c\ell)=\eta\ell\). Any theorem’s assumptions and constants must also be reconsidered after rescaling; preserving a numerical distribution does not automatically preserve the theorem’s stated hypotheses.

Worked Example: A Range Violation Changes Concentration

Consider two candidates with equal prior weights and losses \(0\) and \(1\), using \(\eta=1\). The weight on the zero-loss candidate is \(1/(1+e^{-1})\approx0.73106\).

Now express the same loss in units multiplied by 100, so the losses are \(0\) and \(100\). If \(\eta=1\) is retained, the corresponding weight becomes \(1/(1+e^{-100})\), which is essentially \(1\). This is not the same weighting rule on the original scale.

To preserve the original weights, use inverse temperature \(0.01\) with the rescaled losses: \(0.01(100)=1\), so the weight is again \(1/(1+e^{-1})\approx0.73106\). But if a cited guarantee assumes losses in \([0,1]\), the rescaled loss in \([0,100]\) does not satisfy that assumption. One must use a result valid for the new range or rescale the loss and correctly translate the bound.

A Practical Diagnostic Checklist

When an exponential-weights expression or guarantee appears inconsistent, check the calculation in a fixed order. First identify the loss being exponentiated: a single-round loss, cumulative loss, or average empirical loss. Next identify the coefficient multiplying that loss, rather than trusting whether the author calls it temperature or inverse temperature. Then confirm that every prior mass is present and that the normalizer sums over the full candidate set. Finally, inspect the exact assumption used by the guarantee: exp-concavity on the prediction domain, a bounded range, or another stated condition.

These checks matter beyond arithmetic. The prior determines how much complexity is charged to a candidate, the loss convention determines the effective strength of the update, and range conditions determine whether a theorem applies at all. A weight vector can be normalized perfectly and still be based on the wrong exponent or an unjustified guarantee.

Common Mistakes

  • Using one inverse temperature for both conventions. Since \(L_n=n\hat R_n\), equivalent summed- and average-loss formulas require \(\eta_{\mathrm{avg}}=n\eta_{\mathrm{sum}}\).
  • Confusing temperature with inverse temperature. In \(\exp(-L/T)\), the coefficient of loss is \(1/T\). A smaller \(T\) produces stronger concentration.
  • Dropping the prior. The update is proportional to \(\pi_j e^{-\eta L_j}\), not just \(e^{-\eta L_j}\), unless the prior is explicitly uniform.
  • Assuming normalization proves a regret guarantee. Normalization is algebra; a prediction guarantee also needs its stated loss and aggregation assumptions.
  • Reusing a unit-range result after rescaling. Changing the loss scale changes both the exponent and the range condition. Adjusting \(\eta\) may preserve weights, but does not by itself verify the theorem’s assumptions.
Key takeaway: Audit the exponent, prior, normalizer, and loss assumptions separately. Equivalent weights require matching the effective coefficient on loss; valid guarantees additionally require the theorem’s hypotheses on the actual prediction problem and loss scale.

Check Your Understanding

For each question, identify the formula or assumption that controls the answer.

  1. For \(n=5\), what inverse temperature on average empirical loss gives the same Gibbs weights as inverse temperature \(0.2\) on cumulative loss?
  2. If a formula uses \(\exp(-L/T)\), what happens to concentration as \(T\) increases?
  3. Why can omitting a nonuniform prior change the normalized weights even though both versions are divided by a normalizing constant?
  4. Which condition in the theorem above permits the aggregate loss to be bounded by the log-sum of candidate exponential losses?
  5. A loss is multiplied by 10. What inverse-temperature adjustment preserves the Gibbs weights, and why must the original range-based guarantee still be checked?
Clinical Biostats