A moment generating function packs every moment of a distribution, the mean, the variance and all the higher ones, into a single function. It looks like machinery, and it earns its place in two ways: it turns the messy sum of independent variables into a plain product, and it acts as a name tag for a distribution. This page derives both, and uses them to settle several results the earlier pages took on trust.
Tap a symbol.
The mean is the average of X. The variance needs the average of X². To describe the shape fully you want E[X³], E[X⁴], and so on. Computing each by its own sum or integral is slow. The moment generating function (MGF) is a single function of a helper variable t, and every one of those moments can be read out of it by differentiating.
The price is that you must find the function once. The reward is that for the distributions of this library it is short, and that it behaves very well when independent variables are added.
The moment generating function of X is M(t) = E[etX]. For each fixed t, etX is just another random variable, so its average is a number, and as t varies that number traces a function. For a discrete X it is Σ etxP(x), and for a continuous X it is ∫ etxf(x) dx. Why etX? The next step shows it carries every power of X at once.
The series eu = 1 + u + u²/2! + u³/3! + … with u = tX gives etX = 1 + tX + t²X²/2! + t³X³/3! + …. Take the average of each term, remembering that t is a constant:
The moments E[X], E[X²], E[X³] and so on sit in a row as the coefficients, each attached to its own power of t. That is the sense in which M “generates” them.
Differentiate once: the constant 1 disappears, the term in t becomes E[X], and every other term still has a factor of t. Set t = 0 and only E[X] survives. Differentiate twice: the t² ÷ 2! term becomes E[X²], and setting t = 0 leaves just that. In general
Geometrically, M passes through (0, 1), its slope there is the mean and its curvature gives the second moment. The lab draws the curve for each family with its tangent.
A Bernoulli trial is 1 with chance p and 0 with chance q, so M(t) = q · e⁰ + p · et = q + pet. Then M′(t) = pet and M″(t) = pet, so M′(0) = p and M″(0) = p, and the variance is p − p² = pq, as found earlier by hand.
The middle sum is the series for eu with u = λet. Differentiate: M′(t) = λet M(t), so M′(0) = λ. And M″(t) = λet M(t) + (λet)² M(t), so M″(0) = λ + λ² and the variance is λ + λ² − λ² = λ.
The restriction t < λ is needed for the integral to converge, and it is all that is needed, since M only has to exist around t = 0. Then M′(t) = λ ÷ (λ − t)², so M′(0) = 1 ÷ λ, and M″(0) = 2 ÷ λ², giving the variance 2 ÷ λ² − 1 ÷ λ² = 1 ÷ λ².
For Z standard normal, MZ(t) = ∫ etz e−z²/2 ÷ √(2π) dz. Combine the exponents and complete the square: tz − z²/2 = −(z − t)²/2 + t²/2. So
The remaining integral is a normal density centred at t, so its area is 1. For a general normal X = μ + σZ, use et(μ+σZ) = eμt e(σt)Z, so MX(t) = eμt MZ(σt) = eμt + σ²t²/2. Its slope at 0 is μ and M″(0) = σ² + μ², so the variance is σ².
A gamma with shape α and rate λ is the sum of α independent exponentials, so its function is the exponential one to the power α: (λ ÷ (λ − t))α, which the sums derivation below confirms. With α = k ÷ 2 and λ = ½ this is the chi-square: (1 − 2t)−k/2, for t < ½.
M(t) must be finite for t in some interval around 0. For the heavy-tailed Cauchy distribution, and for the lognormal, etX has infinite average for every t ≠ 0, so no moment generating function exists, although other tools (the characteristic function, which uses an imaginary exponent) always do.
| Distribution | M(t) | Mean | Variance |
|---|---|---|---|
| Bernoulli(p) | q + pet | p | pq |
| Binomial(n, p) | (q + pet)n | np | npq |
| Poisson(λ) | exp(λ(et − 1)) | λ | λ |
| Exponential(λ) | λ ÷ (λ − t), t < λ | 1 ÷ λ | 1 ÷ λ² |
| Gamma(α, λ) | (λ ÷ (λ − t))α | α ÷ λ | α ÷ λ² |
| Chi-square(k) | (1 − 2t)−k/2 | k | 2k |
| Normal(μ, σ²) | exp(μt + σ²t²/2) | μ | σ² |
et(X+Y) = etX · etY. When X and Y are independent, the average of a product of functions of them is the product of the averages, the same factorisation that made independent variables uncorrelated. So
Finding the distribution of a sum directly means adding up every pair of values with the same total, a convolution. The moment generating function turns that into one multiplication.
A Bernoulli has M(t) = q + pet, and a binomial is the sum of n independent copies, so M(t) = (q + pet)n. Its slope at 0 is n(q + p)n−1p = np, and the variance comes out as npq. For n = 5 and p = 0.4, M(1) = 13.677.
The product has the form of a Poisson function with mean λ₁ + λ₂. The lab adds up pairs the long way and compares: the bars agree exactly. For example, with means 1.5 and 2.5 the chance that the total is 3 is the Poisson(4) value 0.1954.
(λ ÷ (λ − t))α₁ · (λ ÷ (λ − t))α₂ = (λ ÷ (λ − t))α₁+α₂: shapes add when the rate is the same. This is the step that was assumed when a gamma was built from exponential waits, and when a chi-square was built by adding squared normals. Likewise two independent normals give e(μ₁+μ₂)t + (σ₁²+σ₂²)t²/2, which is normal with the means and the variances added.
A theorem, quoted without proof here, says a moment generating function that is finite around 0 belongs to exactly one distribution. So recognising the shape is enough to identify a variable. (¼ + ¾et)6 is a binomial with n = 6 and p = ¾. e2(et−1) is a Poisson with mean 2. And 1 ÷ (1 − 2t) = ½ ÷ (½ − t) is an exponential with rate ½, that is, mean 2.
A binomial with p = λ ÷ n has M(t) = (1 + λ(et − 1) ÷ n)n. Since (1 + x ÷ n)n tends to ex, this tends to eλ(et−1), the Poisson function. By uniqueness the binomial distribution tends to the Poisson, which is the result derived by hand on the binomial and Poisson page. The same method, applied to a standardised sum, shows a function tending to et²/2, which is the central limit theorem.
The MGF of an independent sum is the product of the MGFs, and an MGF finite around 0 belongs to exactly one distribution. Multiply, recognise, done.
Questions of the form “the MGF is …, find the mean, the variance, or the distribution” are answered by recognising the shape against the table above, and only then by calculating. A short method:
The binomial and Poisson, exponential and gamma, and normal pages derive the distributions behind each row.
Read each answer from the moment generating function, using the formulas on this page.
This page does not have a past-paper set of its own yet. Questions that ask you to name a distribution from its moment generating function test the forms in the table above.
The moment generating function of a random variable X is M(t) = E[e^(tX)], defined for t in an interval around 0. It is called that because the k-th derivative of M at t = 0 equals the k-th moment E[X^k]. In particular M'(0) is the mean and M''(0) − M'(0)² is the variance.
Expanding e^(tX) as a power series and taking the average of each term gives M(t) = 1 + tE[X] + t²E[X²]/2! + t³E[X³]/3! + …. Differentiating k times and setting t = 0 kills every term except the one containing E[X^k], leaving exactly E[X^k].
For a normal with mean μ and variance σ², M(t) = exp(μt + σ²t²/2). For the standard normal it is exp(t²/2), found by completing the square in the exponent of the integral.
For a Poisson with mean λ, M(t) = exp(λ(e^t − 1)). For an exponential with rate λ, M(t) = λ/(λ − t) for t < λ.
It is the product of the individual MGFs, because the average of a product of functions of independent variables is the product of their averages. This shows, for example, that a sum of n independent Bernoulli variables is binomial and that a sum of independent Poisson variables is Poisson with the means added.
If two random variables have moment generating functions that are finite on an interval around 0 and are equal there, they have the same distribution. So recognising the form of an MGF tells you the distribution: for instance (1/4 + 3/4 e^t)^6 is the MGF of a binomial with n = 6 and p = 3/4.