TL;DR
The Gumbel distribution is a bell-like curve with a longer tail on the right. For many common distributions, it is the limiting shape of the largest of many independent random variables once they are shifted and scaled. In machine learning it has a second use: adding Gumbel noise to a list of scores and keeping the highest one picks each option with exactly its intended probability.
Builds on: Cumulative Distribution Function, Uniform Distribution, Logarithm · Leads to: Gumbel-Softmax Trick
Where it's used
Yearly maximum floods and winds. Engineers who design dams, bridges and sea walls need to know how large the worst flood in a year is likely to be. For many rivers the yearly maximum flow is often modelled with a Gumbel distribution, fitted to decades of records, and then used to estimate how often a flood of a given size is expected. This is one of the classic uses of extreme value theory, the branch of statistics that studies maxima.
Choice models in economics. When a person picks one option from several, a common model assumes each option has a fixed value plus random taste noise. If that noise is Gumbel, the probability of each choice takes the simple softmax form, which gives the standard logit choice model used to forecast demand for transport and products.
Sampling discrete choices in neural networks. A network often outputs a score for each category, and sampling a category means picking one at random with the right probabilities. Adding independent Gumbel noise to the log-probabilities and taking the largest value does this exactly. The Gumbel-Softmax Trick builds on this to make the choice differentiable. The same idea can appear in discrete variational autoencoders, where the latent variable is a category.
How it works
We use the standard Gumbel distribution, the version with location 0 and scale 1. Its cumulative distribution function is
Read it as: for a value , is the chance that a Gumbel draw is at or below . The goal is to generate a Gumbel draw from a uniform random number, which is easy for a computer.
-
Start with a uniform number. Draw uniformly between 0 and 1. Suppose the draw is . Check: a uniform draw is equally likely to land anywhere in , so sits in the middle.
-
Turn the CDF into an equation. We want the value where the CDF equals the draw: . Taking the natural logarithm of both sides gives . Check: the right side is negative, and is also negative, so the equation is consistent.
-
Solve for x. Multiply by : . Take the logarithm again: , so . With , , and . So the Gumbel draw is about . Check: , which is the uniform draw we started with.
-
See what a larger uniform gives. Try . Then , and . So the draw is about . Check: . Large uniform draws map to large Gumbel draws, and the rare values above 2 come from the top 10 percent of uniform draws.
-
Shift and scale. A Gumbel with location and scale is , where is the standard draw. Its CDF is . The location moves the curve sideways, and the scale stretches it. Check: with and , the value maps to inside the exponent, the same as the standard case at .
The shape comes from the double exponential. The density is largest near the mode at 0, falls off fast on the left, and falls off slowly on the right. The right tail is what makes the Gumbel useful for maxima: a single very large value can still happen, while very small values are squeezed out.
The math
Definition
A random variable has a Gumbel distribution with location and scale when its CDF is
The standard case has and .
Step 1 in symbols: the density
Differentiating the CDF gives the density for the standard case:
Its derivative is , which is zero when , so the mode is at . Because the density decays like for large , the right tail is longer than a normal tail with the same centre.
Step 2 in symbols: inverting the CDF
Setting and solving gives the inverse
This is the formula used in step 3 of the walkthrough. For the standard case, gives .
Step 3 in symbols: mean and variance
For the Gumbel with location and scale , the mean and variance are
where is the Euler–Mascheroni constant. The mean is larger than the mode , which is the statement that the right tail pulls the average to the right.
Step 4 in symbols: the Gumbel-max trick
Let the categories have probabilities , and let be independent standard Gumbel draws. Then
So taking the largest noisy log-probability is an exact way to sample a category. This is the fact behind the third use in "Where it's used".
Worked examples
Let be a uniform draw, and find the standard Gumbel draw .
- Compute .
- Compute .
- Set , which is about .
- Check: , and , so .
Interpretation: the uniform draw in the middle of becomes a Gumbel draw slightly above 0, which is near the mode.
Let and . Find .
- Compute the standardised value: .
- Compute .
- Compute .
- So .
- Check: , a small but not negligible chance.
Interpretation: a Gumbel with scale 2 puts about 87 percent of its probability at or below 4, and the remaining 13 percent sits in the right tail.
This is an illustrative model, so the numbers are made up. The yearly maximum river flow, in cubic metres per second, is modelled as Gumbel with and . Find the chance that the yearly maximum exceeds 160.
- Standardise: .
- Compute .
- Compute .
- The chance of staying at or below 160 is , so the chance of exceeding it is .
- Convert to a return period: . So a flow above 160 is expected about once every 21 years, on average.
Interpretation: a design that must survive flows of this size needs to be safe for a roughly 1-in-21-year event, and the answer depends entirely on the fitted location and scale.
Try it. Use the same model, and . What is the chance that the yearly maximum exceeds 120?
Answer: Standardise: . Then , and . The chance of exceeding 120 is , about 0.31.
Common mistakes and tradeoffs
It is tempting to think the Gumbel is just a normal distribution with a different name. In fact it is skewed: its right tail decays like , much more slowly than the normal's . Far into the right tail, a Gumbel gives much larger probabilities than a normal with the same centre and spread.
It is tempting to think the maximum of any random values is Gumbel. In fact the limit depends on how the tail of the original distribution behaves. Many light-tailed families give a Gumbel limit for their maxima after shifting and scaling, but heavy-tailed families give different limit shapes, such as the Fréchet family. Sums of random values follow the central limit theorem instead, which gives a normal limit.
It is tempting to think the Gumbel-max trick needs any noise that looks similar. In fact the exact identity depends on the Gumbel shape. Other noise distributions in general give selection probabilities that differ from .
It is tempting to think the Gumbel-max trick gives gradients. In fact the hard argmax has no useful gradient. This is the reason the Gumbel-Softmax Trick replaces the argmax with a softmax at a chosen temperature, which trades exactness for a gradient.
When to use the Gumbel. Use it for maxima of many similar quantities, when the data look right-skewed and the upper tail matters, and for the Gumbel-max sampling trick.
When not to use it. Do not use it for heavy-tailed maxima without checking the fit, and do not assume a Gumbel fitted to a small sample describes rare events well.
Alternatives. The Exponential Distribution is the simpler model of waiting times with a constant rate. For maxima of heavy-tailed data, the Fréchet and generalised extreme value families are the usual choices.
History
In 1928, Ronald Fisher and Leonard Tippett showed that the maximum of many independent samples can only converge, after rescaling, to one of a small number of limit shapes. One of these is the Gumbel family.
Emil Gumbel, a statistician, developed the theory of extreme values in the mid-twentieth century, and his book Statistics of Extremes (1958) helped make these methods common in hydrology and engineering.
In machine learning, the Gumbel-max trick for exact sampling from a categorical distribution later became a standard tool. The continuous relaxation, the Gumbel-Softmax Trick, let researchers train networks that make discrete choices.
Recap
- The standard Gumbel has CDF , with a longer right tail than the normal.
- A uniform draw becomes a Gumbel draw by the inverse formula .
- Location and scale shift and stretch the curve, with mean and variance .
- For many light-tailed distributions, the maximum of many suitably scaled samples has a Gumbel limit, which is why the family appears in flood and wind studies.
- Adding independent Gumbel noise to log-probabilities and taking the argmax samples a category exactly, which is the base of the Gumbel-Softmax Trick.
Read next: Gumbel-Softmax Trick for how the noisy argmax becomes differentiable.
Check yourself
QuestionWhat is the CDF of the standard Gumbel distribution?Show answer
. Its value is the probability that a standard Gumbel draw is at or below .
QuestionA Gumbel has location and scale . What is ?Show answer
Standardise: . Then . So the answer is about 0.873.
QuestionWhy does the Gumbel-max trick take the argmax of noisy log-probabilities, instead of sampling from the probabilities directly?Show answer
Sampling directly needs a random draw and a search through the cumulative probabilities. The trick gives the same distribution with a single pass over the scores: adding independent Gumbel noise and taking the largest is exact, because the Gumbel shape makes the probability that each category wins equal to its probability . It also makes the sampling step a comparison of values, which is what the later relaxation builds on.
QuestionA hydrologist says the yearly flood maximum is Gumbel, and a colleague argues the normal distribution with the same mean and spread would give the same extreme-flood probabilities. Who is right, and why?Show answer
The colleague is wrong for extreme levels. The Gumbel has a right tail that decays like , while the normal's decays like . Far into the right tail the Gumbel gives much larger probabilities, so a normal fit would understate the risk of very large floods.
Sources
- Wikipedia, Gumbel distribution.
- Wikipedia, Extreme value theory.