Multinomial
DistributionMultinomial(total_count: Tensor | int = 1, probs: Tensor | None = None, logits: Tensor | None = None, validate_args: bool | None = None)Multinomial distribution over categories.
Multivariate generalisation of the lucid.distributions.Bernoulli
/Binomial: the joint distribution of the counts
obtained when
independent draws are made from a Categorical with probabilities
. The are non-negative integers
summing to .
The event dimension is the last axis of probs / logits; all
preceding axes form the batch shape.
Parameters
1 (a
one-hot Categorical sample).(..., K) —
normalised internally to sum to 1 along the last axis. Mutually
exclusive with logits.(..., K), converted
via softmax. Mutually exclusive with probs.validate_argsbool= NoneTrue, validate parameter constraints at construction time.Notes
Probability mass function (joint over the count vector with ):
Moments (per category):
Special cases:
- →
- → one-hot
lucid.distributions.Categorical
Conjugate prior: lucid.distributions.Dirichlet —
observing counts updates
Dirichlet(α) → Dirichlet(α + k).
Sampling is non-reparameterised (has_rsample = False) and
implemented by summing one-hot Categorical draws.
Examples
>>> import lucid
>>> from lucid.distributions import Multinomial
>>> d = Multinomial(total_count=10, probs=lucid.tensor([0.2, 0.3, 0.5]))
>>> d.mean # n * p
Tensor([2., 3., 5.])
>>> d.sample((4,))
Tensor([...])Used by 1
Constructors
1__init__
→None__init__(total_count: Tensor | int = 1, probs: Tensor | None = None, logits: Tensor | None = None, validate_args: bool | None = None)Initialise a Multinomial distribution.
Parameters
1 (reduces to a one-hot Categorical).(..., K).
Normalised to sum to 1 internally. Mutually exclusive with
logits.(..., K).
Converted to probabilities via softmax. Mutually exclusive with
probs.validate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Properties
4n · p (element-wise).
Support of the distribution: non-negative integers.
Returns
Constraintnonnegative_integer — the multinomial event count vector lives
in , subject to the additional
constraint that the counts sum to total_count.
Total number of trials per Multinomial draw.
Returns
TensorThe integer-valued n parameter broadcast over the batch shape.
Each independent Multinomial sums to this many trials across the
K categories.
n · p · (1 − p) (element-wise).