class

Poisson

extendsExponentialFamily
Poisson(rate: Tensor | float, validate_args: bool | None = None)
source

Poisson distribution over the non-negative integers.

Models the number of events occurring in a fixed interval when events happen independently at a constant mean rate λ\lambda. The Poisson distribution is the limiting case of a Binomial as nn \to \infty and p0p \to 0 with np=λnp = \lambda fixed.

Parameters

rateTensor | float
Mean rate λ>0\lambda > 0. Determines both the mean and the variance of the distribution.
validate_argsbool | None= None
If True, validate parameter constraints at construction time.

Attributes

rateTensor
The mean rate parameter λ\lambda.

Notes

PMF (probability mass function):

P(X=k)=λkeλk!,k{0,1,2,}P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}, \quad k \in \{0, 1, 2, \ldots\}

Moments:

  • Mean: E[X]=λE[X] = \lambda
  • Variance: Var[X]=λ\operatorname{Var}[X] = \lambda
  • Mode: λ\lfloor \lambda \rfloor

The log-probability is computed as klogλλlogΓ(k+1)k \log \lambda - \lambda - \log\Gamma(k+1), which is numerically stable via the lgamma function.

The Poisson has no closed-form entropy (it is an infinite sum over all non-negative integers), so entropy raises NotImplementedError.

Examples

>>> import lucid
>>> from lucid.distributions import Poisson
>>> dist = Poisson(rate=3.5)
>>> samples = dist.sample((100,))
>>> samples.shape
(100,)
>>> # log-probability at k=4
>>> dist.log_prob(lucid.tensor(4.0))

Methods (7)

dunder

__init__

None
__init__(rate: Tensor | float, validate_args: bool | None = None)
source

Initialise a Poisson distribution.

Parameters

rateTensor | float
Mean rate parameter λ>0\lambda > 0. Determines both the mean and the variance.
validate_argsbool | None= None
If True, validate parameter constraints at construction time.
prop

mean

Tensor
mean: Tensor
source

Mean of the Poisson distribution: E[X]=λE[X] = \lambda.

Returns

Tensor

Mean values equal to rate, shape batch_shape.

prop

mode

Tensor
mode: Tensor
source

Mode of the Poisson distribution: λ\lfloor \lambda \rfloor.

When λ\lambda is an integer, both λ\lambda and λ1\lambda - 1 are modes; this property returns λ\lfloor \lambda \rfloor.

Returns

Tensor

Mode values of shape batch_shape.

prop

variance

Tensor
variance: Tensor
source

Variance of the Poisson distribution: Var[X]=λ\operatorname{Var}[X] = \lambda.

Returns

Tensor

Variance values equal to rate, shape batch_shape.

fn

sample

Tensor
sample(sample_shape: tuple[int, ...] = ())
source

Draw samples from the Poisson distribution.

Delegates to lucid.poisson, which uses the Knuth exact algorithm for small λ\lambda and a Normal approximation with rounding for large λ\lambda.

Parameters

sample_shapetuple[int, ...]= ()
Leading shape of the output sample batch.

Returns

Tensor

Non-negative integer samples of shape (*sample_shape, *batch_shape).

fn

log_prob

Tensor
log_prob(value: Tensor)
source

Log-probability of the given counts under the Poisson distribution.

logP(X=k)=klogλλlogΓ(k+1)\log P(X = k) = k \log \lambda - \lambda - \log\Gamma(k + 1)

Parameters

valueTensor
Non-negative integer counts k0k \geq 0.

Returns

Tensor

Log-probability values of the same shape as value.

fn

entropy

Tensor
entropy()
source

Entropy of the Poisson distribution (not available in closed form).

The Poisson entropy is an infinite sum over all non-negative integers and has no simple closed form.

Raises

NotImplementedError
Always — use numerical approximation if needed.