Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions docs/api/paddle/distribution/Chi2_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.. _cn_api_paddle_distribution_Chi2:

Chi2
-------------------------------
.. py:class:: paddle.distribution.Chi2(df)


卡方分布是基于标准正态分布随机变量的平方和定义的一种连续概率分布。如果有 *k* 个独立的标准正态分布随机变量
:math:`Z_1, Z_2, \ldots, Z_k`, 那么这些随机变量的平方和
:math:`X = Z_1^2 + Z_2^2 + \cdots + Z_k^2`

服从自由度为 *k* 的卡方分布,记作
:math:`X \sim \chi^2(k)`



参数
::::::::::::

- **df** (float|Tensor) - 参数表示自由度,该值必须大于零。支持 Broadcast 语义。当参数类型为 Tensor 时,表示批量创建多个不同参数的分布,``batch_shape`` (参考 :ref:`cn_api_paddle_distribution_Distribution` 基类) 为参数。

代码示例
::::::::::::

COPY-FROM: paddle.distribution.Chi2


属性
:::::::::

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) - Chi2 的实例。

**返回**

- Tensor: 两个卡方分布之间的 KL 散度。


sample(shape)
'''''''''
随机采样,生成指定维度的样本。

**参数**

- **shape** (Sequence[int], optional) - 采样的样本维度。

**返回**

- **Tensor** - 指定维度的样本数据。数据类型为 float32。


rsample(shape)
'''''''''
重参数化采样,生成指定维度的样本。

**参数**

- **shape** (Sequence[int], optional) - 重参数化采样的样本维度。

**返回**

- **Tensor** - 指定维度的样本数据。数据类型为 float32。
62 changes: 62 additions & 0 deletions docs/api/paddle/distribution/LKJCholesky_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _cn_api_paddle_distribution_LKJCholesky:

LKJCholesky
-------------------------------
.. py:class:: paddle.distribution.LKJCholesky(dim, concentration=1.0, sample_method = 'onion')



LKJ 分布是一种用于生成随机相关矩阵的概率分布,广泛应用于贝叶斯统计中,特别是作为协方差矩阵的先验分布。它能够调节相关矩阵的集中度,从而控制变量间的相关性。

LKJ 分布通常定义为对相关矩阵 :math:`\Omega` 的分布,其密度函数为:

.. math::

p(\Omega \mid \eta) \propto |\Omega|^{\eta - 1}

其中,:math:`\Omega` 是一个 :math:`n \times n` 的相关矩阵,:math:`\eta` 是分布的形状参数,:math:`|\Omega|` 是矩阵的行列式。参数 :math:`\eta` 调节矩阵元素的分布集中度。


相关矩阵的下三角 Choleskey 因子的 LJK 分布支持两种 sample 方法:`onion` 和 `cvine`

参数
::::::::::::

- **dim** (int) - 目标相关矩阵的维度。
- **concentration** (float|Tensor) - 集中参数,这个参数控制了生成的相关矩阵的分布,值必须大于 0。concentration 越大,生成的矩阵越接近单位矩阵。
- **sample_method** (str) - 不同采样策略,可选项有:`onion` 和 `cvine`. 这两种 sample 方法都在 `Generating random correlation matrices based on vines and extended onion method <https://www.sciencedirect.com/science/article/pii/S0047259X09000876>`_ 中提出,并且在相关矩阵上提供相同的分布。但是它们在如何生成样本方面是不同的。默认为“onion”。
代码示例
::::::::::::

COPY-FROM: paddle.distribution.LKJCholesky


方法
:::::::::


log_prob(value)
'''''''''
卡方分布的对数概率密度函数。

**参数**

- **value** (float|Tensor) - 输入值。

**返回**

- **Tensor** - value 对应的对数概率密度。



sample(shape)
'''''''''
随机采样,生成指定维度的样本。

**参数**

- **shape** (Sequence[int], optional) - 采样的样本维度。

**返回**

- **Tensor** - 指定维度的样本数据。数据类型为 float32。
2 changes: 2 additions & 0 deletions docs/api/paddle/distribution/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ paddle.distribution 目录下包含飞桨框架支持的随机变量的概率分
" :ref:`ContinuousBernoulli <cn_api_paddle_distribution_ContinuousBernoulli>` ", "ContinuousBernoulli 概率分布类"
" :ref:`Categorical <cn_api_paddle_distribution_Categorical>` ", "Categorical 概率分布类"
" :ref:`Cauchy <cn_api_paddle_distribution_Cauchy>` ", "Cauchy 概率分布类"
" :ref:`Chi2 <cn_api_paddle_distribution_Chi2>` ", "Chi2 概率分布类"
" :ref:`Normal <cn_api_paddle_distribution_Normal>` ", "Normal 概率分布类"
" :ref:`Uniform <cn_api_paddle_distribution_Uniform>` ", "Uniform 概率分布类"
" :ref:`Beta <cn_api_paddle_distribution_Beta>` ", "Beta 概率分布类"
Expand All @@ -36,6 +37,7 @@ paddle.distribution 目录下包含飞桨框架支持的随机变量的概率分
" :ref:`Independent <cn_api_paddle_distribution_Independent>` ", "Independent 概率分布类"
" :ref:`TransfomedDistribution <cn_api_paddle_distribution_TransformedDistribution>` ", "TransformedDistribution 概率分布类"
" :ref:`Laplace <cn_api_paddle_distribution_Laplace>`", "Laplace 概率分布类"
" :ref:`LKJCholesky <cn_api_paddle_distribution_LKJCholesky>`", "LKJCholesky 概率分布类"
" :ref:`LogNormal <cn_api_paddle_distribution_LogNormal>` ", "LogNormal 概率分布类"
" :ref:`Poisson <cn_api_paddle_distribution_Poisson>` ", "Poisson 概率分布类"
" :ref:`Gumbel <cn_api_paddle_distribution_Gumbel>` ", "Gumbel 概率分布类"
Expand Down