mindspore/docs/api/api_python/nn_probability/mindspore.nn.probability.di...

186 lines
5.2 KiB
ReStructuredText
Raw Normal View History

2021-12-02 14:56:03 +08:00
mindspore.nn.probability.distribution.Exponential
===================================================
2022-05-05 17:40:46 +08:00
.. py:class:: mindspore.nn.probability.distribution.Exponential(rate=None, seed=None, dtype=mstype.float32, name='Exponential')
2021-12-02 14:56:03 +08:00
指数分布Exponential Distribution
连续随机分布,取值范围为所有实数,概率密度函数为
.. math::
f(x, \lambda) = \lambda \exp(-\lambda x).
其中 :math:`\lambda` 为分别为指数分布的率参数。
2021-12-02 14:56:03 +08:00
2022-07-12 18:39:07 +08:00
参数:
- **rate** (int, float, list, numpy.ndarray, Tensor) - 率参数。默认值None。
- **seed** (int) - 采样时使用的种子。如果为None则使用全局种子。默认值None。
- **dtype** (mindspore.dtype) - 事件样例的类型。默认值mstype.float32。
- **name** (str) - 分布的名称。默认值:'Exponential'。
2021-12-02 14:56:03 +08:00
.. note::
- `rate` 中的元素必须大于0。
2021-12-02 14:56:03 +08:00
- `dtype` 必须是float因为指数分布是连续的。
2022-07-12 18:39:07 +08:00
异常:
- **ValueError** - `rate` 中元素小于0。
- **TypeError** - `dtype` 不是float的子类。
2021-12-02 14:56:03 +08:00
.. py:method:: rate
:property:
返回 `rate`
2022-07-12 18:39:07 +08:00
返回:
Tensor率参数的值。
.. py:method:: cdf(value, rate)
在给定值下计算累积分布函数Cumulatuve Distribution Function, CDF
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor累积分布函数的值。
.. py:method:: cross_entropy(dist, rate_b, rate)
计算分布a和b之间的交叉熵。
2022-07-12 18:39:07 +08:00
参数:
- **dist** (str) - 分布的类型。
- **rate_b** (Tensor) - 对比分布的率参数。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor交叉熵的值。
.. py:method:: entropy(rate)
计算熵。
2022-07-12 18:39:07 +08:00
参数:
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor熵的值。
.. py:method:: kl_loss(dist, rate_b, rate)
计算KL散度即KL(a||b)。
2022-07-12 18:39:07 +08:00
参数:
- **dist** (str) - 分布的类型。
- **rate_b** (Tensor) - 对比分布的率参数。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
TensorKL散度。
.. py:method:: log_cdf(value, rate)
计算给定值对于的累积分布函数的对数。
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor累积分布函数的对数。
.. py:method:: log_prob(value, rate)
计算给定值对应的概率的对数。
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor累积分布函数的对数。
.. py:method:: log_survival(value, rate)
计算给定值对应的生存函数的对数。
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor生存函数的对数。
.. py:method:: mean(rate)
计算期望。
2022-07-12 18:39:07 +08:00
参数:
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor概率分布的期望。
.. py:method:: mode(rate)
计算众数。
2022-07-12 18:39:07 +08:00
参数:
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor概率分布的众数。
.. py:method:: prob(value, rate)
计算给定值下的概率。对于连续是计算概率密度函数Probability Density Function
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor概率值。
.. py:method:: sample(shape, rate)
采样函数。
2022-07-12 18:39:07 +08:00
参数:
- **shape** (tuple) - 样本的shape。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor根据概率分布采样的样本。
.. py:method:: sd(rate)
计算标准差。
2022-07-12 18:39:07 +08:00
参数:
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor概率分布的标准差。
.. py:method:: survival_function(value, rate)
计算给定值对应的生存函数。
2022-07-12 18:39:07 +08:00
参数:
- **value** (Tensor) - 要计算的值。
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor生存函数的值。
.. py:method:: var(rate)
计算方差。
2022-07-12 18:39:07 +08:00
参数:
- **rate** (Tensor) - 分布的率参数。默认值None。
2022-07-12 18:39:07 +08:00
返回:
Tensor概率分布的方差。