It often comes up in neural networks, generalized linear models, topic models and many other probabilistic models that one wishes to parameterize a discrete distribution in terms of an unconstrained vector of numbers, i.e., a vector that is not confined to the simplex, might be negative, etc. A very common way to address this is to use the “softmax” transformation:

where the are unconstrained in , but the live on the simplex, i.e., and . The parameterize a discrete distribution (not uniquely) and we can generate data by performing the softmax transformation and then doing the usual thing to draw from a discrete distribution. Interestingly, it turns out that there is an alternative way to arrive at such discrete samples, that doesn’t actually require constructing the discrete distribution.

It turns out that the following trick is equivalent to the softmax-discrete procedure: add Gumbel noise to each and then take the argmax. That is, add independent noise to each one and then do a max. This doesn’t change the asymptotic complexity of the algorithm, but opens the door to some interesting implementation possibilities. How does this work? The Gumbel distribution with unit scale and location parameter has the following PDF:

The CDF of the Gumbel is

Now, imagine that the th of our Gumbels, with location , resulted in an outcome . The probability that all of the other are less than this is

We know the marginal distribution over and we need to integrate it out to find the overall probability:

With a little bit of algebra, we get:

It turns out that this integral has closed form:

We can see that this is exactly the softmax probability!

I am studying machine learning and my last name is Gumbel. This article made me happy.

-Matt