Tutorials › VEE Mathematical Statistics › MGFs of Binomial Random Variables

VEE Mathematical Statistics · Moment Generating Functions · Tutorial 227 of 880

MGFs of Binomial Random Variables

Learn to construct a binomial MGF and use its derivatives to find moments without confusing the number of trials with the probability of success.

Intermediate 9 min read

What You'll Learn

  • State the assumptions that make a count binomial.
  • Derive the binomial MGF from the probability mass function.
  • Identify the trial count and success probability in an MGF.
  • Differentiate the MGF to obtain the mean and second moment.
  • Derive the binomial variance and check it against the standard formula.
  • Recognize errors caused by interchanging the binomial parameters.

Why the Binomial MGF Is Useful

A binomial random variable counts successes across a fixed number of trials. Its probability mass function is familiar, but the moment generating function (MGF) provides a compact route to moments: once the MGF is known, derivatives at zero give the mean and higher raw moments. The key is to keep the model parameters distinct. The number of trials is an integer \(n\); the success probability on each trial is \(p\).

This tutorial derives the MGF from the binomial probability mass function and uses its first two derivatives to recover the mean and variance. The central exam skill is not just memorizing a formula: it is recognizing which quantity is \(n\), which is \(p\), and what the derivative calculations actually produce.

Definition: A random variable \(X\) has a binomial distribution with parameters \(n\) and \(p\), written \(X\sim\operatorname{Bin}(n,p)\), if it counts successes in \(n\) independent trials, each with the same probability \(p\) of success. Here \(n\) is a nonnegative integer and \(0\leq p\leq 1\). For \(k=0,1,\ldots,n\), $$ P(X=k)=\binom{n}{k}p^k(1-p)^{n-k}. $$

The binomial model requires a fixed number of trials, two outcomes for each trial (success or failure), independence, and a common success probability. If the probability changes from trial to trial, or the trials are dependent, this binomial formula generally does not apply. Write \(q=1-p\) when it is useful to distinguish the failure probability from the success probability.

Deriving the Binomial MGF

The MGF of \(X\) is \(M_X(t)=E[e^{tX}]\), for values of \(t\) where the expectation is finite. For a binomial variable, \(X\) can take only the values \(0,1,\ldots,n\), so the expectation is a finite sum and is finite for every real \(t\).

1
Write the expectation using the probability mass function.
Multiply \(e^{tk}\) by the probability that \(X=k\), and sum over every possible count \(k\).
2
Combine the factors raised to \(k\).
The terms \(e^{tk}p^k\) combine as \((pe^t)^k\), while the failure-probability term is \(q^{n-k}\).
3
Apply the binomial theorem.
The finite sum is the expansion of \((q+pe^t)^n\).
$$ \begin{aligned} M_X(t) &=E[e^{tX}]\\ &=\sum_{k=0}^{n} e^{tk}\binom{n}{k}p^kq^{n-k}\\ &=\sum_{k=0}^{n}\binom{n}{k}(pe^t)^kq^{n-k}\\ &=(q+pe^t)^n\\ &=(1-p+pe^t)^n. \end{aligned} $$
Theorem: If \(X\sim\operatorname{Bin}(n,p)\), then its MGF is $$ M_X(t)=(1-p+pe^t)^n,\qquad -\infty<t<\infty. $$ The exponent \(n\) is the number of trials. The coefficient \(p\) of \(e^t\) is the success probability, and \(1-p\) is the failure probability.

The formula also has a useful consistency check: \(M_X(0)=1\), because substituting \(t=0\) gives \((1-p+p)^n=1\). This is required of any MGF, since \(E[e^{0X}]=E[1]=1\). If a proposed expression does not equal one at zero, it cannot be the MGF.

Recovering the Mean and Variance

For an MGF that is differentiable around zero, \(M_X'(0)=E[X]\) and \(M_X''(0)=E[X^2]\). The second derivative gives the second raw moment, not the variance itself. The variance is \(E[X^2]-(E[X])^2\).

Differentiate \(M_X(t)=(q+pe^t)^n\) using the chain rule. The first derivative is

$$ M_X'(t)=np e^t(q+pe^t)^{n-1}. $$

Setting \(t=0\), so that \(e^0=1\) and \(q+p=1\), gives \(M_X'(0)=np\). Differentiate once more using the product rule:

$$ \begin{aligned} M_X''(t) &=np e^t(q+pe^t)^{n-1} +n(n-1)p^2e^{2t}(q+pe^t)^{n-2},\\ M_X''(0) &=np+n(n-1)p^2. \end{aligned} $$

Thus the second raw moment is \(np+n(n-1)p^2\). Subtract the square of the mean to obtain the variance. This algebra also explains why the variance involves \(p(1-p)\): the \(n^2p^2\) contribution in the squared mean cancels most of the \(p^2\) contribution in the second moment.

$$ \begin{aligned} \operatorname{Var}(X) &=M_X''(0)-\big(M_X'(0)\big)^2\\ &=np+n(n-1)p^2-n^2p^2\\ &=np-np^2\\ &=np(1-p). \end{aligned} $$
Key result: For \(X\sim\operatorname{Bin}(n,p)\), $$ E[X]=np,\qquad E[X^2]=np+n(n-1)p^2,\qquad \operatorname{Var}(X)=np(1-p). $$ These formulas include the endpoint cases \(p=0\) and \(p=1\), where the count is constant and the variance is zero.

Worked Examples

Worked Example: Counting Incorrect Labels

A hypothetical inspection checks 8 independently selected labels. Assume each label has probability \(0.25\) of being incorrect, with the same probability for every label. Let \(X\) be the number of incorrect labels. Find the MGF, mean, second raw moment, and variance.

Model and method. The fixed number of trials is \(n=8\), and the success probability—here, an incorrect label—is \(p=0.25\). The trials are assumed independent, so \(X\sim\operatorname{Bin}(8,0.25)\). Set \(q=1-p=0.75\) and use the binomial MGF and its derivatives.

The MGF is $$ M_X(t)=(0.75+0.25e^t)^8. $$

The mean is \(np=8(0.25)=2\). The second raw moment is $$ E[X^2]=np+n(n-1)p^2 =8(0.25)+8(7)(0.25)^2 =2+56(0.0625) =2+3.5 =5.5. $$

Therefore, $$ \operatorname{Var}(X)=E[X^2]-(E[X])^2=5.5-2^2=1.5. $$ The direct formula gives the same check: \(npq=8(0.25)(0.75)=1.5\).

Common mistake avoided: \(8\) is the number of trials, not the success probability. Using \(p=8\) would violate \(0\leq p\leq1\) and would not describe a binomial model. The two calculations of the variance agree, as required.

Worked Example: Detection Events in Repeated Tests

A hypothetical monitoring system runs 10 independent tests. Each test detects the event of interest with probability \(0.4\). Let \(X\) count detections. Find the MGF, \(E[X]\), \(E[X^2]\), and \(\operatorname{Var}(X)\).

Model and method. There are \(n=10\) tests, each with success probability \(p=0.4\) and failure probability \(q=0.6\). Under the stated independence and common-probability assumptions, \(X\sim\operatorname{Bin}(10,0.4)\).

The MGF is $$ M_X(t)=(0.6+0.4e^t)^{10}. $$

The mean is $$ E[X]=np=10(0.4)=4. $$ The second raw moment is $$ \begin{aligned} E[X^2] &=np+n(n-1)p^2\\ &=10(0.4)+10(9)(0.4)^2\\ &=4+90(0.16)\\ &=4+14.4\\ &=18.4. \end{aligned} $$

Then $$ \operatorname{Var}(X)=18.4-4^2=18.4-16=2.4. $$ As a separate check, \(npq=10(0.4)(0.6)=2.4\).

Common mistake avoided: The second derivative at zero is \(18.4\), not \(2.4\). It gives \(E[X^2]\); obtaining the variance requires subtracting \((E[X])^2=16\). The direct variance check confirms the result.

Worked Example: Reading Parameters From an MGF

A system reports the MGF $$ M_X(t)=(0.7+0.3e^t)^{12}. $$ Assume it is the MGF of a binomial count. Identify the parameters, then find the mean, variance, and second raw moment.

Model and method. Compare the expression with the binomial form \((1-p+pe^t)^n\). The exponent is the trial count, so \(n=12\). The coefficient of \(e^t\) is \(p\), so \(p=0.3\); the remaining coefficient \(0.7\) is \(1-p\). Thus \(X\sim\operatorname{Bin}(12,0.3)\).

The mean is $$ E[X]=np=12(0.3)=3.6. $$ The variance is $$ \operatorname{Var}(X)=np(1-p)=12(0.3)(0.7)=3.6(0.7)=2.52. $$

Finally, \(E[X^2]=\operatorname{Var}(X)+(E[X])^2\), so $$ E[X^2]=2.52+(3.6)^2=2.52+12.96=15.48. $$ The derivative formula gives the same result: $$ np+n(n-1)p^2=3.6+12(11)(0.09)=3.6+11.88=15.48. $$

Common mistake avoided: The exponent \(12\) is not the success probability. In the standard form, the exponent identifies \(n\), while the coefficient of \(e^t\) identifies \(p\). Both ways of computing the second raw moment agree.

Common Exam Traps and Model Checks

A binomial MGF is compact, which makes it easy to copy the form while misreading its parameters or its derivatives. Check the model and each calculation in context:

  • Swapping \(n\) and \(p\). \(n\) counts trials and must be a nonnegative integer. \(p\) is a probability between zero and one. The binomial MGF raises the one-trial expression \(1-p+pe^t\) to the power \(n\).
  • Using the wrong success definition. Success can mean any outcome of interest, such as an event being detected. Define it before assigning \(p\). If success is redefined as failure, the success probability changes to \(1-p\).
  • Calling \(M_X''(0)\) the variance. It is \(E[X^2]\). Always subtract \((M_X'(0))^2\) to obtain the variance.
  • Ignoring the model assumptions. A fixed number of independent trials with the same success probability is required. A count from dependent trials or trials with unequal probabilities need not have this binomial MGF.
  • Forgetting a basic MGF check. Substitution of \(t=0\) must yield \(M_X(0)=1\). Also, the mean and variance should be nonnegative and consistent with \(np\) and \(np(1-p)\).

The binomial MGF is useful because it packages the distribution into one expression from which moments follow by differentiation. For this model, those results are also easy to verify against the direct formulas \(E[X]=np\) and \(\operatorname{Var}(X)=np(1-p)\). The ability to move between the probability mass function, MGF, and moments is aligned with the SOA VEE Mathematical Statistics syllabus.

Check Your Understanding

For each problem, state or use the binomial parameters carefully. Answers are provided at the end of each question.

  1. A hypothetical review samples 14 independent records, each having probability \(0.1\) of requiring correction. Let \(X\) be the number requiring correction. Give the MGF, mean, and variance. (Answer: \(M_X(t)=(0.9+0.1e^t)^{14}\), \(E[X]=1.4\), \(\operatorname{Var}(X)=1.26\).)
  2. Let \(X\sim\operatorname{Bin}(6,0.5)\). Find \(E[X]\), \(E[X^2]\), and \(\operatorname{Var}(X)\). (Answer: \(E[X]=3\), \(E[X^2]=10.5\), \(\operatorname{Var}(X)=1.5\).)
  3. A binomial count has MGF \(M_X(t)=(0.65+0.35e^t)^8\). Identify \(n\) and \(p\), then find the mean and variance. (Answer: \(n=8\), \(p=0.35\), \(E[X]=2.8\), \(\operatorname{Var}(X)=1.82\).)
  4. A hypothetical screening process performs 20 independent screenings, each positive with probability \(0.05\). Find the MGF, mean, and variance of the number of positive results. (Answer: \(M_X(t)=(0.95+0.05e^t)^{20}\), \(E[X]=1\), \(\operatorname{Var}(X)=0.95\).)
  5. Suppose \(X\sim\operatorname{Bin}(30,0.1)\). Find its MGF, mean, variance, and probability of zero successes, rounding the probability to four decimal places. (Answer: \(M_X(t)=(0.9+0.1e^t)^{30}\), \(E[X]=3\), \(\operatorname{Var}(X)=2.7\), \(P(X=0)=0.9^{30}\approx0.0424\).)
Clinical Biostats