# Gumbel¶

class paddle.distribution. Gumbel ( loc, scale ) [source]

The Gumbel distribution with location loc and scale parameters.

Mathematical details

The probability density function (pdf) is

$pdf(x; mu, sigma) = exp(-(x - mu) / sigma - exp(-(x - mu) / sigma)) / sigma$

In the above equation:

• $$loc = \mu$$: is the mean.

• $$scale = \sigma$$: is the std.

Parameters
• loc (int|float|tensor) – The mean of gumbel distribution.The data type is int, float, tensor.

• scale (int|float|tensor) – The std of gumbel distribution.The data type is int, float, tensor.

Examples

>>> import paddle

>>> # Gumbel distributed with loc=0, scale=1

>>>
>>> print(dist.sample([2]))
[[0.40484068],
[3.19400501]])

>>> print(dist.rsample([2]))
[[-0.95093185],
[ 0.32422572]])

>>>
>>> print(dist.prob(value))
[0.33070430])

>>> print(dist.log_prob(value))
[-1.10653067])

>>> print(dist.cdf(value))
[0.54523921])

>>> print(dist.entropy())
[1.57721567])

property mean

Mean of distribution

The mean is

$mean = \mu + \sigma * γ$

In the above equation:

• $$loc = \mu$$: is the location parameter.

• $$scale = \sigma$$: is the scale parameter.

• $$γ$$: is the euler’s constant.

Returns

mean value.

Return type

Tensor

property variance

Variance of distribution.

The variance is

$variance = \sigma^2 * \pi^2 / 6$

In the above equation:

• $$scale = \sigma$$: is the scale parameter.

Returns

The variance value.

Return type

Tensor

property stddev

Standard deviation of distribution

The standard deviation is

$stddev = \sqrt{\sigma^2 * \pi^2 / 6}$

In the above equation: * $$scale = \sigma$$: is the scale parameter.

Returns

std value

Return type

Tensor

prob ( value )

Probability density/mass function

Parameters

value (Tensor) – The input tensor.

Returns

probability.The data type is same with value.

Return type

Tensor

log_prob ( value )

Log probability density/mass function.

Parameters

value (Tensor) – The input tensor.

Returns

log probability.The data type is same with value.

Return type

Tensor

cdf ( value )

Cumulative distribution function. :param value: value to be evaluated. :type value: Tensor

Returns

cumulative probability of value.

Return type

Tensor

entropy ( )

Entropy of Gumbel distribution.

Returns

Entropy of distribution.

property batch_shape

Returns batch shape of distribution

Returns

batch shape

Return type

Sequence[int]

property event_shape

Returns event shape of distribution

Returns

event shape

Return type

Sequence[int]

kl_divergence ( other ) [source]

The KL-divergence between self distributions and other.

probs ( value )

Probability density/mass function.

Note

This method will be deprecated in the future, please use prob instead.

sample ( shape )

Sample from Gumbel.

Parameters

shape (Sequence[int], optional) – The sample shape. Defaults to ().

Returns

A tensor with prepended dimensions shape.The data type is float32.

Return type

Tensor

rsample ( shape )

reparameterized sample :param shape: 1D int32. Shape of the generated samples. :type shape: Sequence[int]

Returns

A tensor with prepended dimensions shape.The data type is float32.

Return type

Tensor