From d575945ac5cb31c327c85c8b9f4ea5f14288841c Mon Sep 17 00:00:00 2001 From: MayYouBeProsperous Date: Thu, 21 Dec 2023 16:00:51 +0800 Subject: [PATCH 1/3] add Exponential and Gamma docs --- .../paddle/distribution/Exponential_cn.rst | 172 ++++++++++++++++++ docs/api/paddle/distribution/Gamma_cn.rst | 126 +++++++++++++ docs/api/paddle/distribution/Overview_cn.rst | 2 + 3 files changed, 300 insertions(+) create mode 100644 docs/api/paddle/distribution/Exponential_cn.rst create mode 100644 docs/api/paddle/distribution/Gamma_cn.rst diff --git a/docs/api/paddle/distribution/Exponential_cn.rst b/docs/api/paddle/distribution/Exponential_cn.rst new file mode 100644 index 00000000000..5f4fc3b227a --- /dev/null +++ b/docs/api/paddle/distribution/Exponential_cn.rst @@ -0,0 +1,172 @@ +.. _cn_api_paddle_distribution_Exponential: + +Exponential +------------------------------- + +.. py:class:: paddle.distribution.Exponential(rate) + +指数分布 + +指数分布的概率密度满足一下公式: + +.. math:: + + f(x; \theta) = \theta e^{- \theta x }, (x \ge 0) $$ + +上面数学公式中: + + :math:`rate=\theta`:表示率参数。 + + +参数 +:::::::::::: + + - **rate** (float|Tensor) - 率参数,该值必须大于零。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.distribution.Exponential + +属性 +::::::::: + +mean +''''''''' +指数分布的均值。 + + + +variance +''''''''' +指数分布的方差。 + + + +方法 +::::::::: + +prob(value) +''''''''' +指数分布的概率密度函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + +数学公式: +.. math:: + + f(x; \theta) = \theta e^{- \theta x }, (x \ge 0) $$ + +上面数学公式中: + + :math:`rate=\theta`:表示率参数。 + +**返回** + + - **Tensor** - value 对应的概率密度。 + + +log_prob(value) +''''''''' +指数分布的对数概率密度函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + +**返回** + + - **Tensor** - value 对应的对数概率密度。 + +entropy() +''''''''' +指数分布的信息熵。 + +**返回** + + - Tensor: 信息熵。 + +cdf(k) +''''''''' +指数分布的累积分布函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + +数学公式: + +.. math:: + + cdf(x; \theta) = 1 - e^{- \theta x }, (x \ge 0) + +上面的数学公式中: + + :math:`rate=\theta`:表示率参数。 + +**返回** + + - Tensor: value 对应的累积分布。 + +icdf(k) +''''''''' +指数分布的逆累积分布函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + +数学公式: + +.. math:: + + icdf(x; \theta) = -\frac{ 1 }{ \theta } ln(1 + x), (x \ge 0) + +上面的数学公式中: + + :math:`rate=\theta`:表示率参数。 + +**返回** + + - Tensor: value 对应的逆累积分布。 + + +kl_divergence(other) +''''''''' +两个指数分布之间的 KL 散度。 + +**参数** + + - **other** (Geometric) - Exponential 的实例。 + +**返回** + + - Tensor: 两个指数分布之间的 KL 散度。 + + +sample(shape) +''''''''' +随机采样,生成指定维度的样本。 + +**参数** + + - **shape** (Sequence[int], optional) - 采样的样本维度。 + +**返回** + + - **Tensor** - 指定维度的样本数据。数据类型为 float32。 + + +rsample(shape) +''''''''' +重参数化采样,生成指定维度的样本。 + +**参数** + + - **shape** (Sequence[int], optional) - 重参数化采样的样本维度。 + +**返回** + + - **Tensor** - 指定维度的样本数据。数据类型为 float32。 diff --git a/docs/api/paddle/distribution/Gamma_cn.rst b/docs/api/paddle/distribution/Gamma_cn.rst new file mode 100644 index 00000000000..70aa8342856 --- /dev/null +++ b/docs/api/paddle/distribution/Gamma_cn.rst @@ -0,0 +1,126 @@ +.. _cn_api_paddle_distribution_Gamma: + +Gamma +------------------------------- + +.. py:class:: paddle.distribution.Gamma(rate) + +伽马分布 + +伽马分布的概率密度满足一下公式: + +.. math:: + + f(x; \alpha, \beta, x > 0) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha-1}e^{-\beta x} + + \Gamma(\alpha)=\int_{0}^{\infty} x^{\alpha-1} e^{-x} \mathrm{~d} x, (\alpha>0) + +上面数学公式中: + + :math:`concentration=\alpha`:表示集中参数。 + + :math:`rate=\beta`:表示率参数。 + + +参数 +:::::::::::: + + - **concentration** (float|Tensor) - 率参数,该值必须大于零。支持 Broadcast 语义。当参数类型为 Tensor 时,表示批量创建多个不同参数的分布,``batch_shape`` (参考 :ref:`cn_api_paddle_distribution_Distribution` 基类) 为参数。 + + - **rate** (float|Tensor) - 率参数,该值必须大于零。支持 Broadcast 语义。当参数类型为 Tensor 时,表示批量创建多个不同参数的分布,``batch_shape`` (参考 :ref:`cn_api_paddle_distribution_Distribution` 基类) 为参数。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.distribution.Gamma + + +属性 +::::::::: + +mean +''''''''' +伽马分布的均值。 + + +variance +''''''''' +伽马分布的方差。 + + +方法 +::::::::: + +prob(value) +''''''''' +伽马分布的概率密度函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + + +**返回** + + - **Tensor** - value 对应的概率密度。 + + +log_prob(value) +''''''''' +伽马分布的对数概率密度函数。 + +**参数** + + - **value** (float|Tensor) - 输入值。 + +**返回** + + - **Tensor** - value 对应的对数概率密度。 + + +entropy() +''''''''' +伽马分布的信息熵。 + +**返回** + + - Tensor: 信息熵。 + + +kl_divergence(other) +''''''''' +两个伽马分布之间的 KL 散度。 + +**参数** + + - **other** (Geometric) - Gamma 的实例。 + +**返回** + + - Tensor: 两个伽马分布之间的 KL 散度。 + + +sample(shape) +''''''''' +随机采样,生成指定维度的样本。 + +**参数** + + - **shape** (Sequence[int], optional) - 采样的样本维度。 + +**返回** + + - **Tensor** - 指定维度的样本数据。数据类型为 float32。 + + +rsample(shape) +''''''''' +重参数化采样,生成指定维度的样本。 + +**参数** + + - **shape** (Sequence[int], optional) - 重参数化采样的样本维度。 + +**返回** + + - **Tensor** - 指定维度的样本数据。数据类型为 float32。 diff --git a/docs/api/paddle/distribution/Overview_cn.rst b/docs/api/paddle/distribution/Overview_cn.rst index 21fb47c00f6..dd0ce5b46ab 100644 --- a/docs/api/paddle/distribution/Overview_cn.rst +++ b/docs/api/paddle/distribution/Overview_cn.rst @@ -38,6 +38,8 @@ paddle.distribution 目录下包含飞桨框架支持的随机变量的概率分 " :ref:`LogNormal ` ", "LogNormal 概率分布类" " :ref:`Gumbel ` ", "Gumbel 概率分布类" " :ref:`Geometric ` ", "Geometric 概率分布类" + " :ref:`Exponential ` ", "Exponential 概率分布类" + " :ref:`Gamma ` ", "Gamma 概率分布类" .. _about_distribution_transform: From f57a2e17bf436a6612bb315b1aff1c68a21bcb69 Mon Sep 17 00:00:00 2001 From: MayYouBeProsperous Date: Thu, 4 Jan 2024 16:13:55 +0800 Subject: [PATCH 2/3] Update Exponential_cn.rst --- docs/api/paddle/distribution/Exponential_cn.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/api/paddle/distribution/Exponential_cn.rst b/docs/api/paddle/distribution/Exponential_cn.rst index 5f4fc3b227a..2ffb2dfc4b7 100644 --- a/docs/api/paddle/distribution/Exponential_cn.rst +++ b/docs/api/paddle/distribution/Exponential_cn.rst @@ -36,13 +36,11 @@ mean 指数分布的均值。 - variance ''''''''' 指数分布的方差。 - 方法 ::::::::: From 16a6e7131f50308390fd3013c99b6216b0d74390 Mon Sep 17 00:00:00 2001 From: MayYouBeProsperous Date: Thu, 4 Jan 2024 17:06:37 +0800 Subject: [PATCH 3/3] Update Gamma_cn.rst --- docs/api/paddle/distribution/Gamma_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/distribution/Gamma_cn.rst b/docs/api/paddle/distribution/Gamma_cn.rst index 70aa8342856..50ff6dcd1b5 100644 --- a/docs/api/paddle/distribution/Gamma_cn.rst +++ b/docs/api/paddle/distribution/Gamma_cn.rst @@ -3,7 +3,7 @@ Gamma ------------------------------- -.. py:class:: paddle.distribution.Gamma(rate) +.. py:class:: paddle.distribution.Gamma(concentration, rate) 伽马分布