mindspore.ops.random_poisson

View Source On Gitee
mindspore.ops.random_poisson(shape, rate, seed=None, dtype=mstype.float32)[source]

Generate random number Tensor with shape according to a Poisson distribution with mean rate.

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

Warning

The Ascend backend does not support the reproducibility of random numbers, so the seed parameter has no effect.

Parameters
  • shape (Tensor) – The shape of random tensor to be sampled from each poisson distribution, 1-D integer tensor.

  • rate (Tensor) – The μ parameter the distribution is constructed with. It represents the mean of poisson distribution and also the variance of the distribution.

  • seed (int, optional) – Random seed, must be non-negative. Default None .

  • dtype (mindspore.dtype) – The data type returned. Default mstype.float32.

Returns

Tensor, the shape is mindspore.ops.concat([shape, rate.shape], axis=0).

Supported Platforms:

GPU CPU

Examples

>>> 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