Moment generating functions
The question
Start with the curve and estimate the two numbers yourself.
- 1 SeeEstimate mean and variance from a curve.
- 2 TryCompare two ways to form a sum.
- 3 ProveDifferentiate a weighted sum.
- 4 ApplyRead derivatives and model a total.
Before you start · 3 quick checks on weighted averages, powers, and slope
Two ideas before you start
2 ideasAverage the exponential of each outcome
The bars show the two contributions to an exponential average.
Change the base \(a=e^t\). The bar heights change because each outcome \(x\) contributes its probability times \(a^x\).
Exact definition
For a real random variable \(X\) and a real input \(t\), write \(M_X(t)=\mathbb E[e^{tX}]\). If \(X\) takes finitely many values \(x_i\) with probabilities \(p_i\), this is \(\sum_i p_i e^{tx_i}\). For a variable with density \(f_X\), it is \(\int_{\mathbb R} e^{tx}f_X(x)\,dx\).
The expectation can be infinite. A moment generating function, or MGF, exists in the usual two-sided sense when the expectation is finite on an open interval containing zero. The pointwise expectation is meaningful even outside that setting.
Change the bend while holding the slope fixed
A quadratic and its tangent meet at the center.
The solid quadratic and dashed tangent meet with the same slope at zero. The quadratic term controls how far the two separate.
Exact definition
For a function \(g\) that is twice continuously differentiable near zero, the degree-two Taylor polynomial is \(g(0)+g'(0)t+\tfrac12g''(0)t^2\). Subtract the tangent line and divide by \(t^2\). As \(t\) tends to zero, the result tends to \(g''(0)/2\). The second derivative measures the change in slope. Here “bend” refers to that derivative.
Notation and background
A raw moment of order \(k\) is \(\mathbb E[X^k]\) when \(\mathbb E[|X|^k]\) is finite. The mean is \(\mu=\mathbb E[X]\). The variance is the mean squared distance from \(\mu\), namely \(\mathbb E[(X-\mu)^2]=\mathbb E[X^2]-\mu^2\) when the second moment is finite.
See expectation and variance for the weighted-average interpretation and Taylor polynomials for matching a curve near its center.
Read a hidden distribution from its curve
- Move the sample points closer to zero to estimate the slope and second derivative.
- Enter a mean and a variance. Try the heavy-tailed distribution after checking your estimates.
For this activity, use the slope at zero as the mean and the second derivative at zero as the second raw moment. Use the variance formula to turn that second moment into a variance. The support and probabilities of the hidden variable open after you submit.
How the three samples work
Take the two points at equal distances \(h\gt0\) on either side of zero. The slope estimate is the rise between the outer points divided by their spacing. For the second derivative estimate, compare the right-hand secant slope with the left-hand one, then divide their difference by \(h\).
\[\begin{aligned} D_1(h)&=\frac{M(h)-M(-h)}{2h},\\ D_2(h)&=\frac{M(h)+M(-h)-2M(0)}{h^2}. \end{aligned}\]For this smooth curve both estimates converge to the respective derivatives as \(h\) tends to zero. The symmetric samples cancel the even powers in the first numerator and the odd powers in the second. The numbers beside the plot are rounded after the model computes the estimates.
Where the curve can stop
Switch distributions using the buttons. This time both plots use the same vertical scale. Each button gives the domain of finite values and lets you compare the curve near zero.
Why the right side diverges
Combine two indicators
Build the transform of an independent sum
- Choose the probability for the second indicator and the base \(a=e^t\).
- Match each goal by comparing the product and the three contributions from the sum.
| Total \(s\) | Probability | Contribution |
|---|
If \(X\) and \(Y\) are independent, and both exponential expectations are finite at the same \(t\), the expectation of \(e^{tX}e^{tY}\) factors. The algebra of exponents then gives \(M_{X+Y}(t)=M_X(t)M_Y(t)\).
For finite variables, independence gives joint masses \(\mathbb P(X=x,Y=y)=\mathbb P(X=x)\mathbb P(Y=y)\). Inside the weighted sum over the pairs, \(e^{t(x+y)}=e^{tx}e^{ty}\), so the sum splits into two separate factors. For general independent variables the same reasoning uses the factorization of expectations of independent nonnegative functions.
The lesson on convolution groups independent pairs by their total to find its distribution. Here the same grouping creates the coefficients of a polynomial in \(a\). A coefficient gives the probability of that total when the outcomes are nonnegative integers.
Why derivatives give moments
Let \(X\) take finitely many real values \(x_i\) with probabilities \(p_i\ge0\) that sum to one. For every positive integer \(k\), \(M_X^{(k)}(0)=\mathbb E[X^k]\), where the superscript \((k)\) means the \(k\)-th derivative with respect to \(t\). Also \(M_X(0)=1\). In particular, \(\mathbb E[X]=M_X'(0)\) and \(\operatorname{Var}(X)=M_X''(0)-[M_X'(0)]^2\).
Pick steps to build the proof, including an algebraic identity that holds for arbitrary real \(x\) and \(t\).
What changes for infinite support?
Suppose \(M_X\) is finite on an open interval containing zero. Choose \(r\gt0\) with both \(M_X(r)\) and \(M_X(-r)\) finite. Then \(e^{r|X|}\le e^{rX}+e^{-rX}\) has finite expectation. On a smaller interval \(|t|\le r/2\), each \(|X|^k e^{tX}\) is bounded by a constant times \(e^{r|X|}\). This follows because \(u^k e^{-ru/2}\) is bounded for \(u\ge0\).
The mean value theorem bounds each difference quotient by the same type of integrable function on the smaller interval. Dominated convergence then permits repeated differentiation under the expectation near zero. The same exponential bound permits integrating the power series term by term for \(|t|\lt r\), because the sum of absolute term sizes has finite expectation there. The coefficient of \(t^k\) is \(\mathbb E[X^k]/k!\).
A uniqueness theorem states that two MGFs finite and equal on some open interval around zero belong to the same probability law. Equality at one input gives one number only. The full curve near zero carries the extra information.
Two standard examples show why the open interval matters. A standard Cauchy variable has no mean, and \(\mathbb E[e^{tX}]\) is infinite at every \(t\ne0\), so its curve is finite only at \(t=0\) and carries no moment information. A lognormal variable \(X=e^Z\), with \(Z\) standard normal, has every moment finite, \(\mathbb E[X^k]=e^{k^2/2}\), yet \(\mathbb E[e^{tX}]\) is infinite for every \(t\gt0\). So finite moments of every order do not guarantee an MGF near zero, and for the lognormal the sequence of moments does not even pin down the distribution: other laws share all of its moments.
Use the transform to answer a question
Use what you found above. Enter one decimal without units in each box. Start by deciding whether you need a derivative, a coefficient in a polynomial, or the value of an integral. Hints and worked solutions are available within each problem.
Further reading
- J. K. Blitzstein and J. Hwang, Introduction to Probability, chapter 6, “Moments.”