Why Generate Functions for a Two-Point Distribution?
A Bernoulli variable has only two possible outcomes, so its distribution can be written down directly. Generating functions give another way to record those probabilities: the probability-generating function uses powers of an argument to encode integer outcomes, while the moment-generating function uses exponentials. For a Bernoulli variable, both functions are simple, but their derivatives make a useful distinction between ordinary moments and factorial moments.
The main calculation is compact: the probability-generating function has one derivative that yields the mean and a second derivative that yields a factorial moment; the moment-generating function yields ordinary moments from derivatives at zero. Keeping track of which function is differentiated and where is essential.
Definitions and the Bernoulli Generating Functions
For this two-point distribution the expectations are finite sums, so both functions exist for every real \(s\) and \(t\). In particular, the convention \(s^0=1\) applies, including when \(s=0\). Evaluating each expectation by summing over the two outcomes gives the following formulas.
The functions have different input variables and different useful evaluation points. For the probability-generating function, evaluate derivatives at \(s=1\). For the moment-generating function, evaluate derivatives at \(t=0\). The values at those points are both \(1\), as expected: \(G_X(1)=E[1^X]=1\) and \(M_X(0)=E[e^0]=1\).
Worked Example: Constructing Both Functions
Suppose \(X\sim\operatorname{Bernoulli}(0.3)\). Then \(P(X=0)=0.7\) and \(P(X=1)=0.3\). Summing the two terms gives
As a check, \(G_X(1)=0.7+0.3=1\), and \(M_X(0)=0.7+0.3e^0=1\). At \(s=2\), the probability-generating function is \(G_X(2)=0.7+0.3(2)=1.3\). At \(t=\log 2\), the moment-generating function is \(M_X(\log 2)=0.7+0.3(2)=1.3\). The matching numerical values here do not make the functions interchangeable: one is evaluated at \(s=2\), the other at \(t=\log 2\), and their derivatives encode moments through different rules.
Derivatives of the Probability-Generating Function
For a nonnegative integer-valued variable, differentiating a probability-generating function brings down powers of the outcome. At \(s=1\), the first derivative gives the mean. The second derivative gives the expectation of \(X(X-1)\), not \(X^2\), because two differentiations of \(s^x\) produce \(x(x-1)s^{x-2}\).
Here the derivatives can be computed directly from the polynomial \(G_X(s)=1-p+ps\): \(G_X'(s)=p\) and \(G_X''(s)=0\). To see why these values correspond to the stated expectations, differentiate the defining finite sum \(G_X(s)=\sum_{x=0}^1P(X=x)s^x\). Because it is a finite sum, differentiation term by term is valid. The first derivative is \(\sum_{x=0}^1P(X=x)x s^{x-1}\); at \(s=1\), this is \(E[X]\). The second derivative at \(1\) is \(\sum_{x=0}^1P(X=x)x(x-1)=E[X(X-1)]\). For this Bernoulli distribution the \(x=0\) term and the \(x=1\) term in the second derivative are both zero.
Finally, \(X^2=X(X-1)+X\), so the ordinary second moment is \(E[X^2]=G_X''(1)+G_X'(1)=p\). Subtracting the square of the mean gives the variance:
This calculation is also a direct verification of the moment formulas for the Bernoulli distribution. The probability-generating function returns the mean from its first derivative at one, and its second derivative contributes the factorial moment needed to construct the ordinary second moment.
Worked Example: Recovering the Mean and Variance from the PGF
Let \(X\sim\operatorname{Bernoulli}(1/4)\). Its probability-generating function and its first two derivatives are
Evaluating at \(s=1\) gives \(E[X]=G_X'(1)=1/4\) and \(E[X(X-1)]=G_X''(1)=0\). Thus
The variance is therefore
As a check from the two possible outcomes, \(X^2=X\) for \(X=0\) and \(X=1\), so its mean must also be \(1/4\). The result agrees with the derivative calculation.
Derivatives of the Moment-Generating Function
The moment-generating function encodes ordinary moments directly. For the Bernoulli variable, differentiating \(M_X(t)=1-p+pe^t\) gives \(M_X'(t)=pe^t\) and \(M_X''(t)=pe^t\). At \(t=0\), these derivatives are both \(p\). The second derivative therefore gives \(E[X^2]\), not \(E[X(X-1)]\).
The identification follows from the defining expectation. Since \(X\) takes only the values \(0\) and \(1\), \(M_X(t)=\sum_{x=0}^1P(X=x)e^{tx}\). Differentiating this finite sum once gives \(\sum_xP(X=x)xe^{tx}\), and twice gives \(\sum_xP(X=x)x^2e^{tx}\). Setting \(t=0\) makes each exponential factor \(1\), leaving the first and second ordinary moments, respectively. The finite sum requires no interchange of a limit with an infinite series or integral.
Worked Example: Using the MGF to Find Variance
Suppose \(X\sim\operatorname{Bernoulli}(0.2)\). Its moment-generating function is
Differentiate and evaluate at zero:
It follows that
The result also equals \(p(1-p)=0.2(0.8)=0.16\). In this example the first and second raw moments are equal because \(X^2=X\) at both possible outcomes.
Why the Two Derivative Rules Differ
The probability-generating function differentiates powers \(s^x\), while the moment-generating function differentiates exponentials \(e^{tx}\). Their derivative rules explain why the PGF’s second derivative produces \(x(x-1)\), whereas the MGF’s second derivative produces \(x^2\). For a Bernoulli variable, both \(E[X]\) and \(E[X^2]\) equal \(p\), but that equality comes from the support \(\{0,1\}\); it does not mean the two derivative rules are the same.
For the PGF, the conversion from a factorial moment to an ordinary moment uses the identity \(X^2=X(X-1)+X\). The direct finite-sum calculation for this particular variable is:
For the MGF, the corresponding calculation uses \(x^2\):
Worked Example: Diagnosing a Derivative Mistake
A student writes: “For \(X\sim\operatorname{Bernoulli}(0.6)\), \(G_X''(1)=E[X^2]\). Since \(G_X(s)=0.4+0.6s\), \(G_X''(1)=0\), so \(E[X^2]=0\).” The conclusion cannot be right: \(X=1\) with probability \(0.6\), and \(X^2=1\) on that event.
The error is the derivative rule. The second derivative of \(s^x\) is \(x(x-1)s^{x-2}\), so \(G_X''(1)\) is \(E[X(X-1)]\), not \(E[X^2]\). For this distribution, the correct calculations are
Then \(\operatorname{Var}(X)=0.6-(0.6)^2=0.6-0.36=0.24\), matching \(p(1-p)=0.6(0.4)=0.24\).
Boundary Cases and Practical Use
The formulas remain valid at the boundary values of the parameter. If \(p=0\), then \(X=0\) with probability one, \(G_X(s)=1\), \(M_X(t)=1\), and both the mean and variance are zero. If \(p=1\), then \(X=1\) with probability one, \(G_X(s)=s\), \(M_X(t)=e^t\), the mean is one, and the variance is zero. The variance formula \(p(1-p)\) gives zero in both cases.
In practice, these calculations provide a concise way to check a Bernoulli distribution’s moments and to learn how generating functions encode distributions. The distinction to retain is simple: \(G_X'(1)\) gives the mean and \(G_X''(1)\) gives a factorial moment; \(M_X'(0)\) gives the mean and \(M_X''(0)\) gives the second ordinary moment. For this variable both routes lead to the same variance once the appropriate moment identity is used.
Check Your Understanding
Use the definitions and derivative rules above to answer these questions.
- For \(X\sim\operatorname{Bernoulli}(p)\), write \(G_X(s)\) and \(M_X(t)\) and state the point at which each function’s derivatives are evaluated to obtain moments.
- Why does \(G_X''(1)\) equal \(E[X(X-1)]\) rather than \(E[X^2]\)?
- If \(G_X'(1)=0.35\) and \(G_X''(1)=0\) for a Bernoulli variable, find \(E[X^2]\) and \(\operatorname{Var}(X)\).
- For a Bernoulli variable with \(p=0.8\), calculate \(M_X'(0)\), \(M_X''(0)\), and the variance.
- Verify the PGF, MGF, mean, and variance when \(p=0\), and explain why the derivative rules still apply.