Why Use a Joint Generating Function?
A multinomial count vector records how many of \(n\) independent trials fall in each of \(k\) categories. Its joint distribution contains several kinds of information: the probability of a particular count vector, the mean and variance of each count, and the dependence between counts. A joint probability-generating function packages that information into one polynomial. Differentiating the polynomial recovers moments, while its coefficients are the probabilities themselves.
Here \(n\) is a fixed nonnegative integer, and each trial falls in exactly one of \(k\) categories. The probability of category \(j\) on any trial is \(p_j\), where \(p_j\geq 0\) and \(\sum_{j=1}^k p_j=1\). The count in category \(j\) is \(X_j\), so the count vector is \((X_1,\ldots,X_k)\) and its entries sum to \(n\).
Definition and Derivation
To derive the multinomial joint generating function, let \(C_r\) be the category of trial \(r\), for \(r=1,\ldots,n\). On that trial, the factor contributed to \(s_1^{X_1}\cdots s_k^{X_k}\) is \(s_{C_r}\): it is \(s_j\) if the trial falls in category \(j\). Multiplying these factors across trials gives \(s_1^{X_1}\cdots s_k^{X_k}=\prod_{r=1}^n s_{C_r}\). The category outcomes of the trials are independent, so the expectation of this product is the product of the single-trial expectations. For one trial, that expectation is \(\sum_{j=1}^k p_j s_j\). Therefore:
This derivation also covers \(n=0\), when the count vector is identically zero and the generating function is the constant \(1\). Because \(G\) is a finite polynomial, its partial derivatives can be taken term by term; no interchange of an infinite sum and an expectation is needed.
Worked Example: Writing a Three-Category Generating Function
Suppose \(n=3\), with category probabilities \(p_1=1/2\), \(p_2=1/3\), and \(p_3=1/6\). The probabilities sum to one, since \(1/2+1/3+1/6=1\). The joint generating function is
For instance, the coefficient of \(s_1^2s_2\) is the probability that the count vector is \((2,1,0)\). To obtain it, choose the \(s_2/3\) term from one of the three factors and the \(s_1/2\) term from the other two. There are three such choices, so
The same polynomial will also give moments. For example, the mean of \(X_1\) is \(3(1/2)=3/2\), and the covariance between \(X_1\) and \(X_3\), as derived below, is \(-3(1/2)(1/6)=-1/4\).
Derivatives Give Moments
For a probability-generating function, differentiating with respect to \(s_i\) brings down a factor of \(X_i\). The other variables then track the remaining counts. Evaluating every variable at \(1\) removes those remaining powers, because \(1^{X_j}=1\). More generally, a second derivative with respect to the same variable brings down \(X_i(X_i-1)\), while a mixed derivative with respect to two distinct variables brings down \(X_iX_j\).
Proof. Write \(q(s_1,\ldots,s_k)=\sum_{j=1}^k p_js_j\), so that \(G=q^n\). For \(n\geq 1\), differentiating once gives
At \(s_1=\cdots=s_k=1\), \(q=\sum_jp_j=1\). By the definition of \(G\), its first partial derivative there is \(E[X_i]\), giving \(E[X_i]=np_i\). For \(n=0\), both sides are zero as well.
For \(n\geq 2\), differentiating twice with respect to \(s_i\) gives \(\frac{\partial^2G}{\partial s_i^2}=n(n-1)p_i^2q^{n-2}\). At all variables equal to one, the derivative is \(E[X_i(X_i-1)]\), so this factorial moment is \(n(n-1)p_i^2\). When \(n=0\) or \(n=1\), both the second derivative and the stated factorial moment are zero, so the formula holds for all \(n\geq0\).
For distinct \(i,j\), differentiating once with respect to each variable gives, when \(n\geq2\),
At all variables equal to one this is \(E[X_iX_j]=n(n-1)p_ip_j\). For \(n=0\) or \(n=1\), the mixed derivative and the product \(X_iX_j\) are both zero, so the identity again holds.
Finally, \(X_i^2=X_i(X_i-1)+X_i\), and therefore
For \(i\ne j\), the covariance is
These formulas also apply when some \(p_i=0\), since the corresponding counts are always zero. \(\square\)
Worked Example: Recovering Variance and Covariance by Differentiation
Let \(n=8\) and \((p_1,p_2,p_3)=(0.2,0.5,0.3)\). Then \(G(s_1,s_2,s_3)=(0.2s_1+0.5s_2+0.3s_3)^8\). The first derivative with respect to \(s_1\), evaluated at \((1,1,1)\), gives
The second derivative with respect to \(s_1\) gives the second factorial moment:
Since \(X_1^2=X_1(X_1-1)+X_1\), \(E[X_1^2]=2.24+1.6=3.84\). Thus \(\operatorname{Var}(X_1)=3.84-(1.6)^2=3.84-2.56=1.28\), which is also \(8(0.2)(0.8)=1.28\).
For the covariance with \(X_2\), the mixed derivative gives \(E[X_1X_2]=8(7)(0.2)(0.5)=56(0.1)=5.6\). Also, \(E[X_2]=8(0.5)=4\), so \(\operatorname{Cov}(X_1,X_2)=5.6-(1.6)(4)=5.6-6.4=-0.8\). This agrees with \(-8(0.2)(0.5)=-0.8\).
What the Dependence Means
The negative covariance between distinct counts is a consequence of the fixed total \(X_1+\cdots+X_k=n\). If one category count increases while the total remains \(n\), there are fewer trials available for the other categories. More formally, for \(i\ne j\), the covariance is \(-np_ip_j\), which is nonpositive and is strictly negative when both category probabilities are positive.
The trials are independent of one another, but the category counts are generally not independent. Independence across trials does not imply independence among totals formed from those trials. In fact, when \(n>0\) and two category probabilities are positive, the negative covariance just derived rules out independence: independent random variables with finite variances have covariance zero.
Worked Example: Reading a Joint Probability from a Coefficient
Suppose \(n=4\) and \((p_1,p_2,p_3)=(1/4,1/4,1/2)\). The joint generating function is \(G(s_1,s_2,s_3)=(s_1/4+s_2/4+s_3/2)^4\). The probability of counts \((1,1,2)\) is the coefficient of \(s_1s_2s_3^2\).
To form this term, select one \(s_1/4\), one \(s_2/4\), and two \(s_3/2\) terms from the four factors. The number of distinct selections is \(4!/(1!1!2!)=12\). Therefore,
This is a coefficient-extraction use of the joint generating function: the exponent of each variable identifies the corresponding count, and the coefficient gives the probability of that joint count vector.
Common Pitfall
A common mistake is to treat the counts as independent because the trials themselves are independent. That reasoning confuses two different collections of random variables: the outcomes on separate trials are independent, but the category totals are linked by their fixed sum. For example, with \(n=8\), \(p_1=0.2\), and \(p_2=0.5\), independence would require \(\operatorname{Cov}(X_1,X_2)=0\). The derivative calculation instead gives \(-8(0.2)(0.5)=-0.8\), so the counts are not independent.
A related computational error is to use \(E[X_i^2]=n(n-1)p_i^2\). That derivative gives \(E[X_i(X_i-1)]\), not \(E[X_i^2]\). The correction is to add \(E[X_i]\), because \(X_i^2=X_i(X_i-1)+X_i\). This extra term is essential when calculating the variance.
Check Your Understanding
Use the definition and derivative relationships in this tutorial to answer the following.
- Write the joint probability-generating function for \(n=5\) and category probabilities \((0.4,0.6)\).
- For a multinomial count vector, what does the mixed derivative \(\frac{\partial^2G}{\partial s_i\,\partial s_j}\) at all variables equal to one represent when \(i\ne j\)?
- If \(n=10\), \(p_i=0.3\), and \(p_j=0.2\), calculate \(\operatorname{Cov}(X_i,X_j)\).
- Explain why the second derivative with respect to \(s_i\) gives \(E[X_i(X_i-1)]\), rather than \(E[X_i^2]\).
- For \(n=4\) and probabilities \((1/2,1/2)\), what coefficient in the joint generating function gives \(P(X_1=2,X_2=2)\)?