4.9.5 · D2Probability Theory & Statistics

Visual walkthrough — Moment generating function (MGF) — definition, use

1,961 words9 min readBack to topic

We assume only that you know: a random variable is a number that comes out random, and ("the expected value") is the long-run average. Everything else — even what a Taylor series is — we grow below.


Step 1 — What is a "moment", pictured?

WHAT. We line up the first few moments as a strip of numbers describing the shape of .

WHY. The whole point of the MGF is to pack this infinite strip into one function. So first we must see the strip we are trying to pack.

PICTURE. Figure s01: a clay blob (a distribution) with its balance point (moment 1), its width (moment 2), and its lean (moment 3) called out. The moments are an infinite to-do list of facts about the blob.

Figure — Moment generating function (MGF) — definition, use

Step 2 — What is , and why an exponential?

Before packing anything we need the packing material. That material is . Let us earn every symbol.

Now let , where is a plain real number we get to dial (a knob), and is our random variable:

WHAT. We stretched the exponential into an infinite polynomial, then substituted .

WHY this tool and not another? Look at the right-hand side: the term with carries exactly one power — never mixed. No other elementary function separates the powers of so cleanly into separate "shelves" labelled by . That clean shelving is the whole trick. (Contrast: or mix powers in messier ways or blow up.)

PICTURE. Figure s02: the exponential curve drawn as a stack of transparent polynomial pieces , then , then , ... each a coloured layer, showing how they add up to the smooth curve.

Figure — Moment generating function (MGF) — definition, use

Step 3 — Averaging the series: moments climb onto the shelves

Take the expectation of both sides. Because is linear — the average of a sum is the sum of the averages, and constants like slide out — we may average term by term:

WHAT. We averaged, and the random on each shelf turned into the fixed number .

WHY. This is the moment of victory: the entire infinite strip of moments from Step 1 is now packed into a single function . Each moment rides on its own power of .

PICTURE. Figure s03: the moment strip from s01 being loaded, one number per shelf, onto a shelf-rack labelled . This uses Taylor-series shelving and linearity of expectation.

Figure — Moment generating function (MGF) — definition, use

Step 4 — Reading one shelf: differentiate

We packed everything onto shelves; now we need a tool that reads one shelf and only one. That tool is the derivative (the slope / rate-of-change operator) together with evaluation at .

Watch what differentiation does to a single shelf :

Each differentiation pulls down the power by one () and multiplies by that power.

WHAT. We used as a "shelf-lowering" crank and as an "erase-the-rest" switch.

WHY. No single algebraic step can pick out one coefficient of an infinite polynomial — but repeated differentiation followed by can. That is precisely the question the derivative answers here: "what is the coefficient on this power?"

PICTURE. Figure s04: a comb of shelves; the shelf is dragged down two notches to the floor (becoming ) while a "" guillotine erases every shelf that still floats above zero.

Figure — Moment generating function (MGF) — definition, use

Step 5 — The master formula assembled

Do the crank times on the whole series and set ; only shelf survives:

The first two cranks are the ones you use daily:

And from those, variance (the spread from Expectation and Variance):

WHAT. We collapsed Steps 2–4 into a one-line recipe.

WHY. This is the machine the parent promised — turn the crank times, out pops moment .

PICTURE. Figure s05: the "moment genie" box. Dial set to , crank turned times, dial snapped back to , and moment drops out of the chute.

Figure — Moment generating function (MGF) — definition, use

Step 6 — A worked crank: Exponential

Let us watch the machine run on a concrete , density for .

  • The exponent must be negative for the area to be finite, forcing . That is the "interval around " being real.

Crank once and twice:

WHAT / WHY. We fed a real distribution in; the crank gave mean and variance with no integration of — the packing paid off.

PICTURE. Figure s06: the curve with a vertical wall (asymptote) at , the point marked, and the slope at drawn as the tangent whose value is .

Figure — Moment generating function (MGF) — definition, use

Step 7 — Edge & degenerate cases (never get surprised)

WHAT. We checked the dial-at-zero identity, the collapsed-blob limit, and the case where the box can't be built.

WHY. A machine you trust must behave at its boundaries; case 1 catches errors, case 2 shows the smallest input, case 3 shows the failure mode and its rescue.

PICTURE. Figure s07: three mini-panels — (a) every MGF passing through the same anchor point ; (b) a spike distribution at giving ; (c) a heavy tail whose area explodes, crossed out.

Figure — Moment generating function (MGF) — definition, use

Step 8 — Bonus crank: multiplication = gluing blobs

The same packed function has a second superpower. For independent and (see Independence (Probability)):

  • The single splitting step marked needs independence — that is what lets the average of a product become the product of averages.

WHY it matters. Adding independent variables would normally require a messy convolution of densities; here it is plain multiplication. Chaining this () and taking limits is exactly how the Central Limit Theorem is proven, and taking of links to the Cumulant Generating Function.

PICTURE. Figure s08: two blobs glued into one; their packed boxes multiply into the box of the sum.

Figure — Moment generating function (MGF) — definition, use

The one-picture summary

Figure — Moment generating function (MGF) — definition, use

Figure s09 compresses the whole story: moments (left) get packed by the exponential shelves into one curve (center); a crank + reset-to-zero (right) reads any single moment back out; and two boxes multiply when blobs are glued.

pack with e to the tX

differentiate n times then set t equals 0

boxes multiply

moments E of X to the n

MGF M of t

blob X

sum blob

blob Y independent

M of X times M of Y

Recall Feynman retelling of the whole walkthrough

A blob of clay has an endless list of facts: where its middle sits, how wide it is, how it leans, and on forever. That is our moment strip (Step 1). To carry the list without dropping any, we build a magic box out of the exponential , because when you unfold that exponential into an infinite polynomial each power of the dial sits on its own private shelf (Step 2), and each shelf holds exactly one moment once we average (Step 3). To read a fact back, we spin the derivative crank: each spin lowers a shelf by one notch, and when we finally snap the dial back to zero, every shelf but the one we wanted vanishes — that leaves a single clean moment (Steps 4–5). We tested the box on a real exponential distribution and out came the mean and variance with no ugly integrals (Step 6). We checked the corners: the dial at zero always reads , a frozen constant blob has zero spread, and a wild heavy-tailed blob overflows the box so we switch to its cousin the characteristic function (Step 7). Finally, glue two independent blobs together and their boxes simply multiply — that one fact powers half of probability theory (Step 8).

Recall Quick self-check

Why must we set after differentiating, not ? ::: Setting kills every shelf except the one lowered to a constant; would leave all the other shelves alive and mix moments together. What guarantees for every ? ::: . Which single assumption lets ? ::: Independence of and .