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
you might get
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
you might get