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
from paddle.distribution.gumbel import Gumbel

# Gumbel distributed with loc=0, scale=1
dist = Gumbel(paddle.full([1], 0.0), paddle.full([1], 1.0))
dist.sample([2])
# Tensor(shape=[2, 1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [[-0.27544352], [-0.64499271]])
value = paddle.full([1], 0.5)
dist.prob(value)
# Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [0.33070430])
dist.log_prob(value)
# Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [-1.10653067])
dist.cdf(value)
# Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [0.54523915])
dist.entropy()
# Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [1.57721567])
dist.rsample([2])
# Tensor(shape=[2, 1], dtype=float32, place=Place(gpu:0), stop_gradient=True, [[0.80463481], [0.91893655]])
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 )

prob

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_prob

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 )

cdf

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

Returns

cumulative probability of value.

Return type

Tensor

entropy ( )

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]

kl_divergence

The KL-divergence between self distributions and other.

probs ( value )

probs

Probability density/mass function.

Note

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

sample ( shape )

sample

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 )

rsample

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