文档反馈

问题文档片段

问题文档片段包含公式时,显示为空格。

提交类型
issue

有点复杂...

找人问问吧。

PR

小问题,全程线上修改...

一键搞定!

请选择提交类型

问题类型
规范和低错类

- 规范和低错类:

- 错别字或拼写错误,标点符号使用错误、公式错误或显示异常。

- 链接错误、空单元格、格式错误。

- 英文中包含中文字符。

- 界面和描述不一致,但不影响操作。

- 表述不通顺,但不影响理解。

- 版本号不匹配:如软件包名称、界面版本号。

易用性

- 易用性:

- 关键步骤错误或缺失,无法指导用户完成任务。

- 缺少主要功能描述、关键词解释、必要前提条件、注意事项等。

- 描述内容存在歧义指代不明、上下文矛盾。

- 逻辑不清晰,该分类、分项、分步骤的没有给出。

正确性

- 正确性:

- 技术原理、功能、支持平台、参数类型、异常报错等描述和软件实现不一致。

- 原理图、架构图等存在错误。

- 命令、命令参数等错误。

- 代码片段错误。

- 命令无法完成对应功能。

- 界面错误,无法指导操作。

- 代码样例运行报错、运行结果不符。

风险提示

- 风险提示:

- 对重要数据或系统存在风险的操作,缺少安全提示。

内容合规

- 内容合规:

- 违反法律法规,涉及政治、领土主权等敏感词。

- 内容侵权。

请选择问题类型

问题描述

点击输入详细问题描述,以帮助我们快速定位问题。

mindspore.nn.probability.distribution.Poisson

查看源文件
class mindspore.nn.probability.distribution.Poisson(rate=None, seed=None, dtype=mstype.float32, name='Poisson')[源代码]

泊松分布(Poisson Distribution)。 离散随机分布,取值范围为正自然数集,概率质量函数为

P(X=k)=λkexp(λ)/k!,k=1,2,...

其中 λ 为率参数(rate)。

参数:
  • rate (list, numpy.ndarray, Tensor) - 泊松分布的率参数。默认值: None

  • seed (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值: None

  • dtype (mindspore.dtype) - 事件样例的类型。默认值: mstype.float32

  • name (str) - 分布的名称。默认值: 'Poisson'

说明

rate 必须大于0。 dist_spec_argsrate

异常:
  • ValueError - rate 中元素小于0。

支持平台:

Ascend

样例:

>>> import mindspore
>>> import mindspore.nn as nn
>>> import mindspore.nn.probability.distribution as msd
>>> from mindspore import Tensor
>>> # To initialize an Poisson distribution of the rate 0.5.
>>> p1 = msd.Poisson([0.5], dtype=mindspore.float32)
>>> # An Poisson distribution can be initialized without arguments.
>>> # In this case, `rate` must be passed in through `args` during function calls.
>>> p2 = msd.Poisson(dtype=mindspore.float32)
>>>
>>> # Here are some tensors used below for testing
>>> value = Tensor([1, 2, 3], dtype=mindspore.int32)
>>> rate_a = Tensor([0.6], dtype=mindspore.float32)
>>> rate_b = Tensor([0.2, 0.5, 0.4], dtype=mindspore.float32)
>>>
>>> # Private interfaces of probability functions corresponding to public interfaces, including
>>> # `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival`, are the same as follows.
>>> # Args:
>>> #     value (Tensor): the value to be evaluated.
>>> #     rate (Tensor): the rate of the distribution. Default: self.rate.
>>> # Examples of `prob`.
>>> # Similar calls can be made to other probability functions
>>> # by replacing `prob` by the name of the function.
>>> ans = p1.prob(value)
>>> print(ans.shape)
(3,)
>>> # Evaluate with respect to distribution b.
>>> ans = p1.prob(value, rate_b)
>>> print(ans.shape)
(3,)
>>> # `rate` must be passed in during function calls.
>>> ans = p2.prob(value, rate_a)
>>> print(ans.shape)
(3,)
>>> # Functions `mean`, `mode`, `sd`, and 'var' have the same arguments as follows.
>>> # Args:
>>> #     rate (Tensor): the rate of the distribution. Default: self.rate.
>>> # Examples of `mean`, `sd`, `mode`, and `var` are similar.
>>> ans = p1.mean() # return 2
>>> print(ans.shape)
(1,)
>>> ans = p1.mean(rate_b) # return 1 / rate_b
>>> print(ans.shape)
(3,)
>>> # `rate` must be passed in during function calls.
>>> ans = p2.mean(rate_a)
>>> print(ans.shape)
(1,)
>>> # Examples of `sample`.
>>> # Args:
>>> #     shape (tuple): the shape of the sample. Default: ()
>>> #     probs1 (Tensor): the rate of the distribution. Default: self.rate.
>>> ans = p1.sample()
>>> print(ans.shape)
(1, )
>>> ans = p1.sample((2,3))
>>> print(ans.shape)
(2, 3, 1)
>>> ans = p1.sample((2,3), rate_b)
>>> print(ans.shape)
(2, 3, 3)
>>> ans = p2.sample((2,3), rate_a)
>>> print(ans.shape)
(2, 3, 1)
property rate

返回分布的 rate 参数。

返回:

Tensor,rate 参数的值。

cdf(value, rate)

在给定值下计算累积分布函数(Cumulatuve Distribution Function, CDF)。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,累积分布函数的值。

log_cdf(value, rate)

计算给定值对于的累积分布函数的对数。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,累积分布函数的对数。

log_prob(value, rate)

计算给定值对应的概率的对数。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,累积分布函数的对数。

log_survival(value, rate)

计算给定值对应的生存函数的对数。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,生存函数的对数。

mean(rate)

计算期望。

参数:
  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,概率分布的期望。

mode(rate)

计算众数。

参数:
  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,概率分布的众数。

prob(value, rate)

计算给定值下的概率。对于离散分布是计算概率质量函数(Probability Mass Function)。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,概率值。

sample(shape, rate)

采样函数。

参数:
  • shape (tuple) - 样本的shape。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,根据概率分布采样的样本。

sd(rate)

计算标准差。

参数:
  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,概率分布的标准差。

survival_function(value, rate)

计算给定值对应的生存函数。

参数:
  • value (Tensor) - 要计算的值。

  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,生存函数的值。

var(rate)

计算方差。

参数:
  • rate (Tensor) - 率参数(rate)。默认值: None

返回:

Tensor,概率分布的方差。