Moment Generating Functions
One function that quietly stores every moment of a distribution — and hands you the mean back as its slope at zero.
A single function that remembers everything
Suppose you wanted to store all the information about a random variable \(X\) — its mean, its variance, its skewness, every moment \(E[X^k]\) — in one object you could carry around. The moment generating function (MGF) does exactly that. Instead of tracking an infinite list of moments, you track one function of a helper variable \(t\).
The trick is to average the exponential \(e^{tX}\). Because \(e^{tX}\) expands into a power series in \(X\), averaging it folds every power of \(X\) — every moment — into a single tidy expression. Wiggle the knob \(t\), differentiate, and the moments drop out one at a time.
Expand the exponential inside the expectation using its Taylor series \(e^{tX} = 1 + tX + \tfrac{(tX)^2}{2!} + \cdots\), then take the expectation term by term:
\(M(t) = 1 + t\,E[X] + \tfrac{t^2}{2!}E[X^2] + \tfrac{t^3}{3!}E[X^3] + \cdots\)
So the moments \(E[X^k]\) are literally the coefficients of this series (each scaled by \(k!\)). Reading a coefficient off a power series is what differentiating at zero does — which is why the derivatives of \(M\) at \(t=0\) hand you the moments.
Watch the slope become the mean
The tool below plots \(M(t)\) for three distributions with clean closed-form MGFs. Every curve passes through the point \((0, 1)\) because \(M(0) = 1\). The dashed line is the tangent at that point, and its slope is the numeric \(M'(0)\).
Pick a distribution and change its parameter. The readout compares the measured slope \(M'(0)\) against the known mean \(E[X]\) — they track each other exactly. For the exponential, notice the curve blows up as \(t\) approaches \(\lambda\): the MGF only exists for \(t < \lambda\), and the tool stops the plot before that pole.
Because \(M(0) = 1\) is fixed for everyone, the distributions differ in how they leave that point. The initial slope is the mean \(E[X]\), and the curvature at zero encodes the second moment \(E[X^2]\). A steeper, more sharply bending curve near \(t=0\) is a variable with a larger mean and spread. So the whole shape of \(X\) is written into how \(M\) departs from \((0,1)\).
Common MGFs, uniqueness, and sums
A few distributions have MGFs worth memorizing:
- Bernoulli(p): \(M(t) = 1 - p + p\,e^{t}\), giving \(E[X] = p\).
- Standard normal: \(M(t) = e^{t^2/2}\), giving \(E[X] = 0\), and more generally \(N(\mu, \sigma^2)\) has \(M(t) = e^{\mu t + \sigma^2 t^2 / 2}\).
- Exponential(λ): \(M(t) = \dfrac{\lambda}{\lambda - t}\) for \(t < \lambda\), giving \(E[X] = 1/\lambda\).
Two properties make MGFs powerful. Uniqueness: if two variables have the same MGF on an interval around \(t = 0\), they have the same distribution — the MGF pins a distribution down completely. The sum rule: for independent \(X\) and \(Y\), the MGF of the sum is the product of the individual MGFs. Together these turn hard convolution problems into easy multiplication: multiply the MGFs, then recognize the result. (One caveat for honesty: not every distribution has an MGF — heavy-tailed variables like the Cauchy have no interval where the integral converges.)
- First derivative: \(M'(t) = \dfrac{d}{dt}\,\lambda(\lambda - t)^{-1} = \dfrac{\lambda}{(\lambda - t)^2}\). At \(t = 0\): \(M'(0) = \lambda / \lambda^2 = 1/\lambda\). So \(E[X] = 1/\lambda\).
- Second derivative: \(M''(t) = \dfrac{2\lambda}{(\lambda - t)^3}\). At \(t = 0\): \(M''(0) = 2\lambda / \lambda^3 = 2/\lambda^2\). So \(E[X^2] = 2/\lambda^2\).
- Variance: \(\operatorname{Var}(X) = M''(0) - (M'(0))^2 = \dfrac{2}{\lambda^2} - \dfrac{1}{\lambda^2} = \dfrac{1}{\lambda^2}\).
Check your understanding
- The moment generating function is M(t) = E[e^{tX}] — an average of e^{tx} that stores every moment of X in one function.
- Its derivatives at zero recover the moments: M'(0) = E[X] and M''(0) = E[X^2], while M(0) = 1 always.
- Variance comes straight from the MGF: Var(X) = M''(0) − (M'(0))^2.
- Memorable MGFs: Bernoulli(p) = 1 − p + pe^t, standard normal = e^{t^2/2}, Exponential(λ) = λ/(λ − t) for t < λ.
- Uniqueness: equal MGFs mean equal distributions. Sum rule: for independent X and Y, M_{X+Y}(t) = M_X(t)·M_Y(t).