Moment Generating Functions
The moment generating function (MGF) of a random variable X is M_X(t) = E(e^(tX)). Its derivatives at t = 0 give the moments: M′(0) = E(X) and M″(0) = E(X²). Two variables with the same MGF have the same distribution, and the MGF of a sum of independent variables is the product of their MGFs.
Before this lesson: Expected Value of a Continuous Random Variable, Independent Random Variables and Maclaurin Series
Moments packed into one function
The moments of X are E(X), E(X²), E(X³) and so on. The first gives the mean, and the first two together give the variance. The MGF stores all of them in a single function of a new variable t.
Here is why it works. The Maclaurin series of e^(tX) is 1 + tX + t²X²/2! + t³X³/3! + ⋯. Take the expected value of each term, and the moments appear as the coefficients:
M_X(t) = E\left(e^{tX}\right) = 1 + E(X)\,t + \dfrac{E(X^2)}{2!}\,t^2 + \dfrac{E(X^3)}{3!}\,t^3 + \cdotsSo the slope of M_X at t = 0 is E(X), and the second derivative there is E(X²). The graph below shows this for an exponential variable.
Moment generating function formulas
For a discrete random variable with probability function p(x), and for a continuous one with density f(x):
M_X(t) = \sum_x e^{tx}\,p(x) \qquad \text{or} \qquad M_X(t) = \int_{-\infty}^{\infty} e^{tx} f(x)\,dxThe MGF exists when this sum or integral is finite for every t in some open interval around 0.
Key properties
- Moments: M_X^{(n)}(0) = E(X^n). In particular, E(X) = M_X'(0) and \operatorname{Var}(X) = M_X''(0) - [M_X'(0)]^2.
- Uniqueness: if two random variables have the same MGF on an open interval around 0, they have the same distribution.
- Linear change: M_{aX + b}(t) = e^{bt} M_X(at).
- Sums: if X and Y are independent, M_{X+Y}(t) = M_X(t)\,M_Y(t).
- Always: M_X(0) = 1, because e^0 = 1.
Common MGFs
| Distribution | MGF | Valid for |
|---|---|---|
| Bernoulli(p) | 1 - p + pe^t | all t |
| Binomial(n, p) | (1 - p + pe^t)^n | all t |
| Poisson(λ) | e^{\lambda(e^t - 1)} | all t |
| Exponential(λ) | \dfrac{\lambda}{\lambda - t} | t \lt \lambda |
| Gamma(α, λ) | \left(\dfrac{\lambda}{\lambda - t}\right)^{\alpha} | t \lt \lambda |
| Normal N(μ, σ) | e^{\mu t + \sigma^2 t^2/2} | all t |
As in earlier lessons, N(μ, σ) means mean μ and standard deviation σ.
Steps to find the distribution of a sum
- Write the MGF of each variable, using the table or the definition.
- Check that the variables are independent, then multiply the MGFs.
- Simplify the product with exponent rules.
- Match the result to an MGF in the table. By uniqueness, that is the distribution of the sum.
Moment generating function examples
Example 1: MGF from a probability table
X takes the values 0, 1 and 2 with probabilities 0.2, 0.5 and 0.3. Find the MGF of X, then use it to find E(X) and Var(X).
M_X(t) = 0.2e^{0} + 0.5e^{t} + 0.3e^{2t}Definition: add e^(tx) p(x) over the three values.
M_X(t) = 0.2 + 0.5e^{t} + 0.3e^{2t}e^0 = 1.
M_X'(t) = 0.5e^{t} + 0.6e^{2t}Differentiate each term (see chain rule).
M_X'(0) = 0.5 + 0.6 = 1.1
Substitute t = 0 to get E(X).
M_X''(t) = 0.5e^{t} + 1.2e^{2t}Differentiate again.
M_X''(0) = 0.5 + 1.2 = 1.7
Substitute t = 0 to get E(X²).
\operatorname{Var}(X) = 1.7 - 1.1^2Variance = E(X²) − [E(X)]².
\operatorname{Var}(X) = 1.7 - 1.21 = 0.49Square 1.1, then subtract.
Answer: M_X(t) = 0.2 + 0.5e^t + 0.3e^{2t}, E(X) = 1.1 and Var(X) = 0.49. A direct check gives E(X) = 0(0.2) + 1(0.5) + 2(0.3) = 1.1.
Example 2: MGF of an exponential distribution
X has the exponential distribution with rate 3, so f(x) = 3e^(−3x) for x ≥ 0. Find M_X(t), then find E(X) and Var(X).
M_X(t) = \int_0^{\infty} e^{tx} \cdot 3e^{-3x}\,dxDefinition with the density; f(x) = 0 for x < 0.
M_X(t) = 3\int_0^{\infty} e^{-(3 - t)x}\,dxCombine the exponents (see exponent rules).
M_X(t) = 3 \cdot \dfrac{1}{3 - t} = \dfrac{3}{3 - t}, \quad t \lt 3The improper integral equals 1/(3 − t) only when 3 − t > 0.
M_X'(t) = \dfrac{3}{(3 - t)^2}Write M = 3(3 − t)^(−1) and differentiate.
M_X'(0) = \dfrac{3}{9} = \dfrac{1}{3}Substitute t = 0 to get E(X).
M_X''(t) = \dfrac{6}{(3 - t)^3}Differentiate again.
M_X''(0) = \dfrac{6}{27} = \dfrac{2}{9}Substitute t = 0 to get E(X²).
\operatorname{Var}(X) = \dfrac{2}{9} - \left(\dfrac{1}{3}\right)^2 = \dfrac{2}{9} - \dfrac{1}{9} = \dfrac{1}{9}Variance = E(X²) − [E(X)]².
Answer: M_X(t) = \dfrac{3}{3 - t} for t < 3, E(X) = 1/3 and Var(X) = 1/9. These match the exponential formulas 1/λ and 1/λ².
Example 3: Calls at two help desks (word problem)
Calls to help desk A follow a Poisson distribution with mean 4 per hour. Calls to desk B follow a Poisson distribution with mean 6 per hour, independent of desk A. Find the distribution of the total number of calls T in one hour, and find P(T = 8).
M_A(t) = e^{4(e^t - 1)}, \quad M_B(t) = e^{6(e^t - 1)}Poisson MGFs from the table.
M_T(t) = e^{4(e^t - 1)} \cdot e^{6(e^t - 1)}Independent, so the MGF of the sum is the product.
M_T(t) = e^{10(e^t - 1)}Add the exponents: 4 + 6 = 10.
T \sim \text{Poisson}(10)Match the table; uniqueness gives the distribution.
P(T = 8) = \dfrac{e^{-10}\,10^8}{8!}Poisson distribution formula.
P(T = 8) = \dfrac{100{,}000{,}000\,e^{-10}}{40{,}320} \approx 0.112610^8 = 100,000,000 and 8! = 40,320.
Answer: T is Poisson with mean 10, and P(T = 8) ≈ 0.1126. Sums of independent Poisson variables are always Poisson, with the means added.
Example 4: A linear change of a normal variable
X is N(5, 2), so its mean is 5 and its standard deviation is 2. Use MGFs to find the distribution of Y = 3X − 4.
M_X(t) = e^{5t + 4t^2/2} = e^{5t + 2t^2}Normal MGF with μ = 5 and σ² = 4 (see normal distribution).
M_Y(t) = e^{-4t}\,M_X(3t)Linear change with a = 3 and b = −4.
M_X(3t) = e^{5(3t) + 2(3t)^2} = e^{15t + 18t^2}Replace t with 3t.
M_Y(t) = e^{-4t} \cdot e^{15t + 18t^2} = e^{11t + 18t^2}Add the exponents.
\dfrac{\sigma^2}{2} = 18 \implies \sigma^2 = 36 \implies \sigma = 6Match e^(μt + σ²t²/2); the t term gives μ = 11.
Answer: Y is N(11, 6), normal with mean 11 and standard deviation 6. This agrees with E(Y) = 3(5) − 4 and SD(Y) = 3(2).
Example 5: Total life of two components (word problem)
A machine runs on one part until it fails, then switches to an identical spare. Each part’s life is exponential with rate 0.5 per year, and the two lives are independent. Find the distribution of the total running time T, its mean, and P(T > 6).
M_1(t) = M_2(t) = \dfrac{0.5}{0.5 - t}, \quad t \lt 0.5Exponential MGF with λ = 0.5.
M_T(t) = \left(\dfrac{0.5}{0.5 - t}\right)^2Independent, so multiply the two MGFs.
T \sim \text{Gamma}(\alpha = 2,\ \lambda = 0.5)Match the gamma MGF with α = 2.
E(T) = \dfrac{\alpha}{\lambda} = \dfrac{2}{0.5} = 4Gamma mean.
P(T \gt 6) = e^{-0.5(6)}\left(1 + 0.5(6)\right)Gamma tail for α = 2: P(T > x) = e^(−λx)(1 + λx) (see gamma distribution).
P(T \gt 6) = 4e^{-3} \approx 0.1990.5(6) = 3, so the factor is 1 + 3 = 4.
Answer: T is gamma with α = 2 and λ = 0.5, the mean running time is 4 years, and P(T > 6) ≈ 0.199.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using M(0) as the mean | Saying E(X) = 1 because M(0) = 1 | M(0) = 1 for every variable. The mean is M′(0). |
| Using M″(0) as the variance | Var(X) = 1.7 in Example 1 | Subtract the squared mean: 1.7 − 1.1² = 0.49. |
| Multiplying MGFs of dependent variables | Using M_X(t)M_Y(t) when Y = X | The product rule for sums needs independence. |
| Wrong linear change | M_(3X−4)(t) = 3M_X(t) − 4 | Use e^(bt) M_X(at): e^(−4t) M_X(3t). |
| Ignoring where the MGF exists | Using 3/(3 − t) at t = 4 | The exponential MGF only exists for t < λ. |
| Adding MGFs for a sum | M_T(t) = M_A(t) + M_B(t) | Multiply, do not add: M_T(t) = M_A(t)M_B(t). |
Related ideas
Why sums become products
For independent X and Y, E(e^{t(X+Y)}) = E(e^{tX})E(e^{tY}), because e^(tX) and e^(tY) are also independent. This turns the convolution of densities into a simple product.
Generating functions in counting
The probability generating function E(s^X) is a close relative used for counting variables; set s = e^t to get the MGF. Discrete Math uses the same idea in generating functions.
The central limit theorem
A standard proof of the central limit theorem shows that the MGF of a standardized sample mean approaches e^(t²/2), the MGF of the standard normal. Unit 5 builds toward this with limit theorems.
Practice problems
- X takes the values 1 and 3 with probabilities 0.4 and 0.6. Find M_X(t).
- For the X in Problem 1, find E(X) using M_X′(0).
- X has MGF e^{2t + 8t^2}. Identify the distribution and give its mean and variance.
- X has MGF (0.25 + 0.75e^t)^8. Identify the distribution and find E(X).
- X has MGF \dfrac{5}{5 - t} for t < 5. Find Var(X) from the derivatives of the MGF.
- X is Poisson(2) and Y is Poisson(5), independent. Find the MGF of X + Y and P(X + Y = 0).
- X has MGF e^{3(e^t - 1)}. Find the MGF of Y = 2X + 1.
- X₁, X₂ and X₃ are independent Bernoulli(0.4) variables. Find the MGF of their sum and identify its distribution.
- X is N(1, 2) and Y is N(−3, 1), independent. Use MGFs to find the distribution of X + Y.
- X is uniform on [0, 2]. Find M_X(t) for t ≠ 0.
Show answers
1.
M_X(t) = 0.4e^{t} + 0.6e^{3t}Definition: add e^(tx) p(x) over x = 1 and x = 3.
Answer: M_X(t) = 0.4e^t + 0.6e^{3t}
2.
M_X'(t) = 0.4e^{t} + 1.8e^{3t}Differentiate each term.
M_X'(0) = 0.4 + 1.8 = 2.2
Substitute t = 0.
Answer: E(X) = 2.2
3.
\mu = 2, \quad \dfrac{\sigma^2}{2} = 8Match e^(μt + σ²t²/2).
\sigma^2 = 16 \implies \sigma = 4
Multiply by 2, then take the square root.
Answer: X is N(2, 4); mean 2, variance 16
4.
1 - p = 0.25,\quad p = 0.75,\quad n = 8
Match (1 − p + pe^t)^n.
E(X) = np = 8(0.75) = 6
Binomial mean (see binomial distribution).
Answer: Binomial(8, 0.75); E(X) = 6
5.
M_X'(t) = \dfrac{5}{(5 - t)^2} \implies M_X'(0) = \dfrac{5}{25} = 0.2First derivative at 0.
M_X''(t) = \dfrac{10}{(5 - t)^3} \implies M_X''(0) = \dfrac{10}{125} = 0.08Second derivative at 0.
\operatorname{Var}(X) = 0.08 - 0.2^2 = 0.08 - 0.04 = 0.04Variance = E(X²) − [E(X)]².
Answer: Var(X) = 0.04
6.
M_{X+Y}(t) = e^{2(e^t - 1)}\,e^{5(e^t - 1)} = e^{7(e^t - 1)}Multiply the MGFs and add the exponents.
P(X + Y = 0) = \dfrac{e^{-7}\,7^0}{0!} = e^{-7} \approx 0.000912X + Y is Poisson(7).
Answer: e^{7(e^t - 1)}; about 0.000912
7.
M_Y(t) = e^{t}\,M_X(2t)Linear change with a = 2 and b = 1.
M_Y(t) = e^{t}\,e^{3(e^{2t} - 1)}Replace t with 2t in M_X.
Answer: M_Y(t) = e^{t + 3(e^{2t} - 1)}
8.
M_S(t) = (0.6 + 0.4e^t)^3
Multiply three copies of the Bernoulli MGF 0.6 + 0.4e^t.
Answer: (0.6 + 0.4e^t)^3, so the sum is Binomial(3, 0.4)
9.
M_X(t) = e^{t + 2t^2}, \quad M_Y(t) = e^{-3t + 0.5t^2}Normal MGFs: σ² = 4 for X and σ² = 1 for Y.
M_{X+Y}(t) = e^{-2t + 2.5t^2}Multiply and add the exponents.
\dfrac{\sigma^2}{2} = 2.5 \implies \sigma^2 = 5 \implies \sigma = \sqrt{5} \approx 2.236Match the normal MGF.
Answer: X + Y is N(−2, √5): mean −2, variance 5
10.
M_X(t) = \int_0^2 e^{tx} \cdot \dfrac{1}{2}\,dxUniform density 1/2 on [0, 2].
M_X(t) = \dfrac{1}{2} \cdot \dfrac{e^{2t} - 1}{t}Antiderivative e^(tx)/t, evaluated from 0 to 2.
M_X(t) = \dfrac{e^{2t} - 1}{2t}Simplify.
Answer: M_X(t) = \dfrac{e^{2t} - 1}{2t} for t ≠ 0, and M_X(0) = 1
Moment generating function FAQ
What is a moment generating function used for?
It is used to find moments such as the mean and variance by differentiation, to identify a distribution by matching its MGF, and to find the distribution of a sum of independent random variables by multiplying MGFs.
How do you find the mean and variance from an MGF?
The mean is M′(0). The variance is M″(0) − [M′(0)]², as in Example 1.
Does every random variable have a moment generating function?
No. The MGF exists only if E(e^(tX)) is finite for all t in an open interval around 0. Heavy-tailed distributions such as the Cauchy distribution have no MGF.
Why is the MGF of a sum the product of the MGFs?
If X and Y are independent, then e^(tX) and e^(tY) are independent, so the expected value of their product is the product of their expected values. That product is M_X(t)M_Y(t).
Summary
- The MGF is M_X(t) = E(e^(tX)), a sum or integral of e^(tx) times the distribution.
- E(X) = M′(0), E(X²) = M″(0) and Var(X) = M″(0) − [M′(0)]².
- The same MGF means the same distribution, so you can identify a distribution by its MGF.
- For independent variables, the MGF of a sum is the product of the MGFs.
- For Y = aX + b, M_Y(t) = e^(bt) M_X(at).
Previous lesson: Bivariate Normal Distribution
Next lesson: Markov and Chebyshev Inequalities
Back to the Probability Theory Index