Waiting-Time Counts and Their Conventions
A geometric random variable records how long a sequence of independent trials takes to produce a success. A negative binomial variable extends the same idea to a fixed number of successes. These models are simple, but their notation is a frequent source of errors: “waiting time” may count failures only, or it may count the trial on which success occurs. Their MGFs differ by a factor that depends on this choice.
Throughout, each trial has two possible outcomes, success or failure. The probability of success is \(p\), the probability of failure is \(q=1-p\), and outcomes on different trials are independent. Assume \(0<p<1\). These assumptions ensure that the specified success eventually occurs with probability one and that the waiting-time variables are finite.
For a fixed positive integer \(r\), let \(K\) count the failures before the \(r\)th success. Its support is \(0,1,2,\ldots\), and the negative binomial probability mass function is \(P(K=k)=\binom{k+r-1}{r-1}p^r q^k\). The coefficient counts the ways to arrange the \(k\) failures among the first \(k+r-1\) trials, after which the final trial must be a success. The total number of trials through the \(r\)th success is \(N=K+r\), with support \(r,r+1,r+2,\ldots\).
In this tutorial, “geometric” means failures before success, and “negative binomial” means failures before the \(r\)th success, unless total trials are explicitly named. This convention makes both counts start at zero and makes the geometric distribution the \(r=1\) case of the negative binomial distribution.
Deriving the Geometric MGF
An MGF is \(M_X(t)=E[e^{tX}]\), for those real values of \(t\) for which the expectation is finite. For \(G\), the PMF gives a weighted sum over its possible failure counts:
This is a geometric series. It sums to \(1/(1-qe^t)\) exactly when \(qe^t<1\). Since \(q>0\), this condition is \(t<-\ln q\). The sum does not exist as a finite value at or above the boundary: at equality its terms do not approach zero, and above it the terms grow.
For the total trial count \(T=G+1\), multiplying \(e^{tG}\) by \(e^t\) gives the corresponding MGF. This shift changes the value of the MGF but not its finite domain.
Worked Example: Geometric Failures and the MGF Domain
Hypothetical setting. A quality-control device performs independent diagnostic trials, each detecting a fault with probability \(p=0.4\). Let \(G\) be the number of unsuccessful trials before the first detection. Thus \(q=0.6\), the support is \(0,1,2,\ldots\), and \(P(G=k)=0.6^k(0.4)\). There is no interest rate or mortality assumption in this trial-count model.
Method: sum the PMF as a geometric series. Substituting the PMF into the definition of the MGF gives \(M_G(t)=0.4\sum_{k=0}^{\infty}(0.6e^t)^k\). The series is finite when \(0.6e^t<1\), or \(t<-\ln(0.6)\), approximately \(t<0.5108\). Therefore \(M_G(t)=0.4/(1-0.6e^t)\) on that interval.
Evaluate it at \(t=\ln(1.25)\). Since \(e^t=1.25\), \(0.6e^t=0.75\), so \(M_G(t)=0.4/(1-0.75)=0.4/0.25=1.6\). The chosen value is within the domain because \(\ln(1.25)\approx0.2231<0.5108\).
As a moment check, differentiating the MGF gives \(M'_G(t)=pq e^t/(1-qe^t)^2\). Thus \(E[G]=M'_G(0)=0.4(0.6)/(0.4)^2=1.5\). Differentiating once more, or using the second derivative at zero and subtracting the squared mean, gives \(\operatorname{Var}(G)=q/p^2=0.6/0.16=3.75\).
Check. The MGF at zero is \(0.4/(1-0.6)=1\), as every MGF must be. A common mistake is to include the successful trial while using the failures-only formula; that would incorrectly report \(M_T(t)\) instead of \(M_G(t)\).
Deriving the Negative Binomial MGF
The failures-before-\(r\)th-success PMF leads to \(M_K(t)=p^r\sum_{k=0}^{\infty}\binom{k+r-1}{r-1}(qe^t)^k\). To sum this series, use the identity \(\sum_{k=0}^{\infty}\binom{k+r-1}{r-1}x^k=(1-x)^{-r}\) for \(|x|<1\). One way to see why the identity holds is to multiply \(r\) copies of the geometric series \(\sum_{j=0}^{\infty}x^j=(1-x)^{-1}\). The coefficient of \(x^k\) in the product counts the nonnegative integer \(r\)-tuples whose entries sum to \(k\). There are \(\binom{k+r-1}{r-1}\) such tuples, which gives the stated coefficient and the identity.
Here \(x=qe^t\) is positive, so the condition \(|x|<1\) reduces to \(qe^t<1\), or \(t<-\ln q\). This is also the exact finite domain: at the boundary the summands do not tend to zero, and for larger \(t\) they do not form a convergent series.
The moments also follow directly by differentiating. For \(K\), the logarithmic derivative is \(\dfrac{d}{dt}\ln M_K(t)=\dfrac{rq e^t}{1-qe^t}\). Evaluating at zero gives \(E[K]=rq/p\). The second derivative of \(\ln M_K(t)\) at zero is \(rq/p^2\), which equals the variance. Adding the constant \(r\) to obtain \(N\) increases the mean by \(r\) and leaves the variance unchanged. Thus \(E[N]=r/p\) and \(\operatorname{Var}(N)=rq/p^2\).
Worked Example: Failures Before the Third Success
Hypothetical setting. A laboratory repeats an independent test that returns a positive result with probability \(p=0.5\). Let \(K\) count the negative results before the third positive result, so \(r=3\), \(q=0.5\), and the support is \(0,1,2,\ldots\). There is no interest rate or mortality assumption. The test results follow the negative binomial model with the stated parameters.
Method: apply the negative binomial series. The MGF of the failures count is \(M_K(t)=[0.5/(1-0.5e^t)]^3\). Its domain is \(0.5e^t<1\), or \(t<\ln 2\), approximately \(0.6931\). At \(t=\ln(1.5)\), \(e^t=1.5\) and \(0.5e^t=0.75\), so \(M_K(t)=[0.5/(1-0.75)]^3=(0.5/0.25)^3=2^3=8\).
The mean and variance of \(K\) are \(E[K]=rq/p=3(0.5)/0.5=3\) and \(\operatorname{Var}(K)=rq/p^2=3(0.5)/(0.5)^2=6\). If instead \(N\) counts all trials through the third positive result, then \(N=K+3\). Its MGF at the same \(t\) is \(M_N(t)=e^{3t}M_K(t)=(1.5)^3(8)=3.375(8)=27\), and its mean is \(E[N]=3+3=6\); its variance remains \(6\).
Check. Both MGFs equal \(1\) at \(t=0\). The common mistake is to use the failures-count MGF for \(N\), despite \(N\) including the three successful trials. The factor \(e^{3t}\) accounts for that fixed difference.
Using the MGF Without Losing the Convention
The following comparison keeps the two choices of support visible. In each row, \(p\) is the success probability, \(q=1-p\), and the trials are independent.
| Variable | What it counts | Support | MGF and finite domain |
|---|---|---|---|
| \(G\) | Failures before the first success | \(0,1,2,\ldots\) | \(\dfrac{p}{1-qe^t}\), \(t<-\ln q\) |
| \(T=G+1\) | Trials through the first success | \(1,2,3,\ldots\) | \(\dfrac{pe^t}{1-qe^t}\), \(t<-\ln q\) |
| \(K\) | Failures before the \(r\)th success | \(0,1,2,\ldots\) | \(\left(\dfrac{p}{1-qe^t}\right)^r\), \(t<-\ln q\) |
| \(N=K+r\) | Trials through the \(r\)th success | \(r,r+1,r+2,\ldots\) | \(e^{rt}\left(\dfrac{p}{1-qe^t}\right)^r\), \(t<-\ln q\) |
A useful exam procedure is to identify what the variable counts before writing any formula. Next, record the support and the parameters \(p\), \(q\), and, when relevant, \(r\). Then write the MGF and its domain. Checking \(M(0)=1\) catches many algebra errors, but it does not catch a mistaken support convention: both the failures count and total-trials count have MGF equal to one at zero.
The stated formulas assume \(0<p<1\). If \(p=1\), success occurs on the first trial with certainty: \(G=K=0\), \(T=1\), and \(N=r\). These are constant random variables, so their MGFs are finite for every real \(t\). If \(p=0\), the required success never occurs, and the waiting time is not a finite-valued geometric or negative binomial variable under these definitions.
Worked Example: Total Trials Through the Second Success
Hypothetical setting. A device passes an independent inspection with probability \(p=0.25\) on each attempt. Let \(N\) count the attempts through the second pass. Here \(r=2\), \(q=0.75\), and \(N\) has support \(2,3,4,\ldots\). There is no interest rate or mortality assumption; the model is a negative binomial trial-count model.
Method: shift the failures count by \(r\). Since \(N=K+2\), its MGF is \(M_N(t)=e^{2t}[0.25/(1-0.75e^t)]^2\), finite when \(0.75e^t<1\), or \(t<\ln(4/3)\approx0.2877\).
Take \(t=\ln(1.2)\). Then \(e^t=1.2\) and \(0.75e^t=0.9\), so the failures-count MGF is \([0.25/(1-0.9)]^2=(0.25/0.1)^2=2.5^2=6.25\). The shift factor is \(e^{2t}=(1.2)^2=1.44\). Therefore \(M_N(t)=1.44(6.25)=9\). The chosen \(t\) is allowed because \(\ln(1.2)\approx0.1823<0.2877\).
As checks, \(M_N(0)=1\), \(E[N]=r/p=2/0.25=8\), and \(\operatorname{Var}(N)=rq/p^2=2(0.75)/(0.25)^2=1.5/0.0625=24\). At the boundary \(t=\ln(4/3)\), the denominator \(1-0.75e^t\) is zero, so the MGF is not finite. The common mistake is to report \(6.25\) as the MGF of \(N\); that is the value for \(K\), which omits the two successful trials.
Common Mistakes and Exam Traps
- Switching supports without adjusting the MGF. A failures count starts at zero; a trial count includes the final success or successes. For a fixed shift \(c\), the MGF is multiplied by \(e^{ct}\).
- Using \(r\) for the success probability. In this tutorial \(p\) is the probability of success on one trial, while \(r\) is the required number of successes.
- Giving the wrong domain. The condition is \(qe^t<1\), not merely that the denominator is nonzero. At \(t=-\ln q\) the defining series diverges.
- Using a formula without its model assumptions. These formulas require independent trials with the same success probability. If probabilities change from trial to trial or outcomes are dependent, the stated geometric and negative binomial PMFs do not apply.
- Forgetting a basic check. Substitution of \(t=0\) must give \(M(0)=1\), because \(E[e^{0X}]=1\).
Check Your Understanding
For each problem, identify the counting convention before using an MGF.
- Independent trials have success probability \(p=0.2\). Let \(G\) count failures before the first success. Give its support, MGF, and finite domain. (Answer: support \(0,1,2,\ldots\); \(M_G(t)=0.2/(1-0.8e^t)\) for \(t<-\ln(0.8)\).)
- A sensor returns a usable reading with probability \(p=0.4\) independently on each trial. Let \(T\) be the number of trials through the first usable reading. Give \(M_T(t)\), its domain, and \(E[T]\). (Answer: \(M_T(t)=0.4e^t/(1-0.6e^t)\) for \(t<-\ln(0.6)\); \(E[T]=2.5\).)
- For a negative binomial variable \(K\) counting failures before the fourth success, let \(p=0.6\). Give its MGF and \(E[K]\). (Answer: \(M_K(t)=[0.6/(1-0.4e^t)]^4\) for \(t<-\ln(0.4)\); \(E[K]=4(0.4)/0.6=8/3\).)
- Independent trials succeed with probability \(p=0.3\). Let \(N\) count trials through the second success. Evaluate its MGF at \(t=\ln(1.1)\), rounding to four decimals, and state whether this \(t\) is in the finite domain. (Answer: \(M_N(t)=1.21(30/23)^2=1089/529\approx2.0586\); yes, since \(\ln(1.1)<\ln(10/7)\).)
- Let \(K\) count failures before the third success when \(p=0.25\). What happens to the MGF at \(t=\ln(4/3)\), the boundary of its finite domain? (Answer: It is infinite; \(qe^t=0.75(4/3)=1\), so the defining series does not converge.)