Skip to content
We use only essential cookies to keep you signed in and remember your preferences. See our Cookie Policy.
TestStop
MocksPracticeResourcesIndiaBlogPricing
Sign in
Resources › Derivations › Moment generating functions
Derivation · Statistics

Moment generating functions, derived

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.

SymbolsReading the maths on this pageΣ, x̄, E[ ] and friends: how to say them and what they tell you to do.

Tap a symbol.

In this guide
Derivation · about 45 minutes
  1. One function that holds every moment
  2. Getting the moments out
  3. The familiar distributions
  4. Sums, and naming a distribution
  5. Reading an MGF in an exam
  6. The mistakes examiners are fishing for
  7. Worked examples
  8. The page on one screen
  9. Check yourself
  10. Quick answers
01
The idea

One function that holds every moment

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.

Pause and predict
The moment generating function of any random variable, evaluated at t = 0, always equals
02
Derivation

Getting the moments out

Derive it

Why the moment generating function gives the moments

We want to show
For M(t)=E[etX], the k-th derivative at zero is the k-th moment: M(k)(0)=E[Xk]. In particular the mean is M′(0) and the variance is M″(0) − M′(0)².
  1. 1
    Define it as an average of exponentials.

    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.

  2. 2
    Expand the exponential.

    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:

    M(t)=1+tE[X]+2!t2​E[X2]+3!t3​E[X3]+⋯

    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.

  3. 3
    Pull one out by differentiating and setting t to 0.

    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

    M(k)(0)=E[Xk],Var(X)=M′′(0)−(M′(0))2

    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.

    Say it in words
    “The mean is the slope of M at zero. The second moment is the second derivative at zero. Subtract the square of the mean from it to get the variance.”
  4. 4
    Try it on the simplest case.

    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.

Step 1 of 4
So
The moment generating function is a way of storing every moment in one function. Reading a mean or a variance becomes differentiating and substituting zero, which is often far easier than summing or integrating x and x² against the density.
The moment generating function
M(t)=E[etX],M(k)(0)=E[Xk]
Defined for t in an interval around 0. The k-th derivative at 0 is the k-th moment.
03
Derivation

The familiar distributions

Derive it

The moment generating functions of the familiar distributions

We want to show
Poisson: eλ(et−1). Exponential: λ−tλ​ for t < λ. Normal: eμt+σ2t2/2.
  1. 1
    Poisson: a sum that is an exponential series.
    M(t)=k≥0∑​etkk!e−λλk​=e−λk≥0∑​k!(λet)k​=e−λeλet=eλ(et−1)

    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 λ + λ² − λ² = λ.

  2. 2
    Exponential: an integral that closes at once.
    M(t)=∫0∞​etxλe−λxdx=λ∫0∞​e−(λ−t)xdx=λ−tλ​(t<λ)

    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 ÷ λ².

  3. 3
    Standard normal: complete the square.

    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

    MZ​(t)=et2/2∫2π​e−(z−t)2/2​dz=et2/2⋅1

    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 σ².

  4. 4
    Gamma and chi-square: the exponential, raised to a power.

    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 < ½.

  5. 5
    Know where it fails.

    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.

Step 1 of 5
So
Each of these functions is a closed form that holds a whole distribution. The names to remember are the shapes: e^(λ(e^t − 1)) is Poisson, a ratio λ ÷ (λ − t) is exponential, and a quadratic in the exponent is normal.
The moment generating functions to know
DistributionM(t)MeanVariance
Bernoulli(p)q + petppq
Binomial(n, p)(q + pet)nnpnpq
Poisson(λ)exp(λ(et − 1))λλ
Exponential(λ)λ ÷ (λ − t), t < λ1 ÷ λ1 ÷ λ²
Gamma(α, λ)(λ ÷ (λ − t))αα ÷ λα ÷ λ²
Chi-square(k)(1 − 2t)−k/2k2k
Normal(μ, σ²)exp(μt + σ²t²/2)μσ²
04
Derivation

Sums, and naming a distribution

Derive it

Sums of independent variables, and why one function names a distribution

We want to show
For independent X and Y, MX+Y​(t)=MX​(t)MY​(t). And two variables with the same moment generating function, finite near 0, have the same distribution.
  1. 1
    A sum becomes a product.

    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

    MX+Y​(t)=E[etXetY]=E[etX]E[etY]=MX​(t)MY​(t)

    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.

  2. 2
    The binomial is n Bernoullis.

    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.

  3. 3
    Two Poisson counts add to a Poisson.
    eλ1​(et−1)⋅eλ2​(et−1)=e(λ1​+λ2​)(et−1)

    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.

  4. 4
    Gamma waits add the same way.

    (λ ÷ (λ − 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.

  5. 5
    Uniqueness: the function is a name tag.

    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.

  6. 6
    Use it to prove the Poisson limit in one line.

    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.

Step 1 of 6
So
Two properties give the moment generating function its power: it turns sums of independent variables into products, and it identifies a distribution uniquely. Together they let you prove, in a line each, facts that take a page by direct calculation.
Two superpowers

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.

05
In the exam

Reading an MGF in an exam

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:

  1. Check M(0) = 1. If a candidate fails this, it is not an MGF.
  2. Match the form. A power of (q + pet) is binomial. An exponential of et is Poisson. A ratio with t in the denominator is exponential or gamma. A quadratic in the exponent is normal.
  3. Read the parameters off the match and quote the mean and variance from the table. Differentiate only if no form matches.
  4. For a sum of independent variables, multiply the functions first, then recognise the product. For a transformation aX + b, use M(t) = ebt MX(at).

The binomial and Poisson, exponential and gamma, and normal pages derive the distributions behind each row.

06
Exam focus

The mistakes examiners are fishing for

Watch out for

The mistakes examiners are fishing for

  • Reporting M″(0) as the variance. It is the second moment. Subtract the square of the mean.
  • Forgetting the et. The binomial function is (q + pet)n, not (q + p)n, which is just 1.
  • Adding the MGFs of independent variables. They multiply. It is the exponents that add.
  • Reading the variance from a normal exponent. In exp(μt + σ²t²/2) the coefficient of t² is σ² ÷ 2, so for 2t² the variance is 4, not 2.
  • Ignoring the range of t. The exponential function λ ÷ (λ − t) exists only for t < λ.
  • Assuming every distribution has one. The Cauchy and the lognormal do not.
07
Practice

Worked examples

Name the distribution
X has M(t) = (¼ + ¾e^t)⁶. State its distribution, mean and variance.
  1. 1
    Match the form
    (q + pe^t)^n with q = ¼, p = ¾, n = 6.
  2. 2
    Read the moments
    Mean np = 6 × ¾ = 4.5. Variance npq = 6 × ¾ × ¼ = 1.125.
Answer
Binomial(6, ¾), with mean 4.5 and variance 1.125.
A sum of independent Poissons
X and Y are independent Poisson variables with means 1.5 and 2.5. Find the distribution of X + Y and P(X + Y = 3).
  1. 1
    Multiply the MGFs
    exp(1.5(e^t − 1)) × exp(2.5(e^t − 1)) = exp(4(e^t − 1)).
  2. 2
    Recognise it
    A Poisson with mean 4.
  3. 3
    Evaluate
    P(3) = e⁻⁴ 4³ ÷ 3! = 0.1954.
Answer
Poisson with mean 4, and P(X + Y = 3) = 0.1954.
A transformation
X is exponential with rate 1 ÷ 2 (mean 2). Find the MGF of 3X + 1 and its mean.
  1. 1
    The rule for aX + b
    M(t) = e^t · M_X(3t).
  2. 2
    Substitute
    M_X(s) = ½ ÷ (½ − s), so M_X(3t) = ½ ÷ (½ − 3t) = 1 ÷ (1 − 6t).
  3. 3
    The mean
    3 × 2 + 1 = 7. As a check, the derivative of e^t ÷ (1 − 6t) at 0 is 1 + 6 = 7.
Answer
M(t) = e^t ÷ (1 − 6t) for t < 1/6, and the mean is 7.
08
Revision

The page on one screen

The lesson on one screen
Definition
M(t) = E[etX]. Always M(0) = 1.
Moments
M(k)(0) = E[Xk]. Variance = M″(0) − M′(0)².
Why
etX = 1 + tX + t²X²/2! + …, averaged term by term.
Sums
Independent X and Y: MX+Y = MX MY.
Transformations
MaX+b(t) = ebt MX(at).
Uniqueness
Same MGF near 0 means same distribution, so recognise the form.
The forms
(q + pet)n binomial; exp(λ(et − 1)) Poisson; λ ÷ (λ − t) exponential; exp(μt + σ²t²/2) normal.
09
Practice

Check yourself

0 of 11 correct so far

Numbers

Read each answer from the moment generating function, using the formulas on this page.

Mean from the slope
X has M(t) = (0.6 + 0.4e^t)⁵. What is its mean?
A variance from the form
The same X has M(t) = (0.6 + 0.4e^t)⁵. What is its variance?
A second moment
X has M(t) = exp(2(e^t − 1)). What is E[X²]?
A variance from a ratio
X has M(t) = 1 ÷ (1 − 2t). What is its variance?
A normal from its exponent
X has M(t) = exp(3t + 2t²). What is its variance?
A sum of two Poissons
X is Poisson with mean 1.5 and Y is an independent Poisson with mean 2.5. What is P(X + Y = 3)? (four decimals)

Concepts

1M(t) = (¼ + ¾e^t)⁶ is the moment generating function of
2For independent X and Y, the MGF of X + Y is
3M(0) equals
4The variance of X is
5Which distribution has no moment generating function?

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.

10
Quick answers

Quick answers

What is a moment generating function?

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.

Why does differentiating the MGF at zero give the moments?

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].

What is the MGF of the normal distribution?

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.

What is the MGF of the Poisson and the exponential?

For a Poisson with mean λ, M(t) = exp(λ(e^t − 1)). For an exponential with rate λ, M(t) = λ/(λ − t) for t < λ.

How does the MGF of a sum of independent variables work?

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.

What is the uniqueness property of the MGF?

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.

Read next

All resources →
StatisticsThe chi-square, t and F distributions, derivedAll three built from the standard normal: the chi-square as a sum of squares (a gamma), the n - 1 degrees of freedom, the variance interval, the t as a normal over a chi-square and the F as a ratio of chi-squares, with simulation labs for each.Derivation · 50 minStatisticsThe binomial and Poisson distributions, derivedThe binomial by counting sequences of independent trials, its mean and variance from indicators, and the Poisson as the limit of the binomial, with a sequence counter, a binomial-to-Poisson lab, and the mean and variance worked out.Derivation · 40 minStatisticsDerivations: how the main results are arrived at, and what they meanEach derivation starts from the question, defines every symbol, goes one step at a time with a picture where the idea turns, and ends on what the result means and where the exams ask it. Includes a short guide to reading sigma notation and other symbols.Derivation · 5 min