Gumbel
DistributionGumbel(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Gumbel (Type-I extreme value) distribution on .
Continuous distribution that models the maximum (or minimum) of a sample drawn from a number of distributions with exponential-like tails. It is the limiting distribution of the maximum of IID exponential-tailed variables (Fisher–Tippett–Gnedenko theorem) and is the basis of the celebrated Gumbel-max trick for differentiable sampling from categorical distributions.
Parameters
Notes
Probability density (with ):
Cumulative distribution:
Moments:
where is the Euler–Mascheroni constant. The mode is and the entropy is .
Gumbel-softmax trick: if IID and are category probabilities, then is a sample from . Replacing the argmax with a softmax yields a continuous relaxation that supports gradient flow through discrete choices (Jang et al., 2017; Maddison et al., 2017).
Examples
>>> import lucid
>>> from lucid.distributions import Gumbel
>>> d = Gumbel(loc=0.0, scale=1.0)
>>> d.rsample((4,)).shape
(4,)
>>> d.log_prob(lucid.tensor(0.0)) # -(0 + e^0)
tensor(-1.)Used by 3
Constructors
1__init__
→None__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Properties
3μ + s · γ where γ is the Euler–Mascheroni constant.
Mode of the Gumbel distribution.
Returns
TensorThe location parameter , which coincides with the mode of the Gumbel PDF.
(π · s)² / 6.
Instance methods
5Cumulative distribution function of the Gumbel distribution.
Returns probabilities in .
Examples
>>> Gumbel(loc=0.0, scale=1.0).cdf(lucid.tensor(0.0)) # 1/e
tensor(0.3679)log(s) + γ + 1.
Quantile function of the Gumbel distribution.
The reference framework builds the Gumbel from a uniform on (the dtype's smallest normal number and machine epsilon) so that no draw is infinite, and its quantile function maps onto that interval first. This does the same: the quantiles at 0 and 1 are finite — and in float32 — and every other one differs from the exact by a relative .
Returns quantiles.
Examples
>>> Gumbel(loc=0.0, scale=1.0).icdf(lucid.tensor(0.5)) # -ln(ln 2)
tensor(0.3665)Reparameterised sample via the Gumbel icdf: μ − s · log(−log U).