Hexa Scholar

Moment generating functions

A tray of navy and gold clay tokens beside a cream dial.
The dial stands for changing how strongly different outcomes contribute to an average.

The question

Start with the curve and estimate the two numbers yourself.

  1. 1 SeeEstimate mean and variance from a curve.
  2. 2 TryCompare two ways to form a sum.
  3. 3 ProveDifferentiate a weighted sum.
  4. 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 ideas

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

1 See

Read a hidden distribution from its curve

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.

2 Try

Combine two indicators

3 Prove

Why derivatives give moments

Theorem for finite support

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\).

4 Apply

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.

Key point Read means and raw moments from derivatives at zero. For a sum of independent variables use the product at common finite inputs. For an unbounded variable, check where its exponential expectation is finite before using the moment formulas.
Level Intro Prerequisites Expectation and variance, Taylor polynomials Time About 30 min

Further reading