# Poisson¶

class paddle.distribution. Poisson ( rate ) [source]

The Poisson distribution with occurrence rate parameter: rate.

In probability theory and statistics, the Poisson distribution is the most basic discrete probability distribution defined on the nonnegative integer set, which is used to describe the probability distribution of the number of random events occurring per unit time.

The probability mass function (pmf) is

$pmf(x; \lambda) = \frac{e^{-\lambda} \cdot \lambda^x}{x!}$

In the above equation:

• $$rate = \lambda$$: is the mean occurrence rate.

Parameters

rate (int|float|Tensor) – The mean occurrence rate of Poisson distribution which should be greater than 0, meaning the expected occurrence times of an event in a fixed time interval. If the input data type is int or float, the data type of rate will be converted to a 1-D Tensor with paddle global default dtype.

Examples

>>> import paddle

>>> print(rv.sample([3]))
[[35.],
[35.],
[30.]])

>>> print(rv.mean)
30.)

>>> print(rv.entropy())
[3.11671066])

>>> print(rv1.kl_divergence(rv2))
[[864.80285645, 0.          ],
[0.06825157  , 1.53426421  ]])

property mean

Mean of poisson distribution.

Returns

mean value.

Return type

Tensor

property variance

Variance of poisson distribution.

Returns

variance value.

Return type

Tensor

sample ( shape=() )

Generate poisson samples of the specified shape. The final shape would be shape+batch_shape .

Parameters

shape (Sequence[int], optional) – Prepended shape of the generated samples.

Returns

Sampled data with shape sample_shape + batch_shape.

Return type

Tensor

entropy ( )

Shannon entropy in nats.

The entropy is

$\mathcal{H}(X) = - \sum_{x \in \Omega} p(x) \log{p(x)}$

In the above equation:

• $$\Omega$$: is the support of the distribution.

Returns

Shannon entropy of poisson distribution. The data type is the same as rate.

Return type

Tensor

log_prob ( value )

Log probability density/mass function.

Parameters

value (Tensor) – The input tensor.

Returns

log probability. The data type is the same as rate.

Return type

Tensor

prob ( value )

Probability density/mass function.

Parameters

value (Tensor) – The input tensor.

Returns

probability. The data type is the same as rate.

Return type

Tensor

kl_divergence ( other ) [source]

The KL-divergence between two poisson distributions with the same batch_shape.

The probability density function (pdf) is

$KL\_divergence\lambda_1, \lambda_2) = \sum_x p_1(x) \log{\frac{p_1(x)}{p_2(x)}}$
$p_1(x) = \frac{e^{-\lambda_1} \cdot \lambda_1^x}{x!}$
$p_2(x) = \frac{e^{-\lambda_2} \cdot \lambda_2^x}{x!}$
Parameters

other (Poisson) – instance of Poisson.

Returns

Tensor, kl-divergence between two poisson distributions. The data type is the same as rate.

property batch_shape

Returns batch shape of distribution

Returns

batch shape

Return type

Sequence[int]

property event_shape

Returns event shape of distribution

Returns

event shape

Return type

Sequence[int]

probs ( value )

Probability density/mass function.

Note

This method will be deprecated in the future, please use prob instead.

rsample ( shape=() )

reparameterized sample