dist_multinomial {distributional}R Documentation

The Multinomial distribution

Description

[Stable]

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 (nn) 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 X=(X1,...,Xk)X = (X_1, ..., X_k) be a Multinomial random variable with success probability p = pp. Note that pp is vector with kk elements that sum to one. Assume that we repeat the Categorical experiment size = nn times.

Support: Each XiX_i is in 0,1,2,...,n{0, 1, 2, ..., n}.

Mean: The mean of XiX_i is npin p_i.

Variance: The variance of XiX_i is npi(1pi)n p_i (1 - p_i). For iji \neq j, the covariance of XiX_i and XjX_j is npipj-n p_i p_j.

Probability mass function (p.m.f):

P(X1=x1,...,Xk=xk)=n!x1!x2!...xk!p1x1p2x2...pkxk P(X_1 = x_1, ..., X_k = x_k) = \frac{n!}{x_1! x_2! ... x_k!} p_1^{x_1} \cdot p_2^{x_2} \cdot ... \cdot p_k^{x_k}

Cumulative distribution function (c.d.f):

Omitted for multivariate random variables for the time being.

Moment generating function (m.g.f):

E(etX)=(i=1kpieti)n E(e^{tX}) = \left(\sum_{i=1}^k p_i e^{t_i}\right)^n

See Also

stats::Multinomial

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)


[Package distributional version 0.4.0 Index]