Why Temperature and Loss Scale Matter
Exponential weights turn empirical losses into a probability distribution over candidate predictors. A candidate with lower empirical risk receives more weight, but the size of the difference matters: a small risk gap can have little effect or a large effect depending on the temperature. The numerical scale used to record losses matters for the same reason. Risks measured in different units cannot be compared through the exponential formula without accounting for that scale.
The main point is that temperature controls sensitivity to loss differences, not the ordering of candidates. We will make that distinction precise, calculate its consequences, and show how relative entropy measures the weights’ concentration relative to a prior distribution.
Definition and Basic Identities
Consider a finite set of \(M\) candidates, indexed by \(j=1,\ldots,M\). Let \(\hat R_j\) be candidate \(j\)'s empirical risk, and let \(\pi_j>0\) be its prior weight, with \(\sum_{j=1}^M \pi_j=1\). For inverse temperature \(\eta\geq 0\), define the normalized exponential weights by
The denominator normalizes the weights so that they sum to one. When \(\eta>0\), the temperature is \(\tau=1/\eta\). Thus a low temperature means a large inverse temperature and greater sensitivity to risk gaps. At \(\eta=0\), the weights equal the prior: \(\hat w_j(0)=\pi_j\).
For any two candidates \(j\) and \(k\), division cancels the common normalizing constant:
This identity separates two influences. The prior ratio sets the starting odds, while the empirical-risk difference changes those odds exponentially. If \(j\) has smaller empirical risk than \(k\), increasing \(\eta\) increases the odds in favor of \(j\).
Worked Example: Changing Temperature for Three Candidates
Suppose the empirical risks are \((0,1,2)\) and the prior is uniform, so \(\pi_j=1/3\) for each candidate. Since the common factor \(1/3\) cancels, at \(\eta=\log 2\) the unnormalized weights are \(1,1/2,1/4\). Their sum is \(7/4\), giving
At \(\eta=\log 4\), the unnormalized weights are \(1,1/4,1/16\), with sum \(21/16\). Thus
The best candidate's weight rises from about \(0.571\) to \(0.762\). The risk ordering did not change; the larger inverse temperature made the existing risk gaps count more strongly.
Loss Rescaling and Temperature
Suppose every empirical risk is multiplied by the same constant \(c>0\), as when changing from one loss unit to another. With inverse temperature \(\eta'\), the weights based on the rescaled risks are proportional to \(\pi_j\exp(-\eta'c\hat R_j)\). They are exactly the original weights at inverse temperature \(\eta\) when \(\eta'c=\eta\).
Adding a common constant to every empirical risk also leaves the weights unchanged, because it multiplies every unnormalized weight by the same factor. These two facts give a useful general expression. For any \(a>0\) and any real \(b\), the weights formed from risks \(a\hat R_j+b\) at inverse temperature \(\eta'\) equal the original weights at \(\eta\) whenever \(\eta'a=\eta\). The additive shift \(b\) has no effect on the normalized weights.
Worked Example: Changing Loss Units
Use the three risks \((0,1,2)\), the uniform prior, and inverse temperature \(\eta=\log 2\). If risks are doubled, the new risks are \((0,2,4)\). Keeping the original inverse temperature would give unnormalized weights \(1,1/4,1/16\), so concentration would increase. To preserve the original weights, use \(\eta'=(\log 2)/2\). Then the exponents are
and the unnormalized weights are again \(1,1/2,1/4\). Normalizing gives \((4/7,2/7,1/7)\), exactly as before. Doubling the loss scale without adjusting temperature is not a neutral change: it doubles the effective inverse temperature.
How Concentration Changes
A direct measure of separation from the prior is the relative entropy
It is zero when the weights equal the prior and increases as the weights move away from it. The next result shows exactly how this measure changes with inverse temperature. All risks here are finite real numbers, and all prior weights are positive.
Proof. Write \(Z(\eta)=\sum_j\pi_j\exp(-\eta\hat R_j)\). Since this is a finite sum of differentiable functions and \(Z(\eta)>0\), its logarithm \(A(\eta)=\log Z(\eta)\) is differentiable. Differentiating gives
Differentiating the weights directly yields
Therefore
From the definition of the weights, \(\log(\hat w_j/\pi_j)=-\eta\hat R_j-\log Z(\eta)\). Summing this identity against \(\hat w_j\) gives \(D=-\eta\bar R-A\). Differentiate and use \(A'=-\bar R\):
The variance is nonnegative, which proves the claimed monotonicity. If the risks are not all equal and \(\eta>0\), the variance is positive because every weight is positive; in that case the relative entropy is strictly increasing. \(\square\)
This theorem quantifies concentration relative to the chosen prior, including when the prior is nonuniform. For a uniform prior, \(D(\hat w\Vert\pi)=\log M-H(\hat w)\), where \(H(\hat w)=-\sum_j\hat w_j\log\hat w_j\) is Shannon entropy. Consequently, with a uniform prior, Shannon entropy is nonincreasing as \(\eta\) increases. With a nonuniform prior, it is relative entropy from the prior—not necessarily Shannon entropy—that has the general monotonicity guarantee.
Worked Example: A Nonuniform Prior and a Risk Gap
Take empirical risks \((1,1.5,3)\), prior weights \((0.6,0.3,0.1)\), and \(\eta=2\). Subtracting 1 from every risk does not change the normalized weights, so use the shifted risks \((0,0.5,2)\). The unnormalized weights are
Their sum is approximately \(0.71220\), so the normalized weights are approximately \((0.8425,0.1550,0.0026)\). The first candidate had prior mass \(0.6\), but its lower empirical risk increases its weight substantially. The third candidate's higher risk reduces its weight despite its positive prior mass. The positive prior keeps every candidate's weight positive at finite \(\eta\); concentration is not the same as assigning exact zero weight.
The Low-Temperature Limit
The pairwise-ratio identity also describes the limiting behavior as \(\eta\) grows. Let \(\hat R_{\min}=\min_j\hat R_j\), and let \(S=\{j:\hat R_j=\hat R_{\min}\}\) be the set of empirical minimizers. Factoring \(\exp(-\eta\hat R_{\min})\) out of the normalizing constant gives
For \(j\in S\), the exponential factor in this expression equals one. For \(j\notin S\), the gap \(\hat R_j-\hat R_{\min}\) is positive, so that factor tends to zero as \(\eta\) tends to infinity. Since there are only finitely many candidates, the denominator tends to \(\sum_{k\in S}\pi_k>0\). It follows that
Thus low temperature concentrates on the empirical minimizers. If there is a unique minimizer, its weight tends to one. If several candidates tie, the limiting weights among them are proportional to their prior masses, rather than necessarily equal.
Worked Example: A Finite Temperature Is Not Hard Selection
Suppose three candidates have risks \((0,0.2,0.4)\), a uniform prior, and \(\eta=5\). After canceling the common prior, the unnormalized weights are \((1,e^{-1},e^{-2})\), which sum to approximately \(1.50321\). The normalized weights are approximately
At \(\eta=10\), the unnormalized weights are \((1,e^{-2},e^{-4})\), which sum to approximately \(1.15365\). The normalized weights are approximately \((0.8668,0.1173,0.0159)\). Increasing inverse temperature makes the weight on the lowest-risk candidate larger, but at either finite value all three candidates retain positive weight. Only in the limit \(\eta\to\infty\) does the unique minimizer receive weight one.
Common Mistake and Practical Use
A common mistake is to say, “Multiplying all losses by a constant does not change which candidate is best, so it does not change the weights.” The first clause is correct; the conclusion is not. The normalized weights depend on the products \(\eta\hat R_j\), not only on the ranking. Scaling losses by \(c\) while keeping \(\eta\) fixed changes the effective inverse temperature from \(\eta\) to \(c\eta\). The weights are preserved only if the inverse temperature is also divided by \(c\).
This distinction matters when choosing a temperature or comparing implementations that use different conventions for loss scale. A temperature that produces moderate concentration for a loss recorded between zero and one may produce near-hard selection if the same loss is recorded on a scale one hundred times larger. Before interpreting weights, check the loss units, the inverse temperature, and the prior. Pairwise odds provide a quick diagnostic: for a risk gap \(\Delta>0\), the odds in favor of the lower-risk candidate are multiplied by \(\exp(\eta\Delta)\), relative to the prior odds.
Check Your Understanding
Use the definitions and identities in this tutorial to answer the following.
- If every empirical risk is multiplied by 3, what change to inverse temperature preserves the exponential weights?
- For two candidates with equal prior weights and a risk gap of \(\Delta>0\), what is the ratio of the lower-risk candidate's weight to the higher-risk candidate's weight?
- Why does adding the same constant to every empirical risk leave normalized weights unchanged?
- What is the limiting distribution of the weights when several candidates tie for the minimum empirical risk?
- Why does the theorem guarantee that relative entropy from the prior is nondecreasing, even when the prior is nonuniform?