Gumbel

class paddle.distribution. Gumbel ( loc, scale ) [源代码]

耿贝尔分布

数学公式:

F(x;μ,β)=ee(xμ)β

上面数学公式中:

loc=μ:耿贝尔分布位置参数。

scale=β:耿贝尔分布尺度参数。

参数

  • loc (int|float|Tensor) - 耿贝尔分布位置参数。数据类型为 int、float、Tensor。

  • scale (int|float|Tensor) - 耿贝尔分布尺度参数。数据类型为 int、float、Tensor。

代码示例

>>> 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))

>>> print(dist.sample([2]))
Tensor(shape=[2, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.40484068],
[3.19400501]])

>>> print(dist.rsample([2]))
Tensor(shape=[2, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
[[-0.95093185],
[ 0.32422572]])

>>> value = paddle.full([1], 0.5)
>>> print(dist.prob(value))
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[0.33070430])

>>> print(dist.log_prob(value))
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[-1.10653067])

>>> print(dist.cdf(value))
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[0.54523921])

>>> print(dist.entropy())
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[1.57721567])

属性

mean

均值

数学公式:

mean=γ

上面数学公式中:

γ:欧拉常数。

variance

方差

数学公式:

variance=16π2β2

上面数学公式中:

scale=β:耿贝尔分布尺度参数。

stddev

标准差

数学公式:

stddev=16πβ

上面数学公式中:

scale=β:耿贝尔分布尺度参数。

方法

prob(value)

耿贝尔分布的概率密度函数。

参数

  • value (Tensor|Scalar) - 待计算的值。

数学公式:

prob(value)=ee(valueμ)β

上面数学公式中:

loc=μ:耿贝尔分布位置参数。

scale=β:耿贝尔分布尺度参数。

返回

  • Tensor - value 在耿贝尔分布下的概率值。

log_prob(value)

耿贝尔分布的对数概率密度函数。

参数

  • value (Tensor|Scalar) - 待计算的值。

数学公式:

log_prob(value)=log(ee(valueμ)β)

上面数学公式中:

loc=μ:耿贝尔分布位置参数。

scale=β:耿贝尔分布尺度参数。

返回

  • Tensor - value 在耿贝尔分布下的对数概率值。

cdf(value)

累积分布函数

参数

  • value (Tensor) - 输入 Tensor。

数学公式:

cdf(value)=ee(valueμ)β

上面的数学公式中:

loc=μ:耿贝尔分布位置参数。

scale=β:耿贝尔分布尺度参数。

返回

  • Tensor: value 对应 Gumbel 累积分布函数下的值。

entropy(scale)

耿贝尔分布的信息熵。

参数

  • scale (int|float|Tensor) - 耿贝尔分布的尺度参数。

数学公式:

entropy(scale) = ln(\beta) + 1 + γ

上面数学公式中:

scale = \beta:耿贝尔分布尺度参数。

\gamma:欧拉常数。

sample(shape)

随机采样,生成指定维度的样本。

参数

  • shape (list[int]) - 1 维列表,指定样本的维度。

返回

  • Tensor - 预先设计好维度的样本数据。

rsample(shape)

重参数化采样。

参数

  • shape (list[int]) - 1 维列表,指定样本的维度。

返回

  • Tensor - 预先设计好维度的样本数据。