Skip to content

MultinomialDistribution ​

nn draws over kk categories with probabilities p1,…,pkp_1,\ldots,p_k (summing to 1); a count vector on the nn-simplex.

MultinomialDistribution(n, {p1, ..., pk})n independent draws, each landing in category i with probability pi.
Typed signatures
TypePackageApplies
(real<0..>, list<real>) -> distributionstatisticsalways

Domain: Statistics

Details
  • PDF(x)=(nx1,…,xk)∏ipixiPDF(x) = \binom{n}{x_1,\ldots,x_k} \prod_i p_i^{x_i} when ∑ixi=n\sum_i x_i = n, 00 otherwise — the multinomial coefficient is compute-engine's own native Multinomial(x1,...,xk), which already computes n!/(x1!⋯xk!)n!/(x_1!\cdots x_k!) for n=∑xin = \sum x_i; the guard is what checks that sum against the DISTRIBUTION's own nn.
  • Meani=n piMean_i = n\,p_i; Variancei=n pi(1−pi)Variance_i = n\,p_i(1-p_i) — both length-kk lists (Wolfram's own Variance convention: componentwise, not the full covariance matrix).
  • Covariance (compute-engine native over two collections) is widened to also accept a single MultinomialDistribution, answering the full k×kk \times k covariance matrix: Cov(Xi,Xj)=−n pipjCov(X_i,X_j) = -n\,p_i p_j (i≠ji \ne j), Var(Xi)=n pi(1−pi)Var(X_i) = n\,p_i(1-p_i) on the diagonal.
  • RandomVariate draws via sequential conditional binomials (category ii gets Binomial(remaining n,pi/remaining p)Binomial(\text{remaining } n, p_i / \text{remaining } p) successes, the last category takes the exact remainder), seeded through the same SeedRandom stream every other distribution in this package uses.

Examples

Basic #

4!/(2!1!1!)⋅(1/2)2(1/3)1(1/6)1=12/724!/(2!1!1!) \cdot (1/2)^2(1/3)^1(1/6)^1 = 12/72

live ↗
InPDF⁡(MultinomialDistribution(4,[12,13,16]),[2,1,1])\operatorname{PDF}(\mathrm{MultinomialDistribution}(4, \bigl\lbrack\frac{1}{2}, \frac{1}{3}, \frac{1}{6}\bigr\rbrack), \bigl\lbrack2, 1, 1\bigr\rbrack)Out16\frac{1}{6}

the count vector sums to 2, not the distribution's own n = 4.

live ↗
InPDF⁡(MultinomialDistribution(4,[12,12]),[1,1])\operatorname{PDF}(\mathrm{MultinomialDistribution}(4, \bigl\lbrack\frac{1}{2}, \frac{1}{2}\bigr\rbrack), \bigl\lbrack1, 1\bigr\rbrack)Out00
live ↗
Inmean(MultinomialDistribution(10,[15,45]))\mathrm{mean}(\mathrm{MultinomialDistribution}(10, \bigl\lbrack\frac{1}{5}, \frac{4}{5}\bigr\rbrack))Out[2,8]\bigl\lbrack2, 8\bigr\rbrack
live ↗
InVariance(MultinomialDistribution(10,[15,45]))\mathrm{Variance}(\mathrm{MultinomialDistribution}(10, \bigl\lbrack\frac{1}{5}, \frac{4}{5}\bigr\rbrack))Out[85,85]\bigl\lbrack\frac{8}{5}, \frac{8}{5}\bigr\rbrack
live ↗
InCovariance⁡(MultinomialDistribution(10,[15,45]))\operatorname{Covariance}(\mathrm{MultinomialDistribution}(10, \bigl\lbrack\frac{1}{5}, \frac{4}{5}\bigr\rbrack))Out[[85,−85],[−85,85]]\bigl\lbrack\bigl\lbrack\frac{8}{5}, -\frac{8}{5}\bigr\rbrack, \bigl\lbrack-\frac{8}{5}, \frac{8}{5}\bigr\rbrack\bigr\rbrack
About
Examples5

See also: MultinormalDistribution, BinomialDistribution, Covariance, RandomVariate