Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Multinomial Distribution

Multinomial distribution is an extension of the binomial distribution.

It describes outcomes in scenarios with multiple possible categories, unlike the binomial distribution, which only considers two outcomes (e.g., blood types in a population or outcomes from rolling dice).

It has three parameters:

  • n: the number of possible outcomes (e.g., 6 for a dice roll).
  • pvals: a list of probabilities for each outcome (e.g., [1/6,1/6,1/6,1/6,1/6,1/6][1/6, 1/6, 1/6, 1/6, 1/6, 1/6] for a dice roll).
  • size: the shape of the returned array.

Example

Draw out a sample for dice roll:

from numpy import random

x = random.multinomial(n=6, pvals=[1/61/61/61/61/61/6])

print(x)
Note: Multinomial samples will not yield a single value; instead, they will generate one value for each probability value (pval).