### 20.4.5 Multinomial distribution

If X follows a multinomial probability distribution with P= [p0,p1,…,pj] (where p0+⋯+pj=1), then for K=[k0,…,kj] with k0+⋯+kj=n, the probability that X=K is given by

n!
k0!k1!⋯kj!

p0k0p1k1…pjkj. (3)

The multinomial command computes the density function for the multinomial distribution.

- multinomial takes three arguments:
  - n, an integer.
  - P=[p0,p1,…,pj], a probability vector (i.e., pk≥ 0 for all k and p0+⋯+pj=1).
  - K=[k0,…,kj], a list of integers with k0 + …+kj=n.
- multinomial(n,P,K) returns the probability that X=K, given in (3).

You will get an error if k0+⋯+kj is not equal to n, although you won’t get one if p0+⋯+pj is not equal to 1.

#### Example

Suppose you make 10 choices, where each choice is one of three items; the first has a 0.2 probability of being chosen, the second a 0.3 probability and the third a 0.5 probability. The probability that you end up with 3 of the first item, 2 of the second and 5 of the third will be:

multinomial(10,[0.2,0.3,0.5],[3,2,5])

0.0567 |  |  |  |  |  |  |  |  |  |