Why the Bernoulli MGF Is Useful
A Bernoulli random variable records the outcome of one trial with two possible values, usually coded as 1 for success and 0 for failure. This simple model appears whenever an event either occurs or does not occur: for example, whether a hypothetical policyholder files a claim during a specified period, or whether a quality inspection detects a defect. The moment generating function (MGF) packages the probabilities of those outcomes into a function whose derivatives reveal moments.
The focus here is a single Bernoulli variable. We will derive its MGF from its probability mass function (PMF), then calculate the mean and variance from its derivatives. The key is to keep the model’s coding clear: the mean equals the probability of the outcome coded 1 because the other outcome contributes zero.
For a discrete random variable, its MGF is \(M_X(t)=E[e^{tX}]\) for values of \(t\) for which that expectation is finite. Since a Bernoulli variable has only two possible values, its MGF is finite for every real \(t\). This fact makes it straightforward to differentiate at zero.
Deriving the Bernoulli MGF
Use the definition of expectation for a discrete variable: multiply each possible value of \(e^{tX}\) by the probability of the corresponding outcome, then add. The outcome \(X=0\) contributes \(e^{0}=1\), and the outcome \(X=1\) contributes \(e^t\).
The expression has two useful checks. First, substituting \(t=0\) gives \(M_X(0)=(1-p)+p=1\), as every MGF must. Second, if \(p=0\), the variable is always 0 and \(M_X(t)=1\); if \(p=1\), it is always 1 and \(M_X(t)=e^t\). Both are the expected MGFs of constant variables.
Recovering the Mean and Variance
For a random variable whose MGF is finite in a neighborhood of zero, the derivatives at zero give raw moments: \(M_X'(0)=E[X]\) and \(M_X''(0)=E[X^2]\). Applying those standard MGF relationships to the Bernoulli expression gives
The second derivative gives the second raw moment, not the variance:
The variance is obtained by subtracting the square of the mean from the second raw moment. Therefore,
This result also has a direct PMF check. Because \(X^2=X\) for both possible values, \(E[X^2]=E[X]=p\). Hence the same variance calculation follows from the two-point distribution without differentiating. The MGF method is useful because it follows a consistent procedure that can be applied to other distributions as well.
Confirm that the variable is coded 1 for success and 0 for failure, with success probability \(p\).
Use \(M_X(t)=1-p+pe^t\), then calculate \(M_X'(t)\) and \(M_X''(t)\).
Use \(M_X'(0)=E[X]\), \(M_X''(0)=E[X^2]\), and \(\operatorname{Var}(X)=M_X''(0)-\{M_X'(0)\}^2\).
Worked Applications
Worked Example: A Hypothetical Claim Indicator
Model and parameters. For one hypothetical insurance policy over a specified one-year period, let \(X=1\) if a claim is filed and \(X=0\) otherwise. Assume the claim indicator follows \(X\sim\operatorname{Bernoulli}(0.20)\). Find its MGF, mean, and variance. No interest or mortality assumptions are needed for this one-period indicator model.
Method. Substitute \(p=0.20\) into the Bernoulli MGF, differentiate, and evaluate at zero.
MGF. The probability of no claim is \(1-0.20=0.80\), so
Mean. Differentiating gives \(M_X'(t)=0.20e^t\). Thus \(E[X]=M_X'(0)=0.20e^0=0.20\).
Variance. The second derivative is \(M_X''(t)=0.20e^t\), so \(E[X^2]=M_X''(0)=0.20\). Therefore,
Check and common mistake avoided. The formula \(p(1-p)\) gives \(0.20(0.80)=0.16\), matching the derivative calculation. A common error is to report \(M_X''(0)=0.20\) as the variance; it is the second raw moment. Subtracting the squared mean gives the correct variance.
Worked Example: Recovering the Model From an MGF
Model and parameters. A hypothetical single inspection is recorded as \(X=1\) if a specified defect is detected and \(X=0\) otherwise. Assume \(X\sim\operatorname{Bernoulli}(p)\), where \(p\) is not yet known. An analysis gives \(M_X(\ln 3)=1.8\). Find \(p\), the mean, and the variance.
Method. Substitute the given argument into the general Bernoulli MGF and solve for its parameter.
The model implies \(M_X(t)=1-p+pe^t\). Since \(e^{\ln 3}=3\),
Subtract 1 from both sides: \(0.8=2p\), so \(p=0.4\). The fitted model is therefore \(X\sim\operatorname{Bernoulli}(0.4)\).
Mean. \(E[X]=p=0.4\).
Variance.
Check and common mistake avoided. Substitution verifies the supplied MGF value: \(1-0.4+0.4(3)=0.6+1.2=1.8\). Do not confuse \(M_X(\ln 3)\) with the probability \(P(X=1)\): the former is a function value, and the parameter is found by solving the MGF equation.
Worked Example: Distinguishing the Second Moment From Variance
Model and parameters. In a hypothetical one-trial screening process, \(X=1\) if the screen flags a sample and \(X=0\) if it does not. Assume \(X\sim\operatorname{Bernoulli}(0.65)\). Calculate \(M_X'(0)\), \(M_X''(0)\), and \(\operatorname{Var}(X)\), and explain what each quantity represents.
Method. Differentiate the MGF and use the first two derivative-at-zero relationships.
The MGF is \(M_X(t)=0.35+0.65e^t\), because \(1-0.65=0.35\). Differentiating once gives \(M_X'(t)=0.65e^t\), hence \(M_X'(0)=0.65\). This is \(E[X]\), the mean flag indicator.
Differentiating a second time gives \(M_X''(t)=0.65e^t\), hence \(M_X''(0)=0.65\). This is \(E[X^2]\), the second raw moment. The variance is not this value; it is
Check and common mistake avoided. The shortcut gives \(p(1-p)=0.65(0.35)=0.2275\), agreeing with the derivative calculation. Reporting \(0.65\) for the variance would omit the squared-mean subtraction; \(0.65\) is the second raw moment here.
Common Exam Traps
The Bernoulli MGF is short, but several errors can arise from applying a correct formula to the wrong coding or stopping one step too soon.
- Switching the success coding. The formulas above assume success is coded 1 and failure 0. If the variable is instead coded 1 for failure, the success parameter in the formula must be the probability of failure.
- Stopping at the second derivative. \(M_X''(0)\) is \(E[X^2]\), not \(\operatorname{Var}(X)\). Always subtract \(\{M_X'(0)\}^2\).
- Dropping the failure contribution incorrectly. The term for \(X=0\) is \((1-p)e^0=1-p\), not zero. The value of \(X\) is zero, but the value of \(e^{tX}\) is one.
- Forgetting to check the parameter. A Bernoulli success probability must satisfy \(0\leq p\leq1\). A result outside this range is inconsistent with the model.
Check Your Understanding
For each question, use the stated 0–1 coding and Bernoulli model. The scenarios are hypothetical.
- A hypothetical one-period indicator is 1 for a reported event and 0 otherwise, with event probability \(0.12\). Write its MGF and find its mean and variance. (Answer: \(M_X(t)=0.88+0.12e^t\), \(E[X]=0.12\), \(\operatorname{Var}(X)=0.1056\))
- A hypothetical Bernoulli variable has \(M_X(\ln 4)=2.2\). Find \(p\), \(E[X]\), and \(\operatorname{Var}(X)\). (Answer: \(p=0.40\), \(E[X]=0.40\), \(\operatorname{Var}(X)=0.24\))
- For \(X\sim\operatorname{Bernoulli}(0.30)\), find \(M_X'(0)\), \(M_X''(0)\), and the variance. State which derivative value is the second raw moment. (Answer: \(M_X'(0)=0.30\), \(M_X''(0)=E[X^2]=0.30\), \(\operatorname{Var}(X)=0.21\))
- A hypothetical Bernoulli model has variance \(0.16\), and its success probability is known to be less than \(0.5\). Find \(p\), then write its MGF. (Answer: \(p=0.20\), \(M_X(t)=0.80+0.20e^t\))
- A hypothetical indicator has MGF \(M_X(t)=0.55+0.45e^t\). Calculate \(M_X'(0)\), \(M_X''(0)\), and \(\operatorname{Var}(X)\), then verify that \(M_X(0)=1\). (Answer: \(M_X'(0)=0.45\), \(M_X''(0)=0.45\), \(\operatorname{Var}(X)=0.2475\), \(M_X(0)=1\))