({{, (RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution])[n,{(Subscript[p, 1]),(Subscript[p, 2]),…,(Subscript[p, m])}]
represents a multinomial distribution with n trials and probabilities (Subscript[p, i]).}})

OpenersNotesSection(Spacer1)Details

The probability for a vector x of non-negative integers (Subscript[x, 1]), (Subscript[x, 2]), …, (Subscript[x, m]) in a multinomial distribution is n! (∏_(i=1)^m)((Subscript[p, i]^(Subscript[x, i]))/((Subscript[x, i])!)).

The number of trials n can be any positive integer, and (Subscript[p, i]) can be any non-negative real numbers such that (∑_(i=1)^m)(Subscript[p, i])==1.

(RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution]) allows n and (Subscript[p, i]) to be dimensionless quantities. »

(RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution]) can be used with such functions as (RefLink[Mean, paclet:ref/Mean]), (RefLink[CDF, paclet:ref/CDF]), and (RefLink[RandomVariate, paclet:ref/RandomVariate]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (22)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Probability mass function:

Table[DiscretePlot3D[PDF[MultinomialDistribution[n,{0.6,0.4}],{x,y}],{y,0,n},{x,0,n},PlotLabel->Row[{"n = ",n}],ExtentSize->0.5],{n,{3,6,9,12}}]

PDF[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}],{x,y}]

PDF[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}],{x,y,z}]

Cumulative distribution function:

Table[DiscretePlot3D[CDF[MultinomialDistribution[n,{0.6,0.4}],{x,y}],{x,0,n},{y,0,n},PlotLabel->Row[{"n = ",n}],ExtentSize->Right],{n,{3,6,9,12}}]

Mean and variance:

Mean[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]

Variance[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]

Covariance:

Covariance[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]//MatrixForm

OpenersExampleSection1(Spacer1)Scope  (8)

Generate a sample of pseudorandom vectors from a multinomial distribution:

sample=RandomVariate[𝒹=MultinomialDistribution[10,{0.3,0.7}],10^4];

{Histogram3D[sample,{-0.5,10.5,1},"PDF",ColorFunction->"Rainbow"],DiscretePlot3D[PDF[𝒹,{x,y}],{x,0,10},{y,0,10},ColorFunction->"Rainbow",ExtentSize->1]}

Distribution parameters estimation:

sample=RandomVariate[MultinomialDistribution[20,{0.2,0.3,0.5}],10^3];

Estimate the distribution parameters from sample data:

e𝒟=EstimatedDistribution[sample,MultinomialDistribution[n,{p1,p2,p3}]]

Goodness-of-fit test:

PearsonChiSquareTest[sample,MultinomialDistribution[n,{p1,p2,p3}]]

Skewness:

Skewness[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]

Limit[Skewness[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]],n->∞]

Kurtosis:

Kurtosis[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]

Limit[Kurtosis[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]],n->∞]

Correlation:

Correlation[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2])}]]//FullSimplify[#,(Subscript[p, 1])>0&&(Subscript[p, 2])>0]&//MatrixForm

Hazard function:

HazardFunction[MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}],{x,y,z}]

The univariate marginals follow (RefLink[BinomialDistribution, paclet:ref/BinomialDistribution]):

𝒟=MultinomialDistribution[n,{(Subscript[p, 1]),(Subscript[p, 2]),(Subscript[p, 3])}];

MarginalDistribution[𝒟,3]

Multivariate marginals do not simplify:

MarginalDistribution[𝒟,{1,2}]

Plot the probability density function of the marginal for fixed values of parameters:

ℳ=MarginalDistribution[𝒟/.{n->10,(Subscript[p, 1])->0.2,(Subscript[p, 2])->0.3,(Subscript[p, 3])->0.5},{1,2}];

DiscretePlot3D[PDF[ℳ,{x,y}],{x,0,8},{y,0,8},ExtentSize->1/2]

Use dimensionless (RefLink[Quantity, paclet:ref/Quantity]) to define (RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution]):

MultinomialDistribution[Quantity[1,"Gross"],Quantity[{20,30,50},"Percent"]]

OpenersExampleSection2(Spacer1)Applications  (5)

There are two candidates in an election where the winner is chosen based on a simple majority. Each of n voters votes for candidate 1 with probability (Subscript[p, 1]) and for candidate 2 with probability (Subscript[p, 2]), where (Subscript[p, 1])+(Subscript[p, 2])<1, so that a voter may choose not to vote for either candidate. When n=100, (Subscript[p, 1])=(Subscript[p, 2])=0.4`, the probability of one swing vote is:

𝒟=MultinomialDistribution[100-1,{0.4,0.4,1-0.4-0.4}];

Probability[x==y,{x,y,z}\[Distributed]𝒟]

Probability that a winner won by one vote:

Probability[Abs[x-y]==1,{x,y,z}\[Distributed]𝒟]

Probability that candidate 1 wins the election:

Probability[x>y,{x,y,z}\[Distributed]𝒟]

Probable outcome of the next election:

RandomVariate[𝒟]

Average outcome of an election:

Mean[𝒟]

Distribute 5 balls among 3 containers, picking each container with equal probability. Find the probability that no container is empty:

Probability[(Subscript[x, 1])>0&&(Subscript[x, 2])>0&&(Subscript[x, 3])>0,{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3])}\[Distributed]MultinomialDistribution[5,{1/3,1/3,1/3}]]

Compute the same probability using (RefLink[SurvivalFunction, paclet:ref/SurvivalFunction]):

SurvivalFunction[MultinomialDistribution[5,{1/3,1/3,1/3}],{0,0,0}]

Distribute n balls among m containers with equal probability. Find the probability that no container is empty for different values of n and m:

ballprob[n_Integer,m_Integer]:=SurvivalFunction[MultinomialDistribution[n,ConstantArray[1/m,{m}]],ConstantArray[0,{m}]]

DiscretePlot3D[Evaluate@ballprob[n,m],{n,7},{m,2,7},ExtentSize->1/2,ViewPoint->{1,1,1}]

In calling a customer service center, one of three things may happen: the line is busy with probability 0.4, a caller gets the wrong party with probability 0.1, or a caller gets connected to an agent. Find the probability that a caller calling at 6 different times gets a busy signal 4 times and twice connects directly to an agent:

𝒟=MultinomialDistribution[6,{0.4,0.1,0.5}];

PDF[𝒟,{4,0,2}]

Find the probability that calling at 6 different times, a caller gets the wrong party at least twice:

SurvivalFunction[𝒟,{0,2,0}]

Simulate 6 calling attempts done at different times:

RandomVariate[𝒟]

In a certain city, out of all 911 calls 30% were requesting an ambulance, 15% were requesting the fire department, and the rest were police requests. Find the probability that in the next 10 emergency calls, 2 will ask for an ambulance, 1 for the fire department, and 7 for police:

𝒟=MultinomialDistribution[10,{.3,.15,.55}];

PDF[𝒟,{2,1,7}]

Simulate the request distribution for the next 100 calls:

Total@RandomVariate[𝒟,10]

Define a multivariate Pólya distribution as a parameter mixture of negative multinomial distribution:

𝒟=ParameterMixtureDistribution[NegativeMultinomialDistribution[10,{p1,p2}],{p1,p2}\[Distributed]DirichletDistribution[{1,2,3}]];

pdf=PDF[𝒟,{x,y}]

DiscretePlot3D[pdf,{x,0,10},{y,0,10},ExtentSize->1/2]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

Relationships to other distributions:

A bivariate multinomial distribution is a (RefLink[BinomialDistribution, paclet:ref/BinomialDistribution]):

PDF[MultinomialDistribution[n,{p,1-p}],{x,n-x}]

PDF[BinomialDistribution[n,p],x]

%-%%//FullSimplify

A univariate multinomial distribution is a shifted (RefLink[BernoulliDistribution, paclet:ref/BernoulliDistribution]):

PDF[MultinomialDistribution[n,{1}],{x}]//FullSimplify[#,n≥0]&

PDF[TransformedDistribution[u+n-1,u\[Distributed]BernoulliDistribution[1],Assumptions->n≥0],x]//FullSimplify

OpenersExampleSection4(Spacer1)Possible Issues  (2)

(RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution]) is not defined when n is not a positive integer:

Mean[MultinomialDistribution[-2,{(Subscript[p, 1]), (Subscript[p, 2]),(Subscript[p, 3]),(Subscript[p, 4])}]]

(RefLink[MultinomialDistribution, paclet:ref/MultinomialDistribution]) is not defined when the elements of p do not sum to 1:

Mean[MultinomialDistribution[n,{1/2,2}]]

Substitution of invalid parameters into symbolic outputs gives results that are not meaningful:

Mean[MultinomialDistribution[n,{(Subscript[p, 1]), (Subscript[p, 2]),(Subscript[p, 3])}]]/.{n->-5,(Subscript[p, 1])->1/2, (Subscript[p, 2])->2,(Subscript[p, 3])->I}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BinomialDistribution, paclet:ref/BinomialDistribution])  ▪  (RefLink[NegativeMultinomialDistribution, paclet:ref/NegativeMultinomialDistribution])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Urn Model Distributions, paclet:guide/UrnModelDistributions])}, {▪(RefLinkPlain[Parametric Statistical Distributions, paclet:guide/ParametricStatisticalDistributions])}})}})