# Producing random numbers with a multinomial distribution: randmultinomial

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

The randmultinomial command finds random numbers chosen according to a multinomial distribution (see Section 8.4.5).

- randmultinomial takes one mandatory and one optional argument:
  - P, a list P=[p0,…,pn−1] of n probabilities which add to 1 (representing the probability that one of several mutually exclusive events occurs).
  - Optionally, K, a list of length n.
- randmultinomial(L) returns an index chosen randomly according to the corresponding multinomial distribution.
- randmultinomial(L,K) returns an element of K whose index is chosen randomly.

#### Examples.

- Input:
  randmultinomial([1/2, 1/3, 1/6])
  Output (for example):

  1

- Input:
  randmultinomial([1/2, 1/3, 1/6],["R","V","B"])
  Output (for example):

  "R"