mindspore.ops.random_poisson

查看源文件
mindspore.ops.random_poisson(shape, rate, seed=None, dtype=mstype.float32)[源代码]

从指定均值为 rate 的泊松分布中,生成指定shape的随机样本。

P(i|μ)=exp(μ)μii!

警告

Ascend后端不支持随机数重现功能, seed 参数不起作用。

参数:
  • shape (Tensor) - 指定生成随机数的shape。一维整型tensor。

  • rate (Tensor) - 泊松分布的 μ 参数,表示泊松分布的均值,同时也是分布的方差。

  • seed (int, 可选) - 随机数种子。必须是一个非负整数,默认 None

  • dtype (mindspore.dtype) - 指定数据类型。默认 mstype.float32

返回:

Tensor, 形状为 mindspore.ops.concat([shape, rate.shape], axis=0)

支持平台:

GPU CPU

样例:

>>> import mindspore
>>> # case 1: 1-D shape, 2-D rate, float64 output
>>> shape = mindspore.tensor([2, 2], mindspore.int64)
>>> rate = mindspore.tensor([[5.0, 10.0], [5.0, 1.0]], mindspore.float32)
>>> output = mindspore.ops.random_poisson(shape, rate, seed=5, dtype=mindspore.float64)
>>> print(output.shape, output.dtype)
(2, 2, 2, 2) Float64
>>> # case 2: 1-D shape, scalar rate, int64 output
>>> shape = mindspore.tensor([2, 2], mindspore.int64)
>>> rate = mindspore.tensor(5.0, mindspore.float64)
>>> output = mindspore.ops.random_poisson(shape, rate, seed=5, dtype=mindspore.int64)
>>> print(output.shape, output.dtype)
(2, 2) Int64