dist_multinomial {distributional} | R Documentation |
The Multinomial distribution
Description
The multinomial distribution is a generalization of the binomial
distribution to multiple categories. It is perhaps easiest to think
that we first extend a dist_bernoulli()
distribution to include more
than two categories, resulting in a dist_categorical()
distribution.
We then extend repeat the Categorical experiment several ()
times.
Usage
dist_multinomial(size, prob)
Arguments
size |
The number of draws from the Categorical distribution. |
prob |
The probability of an event occurring from each draw. |
Details
We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.
In the following, let be a Multinomial
random variable with success probability
p
= . Note that
is vector with
elements that sum to one. Assume
that we repeat the Categorical experiment
size
= times.
Support: Each is in
.
Mean: The mean of is
.
Variance: The variance of is
.
For
, the covariance of
and
is
.
Probability mass function (p.m.f):
Cumulative distribution function (c.d.f):
Omitted for multivariate random variables for the time being.
Moment generating function (m.g.f):
See Also
Examples
dist <- dist_multinomial(size = c(4, 3), prob = list(c(0.3, 0.5, 0.2), c(0.1, 0.5, 0.4)))
dist
mean(dist)
variance(dist)
generate(dist, 10)
# TODO: Needs fixing to support multiple inputs
# density(dist, 2)
# density(dist, 2, log = TRUE)