Tutorials › Statistical Theory I - Probability and Distribution Theory › Recovering Moments by Differentiating an MGF

Moments and Generating Functions · Tutorial 504 of 994

Recovering Moments by Differentiating an MGF

Use derivatives at zero to calculate raw moments from an MGF, and distinguish those moments from central moments and other summaries.

Intermediate 9 min read

What You'll Learn

  • State the condition under which MGF derivatives at zero recover raw moments.
  • Calculate first, second, and higher raw moments from explicit MGFs.
  • Use derivatives of a finite-support MGF to obtain moments directly.
  • Recover variance from the first two MGF derivatives.
  • Recognize why an MGF known only on one side of zero does not meet the stated condition.
  • Avoid confusing raw moments with central moments.

From an MGF to Raw Moments

A moment-generating function is useful not only as a compact description of a distribution, but also as a way to calculate its moments. When the moment-generating function exists on an open interval around zero, its derivatives at zero give the raw moments: the first derivative gives the mean, the second gives the second raw moment, and so on. The key is to evaluate the derivative at zero—not to read a moment directly from the exponent or from a value of the MGF away from zero.

Let \(X\) be a random variable with moment-generating function \(M(t)=E[e^{tX}]\) wherever this expectation is finite. The condition “exists on an open interval around zero” means there is some \(\delta>0\) such that \(M(t)<\infty\) for every \(t\in(-\delta,\delta)\). Under this condition, the MGF differentiation rule applies for every nonnegative integer order.

Theorem: If \(M(t)=E[e^{tX}]\) is finite for every \(t\) in some open interval containing zero, then \(M\) has derivatives of every nonnegative integer order at zero, and $$ M^{(r)}(0)=E[X^r], \qquad r=0,1,2,\ldots. $$ In particular, \(M(0)=1\), \(M'(0)=E[X]\), \(M''(0)=E[X^2]\), and \(M'''(0)=E[X^3]\). These are raw moments, not central moments.

The derivative order matters: \(M^{(r)}(0)\) corresponds to the power \(X^r\). For example, the second derivative gives \(E[X^2]\), not \(\operatorname{Var}(X)\). Variance is obtained by combining raw moments, as shown below. If the support of \(X\) includes negative values, odd raw moments can be negative; the formula does not insert an absolute value.

Why the Rule Works for Finite-Support Distributions

For a distribution with finitely many possible values, the MGF is a finite sum of exponential terms, so repeated differentiation requires no interchange of a limit and an expectation. This gives a direct derivation of the rule in that case.

Result for finite support: Suppose \(P(X=x_j)=p_j\) for \(j=1,\ldots,m\), where \(p_j\geq 0\) and \(\sum_{j=1}^m p_j=1\). Then $$ M(t)=\sum_{j=1}^m p_j e^{t x_j} \quad\text{and}\quad M^{(r)}(0)=\sum_{j=1}^m p_jx_j^r=E[X^r]. $$

To verify the result, differentiate each term of the finite sum. The \(r\)th derivative of \(p_j e^{t x_j}\) is \(p_jx_j^r e^{t x_j}\), including when \(x_j\) is negative. Evaluating at zero gives \(p_jx_j^r e^0=p_jx_j^r\). Summing over \(j\) yields \(\sum_j p_jx_j^r\), which is the expectation of \(X^r\) for this discrete distribution. The sum is finite, so each differentiation and the evaluation at zero are valid. \(\square\)

This finite-support calculation also gives a useful practical check: when the distribution is specified by a short probability table, the derivative result should agree with the direct sum of probability times the appropriate power. The MGF can make repeated calculations convenient, but it does not change what a raw moment means.

Worked Example: First Three Raw Moments from a Finite MGF

Let \(X\) have the distribution \(P(X=0)=0.2\), \(P(X=1)=0.5\), and \(P(X=3)=0.3\). The probabilities are nonnegative and sum to \(0.2+0.5+0.3=1\). Find \(E[X]\), \(E[X^2]\), and \(E[X^3]\) by differentiating the MGF.

The MGF is $$ M(t)=0.2e^{0t}+0.5e^t+0.3e^{3t} =0.2+0.5e^t+0.3e^{3t}. $$

Differentiate once: $$ M'(t)=0.5e^t+0.9e^{3t}, \qquad M'(0)=0.5+0.9=1.4. $$ Thus \(E[X]=1.4\).

Differentiate again: $$ M''(t)=0.5e^t+2.7e^{3t}, \qquad M''(0)=0.5+2.7=3.2. $$ Thus \(E[X^2]=3.2\).

A third derivative gives $$ M'''(t)=0.5e^t+8.1e^{3t}, \qquad M'''(0)=0.5+8.1=8.6. $$ Thus \(E[X^3]=8.6\). As a check, the direct weighted sums are \(0(0.2)+1(0.5)+3(0.3)=1.4\), \(0^2(0.2)+1^2(0.5)+3^2(0.3)=3.2\), and \(0^3(0.2)+1^3(0.5)+3^3(0.3)=8.6\).

Using the First Two Derivatives

The first two MGF derivatives give the mean and the second raw moment. Their relationship to variance follows directly from the definition of variance, provided the second moment is finite. The open-interval condition above ensures that these moments exist.

Result: If the MGF of \(X\) is finite on an open interval containing zero, then $$ \operatorname{Var}(X)=M''(0)-\bigl(M'(0)\bigr)^2. $$

Indeed, the definition of variance gives \(\operatorname{Var}(X)=E[(X-E[X])^2]\). Expanding the square, $$ \operatorname{Var}(X)=E[X^2-2X E[X]+(E[X])^2] =E[X^2]-2(E[X])^2+(E[X])^2 =E[X^2]-(E[X])^2. $$ Here \(E[X]\) is a constant, so \(E[X E[X]]=E[X]E[X]\). Applying the MGF differentiation rule, \(E[X^2]=M''(0)\) and \(E[X]=M'(0)\), proving the stated formula. \(\square\)

Worked Example: Variance From MGF Derivatives

For the distribution in the preceding calculation, use the first two derivatives to find the variance and standard deviation.

The derivatives gave \(M'(0)=1.4\) and \(M''(0)=3.2\). Therefore $$ \operatorname{Var}(X)=3.2-(1.4)^2=3.2-1.96=1.24. $$ The standard deviation is \(\sqrt{1.24}\), approximately \(1.114\). The nonnegative variance is consistent with the distribution. Notice that \(3.2\) itself is the second raw moment, not the variance.

Worked Calculations With Different Support

The same procedure applies when the support includes negative values. Odd powers retain their signs, while even powers are nonnegative. Keeping the powers visible during differentiation helps prevent sign errors.

Worked Example: Odd and Even Moments for a Symmetric Distribution

Suppose \(P(X=-2)=1/2\) and \(P(X=2)=1/2\). Find the first four raw moments from the MGF.

The probabilities sum to one, and $$ M(t)=\tfrac12e^{-2t}+\tfrac12e^{2t}. $$ The first derivative is $$ M'(t)=-e^{-2t}+e^{2t}, \qquad M'(0)=-1+1=0, $$ so \(E[X]=0\).

The second derivative is $$ M''(t)=2e^{-2t}+2e^{2t}, \qquad M''(0)=2+2=4, $$ so \(E[X^2]=4\). The third derivative is $$ M'''(t)=-4e^{-2t}+4e^{2t}, \qquad M'''(0)=-4+4=0, $$ so \(E[X^3]=0\). Finally, $$ M^{(4)}(t)=8e^{-2t}+8e^{2t}, \qquad M^{(4)}(0)=8+8=16, $$ so \(E[X^4]=16\). These values also follow directly from the equal probabilities at \(2\) and \(-2\): odd powers cancel and even powers agree.

Worked Example: A Nonzero Mean With Negative Support

Let \(P(X=-1)=1/4\), \(P(X=0)=1/2\), and \(P(X=2)=1/4\). These probabilities sum to one. Find the first three raw moments and the variance.

The MGF is $$ M(t)=\tfrac14e^{-t}+\tfrac12+\tfrac14e^{2t}. $$ Its first derivative is \(M'(t)=-\tfrac14e^{-t}+\tfrac12e^{2t}\), so \(M'(0)=-\tfrac14+\tfrac12=\tfrac14\). Thus \(E[X]=1/4\).

The second derivative is \(M''(t)=\tfrac14e^{-t}+e^{2t}\), giving \(M''(0)=\tfrac14+1=\tfrac54\). Hence \(E[X^2]=5/4\). The third derivative is \(M'''(t)=-\tfrac14e^{-t}+2e^{2t}\), giving \(M'''(0)=-\tfrac14+2=\tfrac74\). Hence \(E[X^3]=7/4\).

The variance is $$ \operatorname{Var}(X)=\tfrac54-\left(\tfrac14\right)^2 =\tfrac{20}{16}-\tfrac{1}{16} =\tfrac{19}{16}. $$ The negative support point contributes negatively to the first and third raw moments, but positively to the second raw moment.

Domain Checks and Common Mistakes

Before differentiating an MGF to obtain moments, check the condition under which the differentiation rule applies. It is not enough that the formula for \(M(t)\) can be written down at zero, or that it is finite for some positive values of \(t\). The stated rule requires finiteness throughout an open interval containing zero. Once that condition is satisfied, differentiate the MGF, then substitute \(t=0\), and interpret the result as the raw moment of the corresponding order.

A common mistake is to identify \(M''(0)\) with variance because variance is often informally described as a “second moment.” That reasoning skips the centering by the mean. The correction is to distinguish the second raw moment, \(E[X^2]=M''(0)\), from the second central moment, \(\operatorname{Var}(X)=E[(X-E[X])^2]\). The latter equals \(M''(0)-(M'(0))^2\).

Another error is to ignore signs when \(X\) can be negative. For instance, the contribution of the value \(-1\) to the third raw moment is \((-1)^3=-1\), not \(1\). A reliable check is to compare the derivative calculation with the finite sum \(\sum_j p_jx_j^r\) whenever the distribution has finite support.

Key takeaway: Under the open-interval existence condition, \(M^{(r)}(0)=E[X^r]\). Differentiate first, evaluate at zero second, and then interpret the result as a raw moment. Compute variance separately as \(M''(0)-(M'(0))^2\).

Check Your Understanding

Use the MGF differentiation rule and show enough work to identify the derivative values you use.

  1. For a random variable with \(M(t)=0.4+0.6e^{2t}\), calculate \(E[X]\) and \(E[X^2]\).
  2. If \(M'(0)=-1\) and \(M''(0)=5\), what are the mean, second raw moment, and variance?
  3. Why does \(M''(0)\) generally not equal \(\operatorname{Var}(X)\)?
  4. For a finite-support distribution, explain why differentiating its MGF term by term is valid.
  5. What domain condition is required to apply the general MGF differentiation rule for every raw moment order?