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
locTensor or floatscaleTensor or floatvalidate_argsbool= NoneTrue, validate parameter constraints at construction time.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,))
Tensor([...])
>>> d.log_prob(lucid.tensor(0.0))
Tensor(-1.0)Methods (7)
__init__
→None__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Initialise a Gumbel distribution.
Parameters
locTensor | floatscaleTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.mean
→Tensormean: Tensorμ + s · γ where γ is the Euler–Mascheroni constant.
variance
→Tensorvariance: Tensor(π · s)² / 6.
mode
→Tensormode: TensorMode of the Gumbel distribution.
Returns
TensorThe location parameter , which coincides with the mode of the Gumbel PDF.
rsample
→Tensorrsample(sample_shape: tuple[int, ...] = ())Reparameterised sample via the Gumbel icdf: μ − s · log(−log U).
log_prob
→Tensorlog_prob(value: Tensor)Log-probability density of the Gumbel distribution.
Parameters
valueTensorReturns
TensorLog-density where .
entropy
→Tensorentropy()log(s) + γ + 1.