### 7.3.4 Producing random numbers with a multinomial distribution: randmultinomial

Given a list P=[p0,...,pn−1] of n probabilities which add to 1 (representing the probability that one of several mutually exclusive events occurs), the randmultinomial command will return an index whose probability is determined by the corresponding multinomial distribution. If you enter

randmultinomial([1/2, 1/3, 1/6])

you might get

0

If K is a list of length n, then randmultinomial(P,K) will return an element of the list, whose index is chosen according to the multinomial distribution. If you enter

randmultinomial([1/2, 1/3, 1/6],["R","V","B"])

you might get

"R"