Poisson
ExponentialFamilyPoisson(rate: Tensor | float, validate_args: bool | None = None)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 . The Poisson distribution is the limiting case of a Binomial as and with fixed.
Parameters
rateTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Attributes
rateTensorNotes
PMF (probability mass function):
Moments:
- Mean:
- Variance:
- Mode:
The log-probability is computed as
, 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)
__init__
→None__init__(rate: Tensor | float, validate_args: bool | None = None)Initialise a Poisson distribution.
Parameters
rateTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.mean
→Tensormean: TensorMean of the Poisson distribution: .
Returns
TensorMean values equal to rate, shape batch_shape.
mode
→Tensormode: TensorMode of the Poisson distribution: .
When is an integer, both and are modes; this property returns .
Returns
TensorMode values of shape batch_shape.
variance
→Tensorvariance: TensorVariance of the Poisson distribution: .
Returns
TensorVariance values equal to rate, shape batch_shape.
sample
→Tensorsample(sample_shape: tuple[int, ...] = ())Draw samples from the Poisson distribution.
Delegates to lucid.poisson, which uses the Knuth exact
algorithm for small and a Normal approximation
with rounding for large .
Parameters
sample_shapetuple[int, ...]= ()Returns
TensorNon-negative integer samples of shape
(*sample_shape, *batch_shape).
log_prob
→Tensorlog_prob(value: Tensor)Log-probability of the given counts under the Poisson distribution.
Parameters
valueTensorReturns
TensorLog-probability values of the same shape as value.
entropy
→Tensorentropy()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