Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


distributions3 (version 0.2.1)

Multinomial: Create a 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 Bernoulli() distribution to include more than two categories, resulting in a Categorical() distribution. We then extend repeat the Categorical experiment several (n) times.

Usage

Multinomial(size, p)

Value

A Multinomial object.

Arguments

size

The number of trials. Must be an integer greater than or equal to one. When size = 1L, the Multinomial distribution reduces to the categorical distribution (also called the discrete uniform). Often called n in textbooks.

p

A vector of success probabilities for each trial. p can take on any positive value, and the vector is normalized internally.

Details

We recommend reading this documentation on https://alexpghayes.github.io/distributions3/, where the math will render with additional detail and much greater clarity.

In the following, let X=(X1,...,Xk) be a Multinomial random variable with success probability p = p. Note that p is vector with k elements that sum to one. Assume that we repeat the Categorical experiment size = n times.

Support: Each Xi is in 0,1,2,...,n.

Mean: The mean of Xi is npi.

Variance: The variance of Xi is npi(1pi). For ij, the covariance of Xi and Xj is npipj.

Probability mass function (p.m.f):

P(X1=x1,...,Xk=xk)=n!x1!x2!...xk!p1x1p2x2...pkxk

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

See Also

Other discrete distributions: Bernoulli(), Binomial(), Categorical(), Geometric(), HurdleNegativeBinomial(), HurdlePoisson(), HyperGeometric(), NegativeBinomial(), Poisson(), ZINegativeBinomial(), ZIPoisson(), ZTNegativeBinomial(), ZTPoisson()

Examples

Run this code

set.seed(27)

X <- Multinomial(size = 5, p = c(0.3, 0.4, 0.2, 0.1))
X

random(X, 10)

# pdf(X, 2)
# log_pdf(X, 2)

Run the code above in your browser using DataLab