St · Statistics & Probability

What Is the MGF of X − Y?

Published By the 9to5Science editorial team

At a glance

  1. 1. Start with the definition

    Write the MGF of the difference as E[e^{t(X−Y)}].

  2. 2. Check independence

    If X and Y are independent, factor the expectation into separate MGFs.

  3. 3. Reverse the sign

    The Y factor is M_Y(−t), not M_Y(t).

  4. 4. Check the domain

    Use only t values where both required MGFs are finite.

  5. 5. Handle dependence jointly

    Without independence, evaluate E[e^{t(X−Y)}] from the joint distribution.

The moment-generating function (MGF) of a random variable ZZ is MZ(t)=E[etZ]M_Z(t)=\mathbb{E}[e^{tZ}], for values of tt where the expectation is finite. To find the MGF of a difference, the key step is to keep track of the minus sign on YY.

If XX and YY are independent, then

MX−Y(t)=MX(t)MY(−t).M_{X-Y}(t)=M_X(t)M_Y(-t).

The formula is valid on the range of tt where both factors on the right are finite. If XX and YY are dependent, this product rule does not generally apply; use the joint distribution to calculate E[et(X−Y)]\mathbb{E}[e^{t(X-Y)}].

Deriving the formula

Start from the definition and rewrite the exponential:

MX−Y(t)=E[et(X−Y)]=E[etXe−tY].\begin{aligned} M_{X-Y}(t) &=\mathbb{E}[e^{t(X-Y)}]\\ &=\mathbb{E}[e^{tX}e^{-tY}]. \end{aligned}

When XX and YY are independent, functions of XX and YY are independent as well. Therefore the expectation factors:

MX−Y(t)=E[etX] E[e−tY]=MX(t)MY(−t).\begin{aligned} M_{X-Y}(t) &=\mathbb{E}[e^{tX}]\,\mathbb{E}[e^{-tY}]\\ &=M_X(t)M_Y(-t). \end{aligned}

The argument of MYM_Y is −t-t because the exponent contains −tY-tY. This is the main detail that distinguishes the MGF of a difference from the MGF of a sum. For independent variables, the sum formula is MX+Y(t)=MX(t)MY(t)M_{X+Y}(t)=M_X(t)M_Y(t); for a difference, replace the second tt with −t-t.

Worked example: independent exponential variables

Suppose XX and YY are independent exponential random variables with rates λ>0\lambda>0 and μ>0\mu>0. An exponential variable with rate rr has MGF

M(t)=rr−t,t<r.M(t)=\frac{r}{r-t}, \qquad t<r.

Thus MX(t)=λλ−tM_X(t)=\frac{\lambda}{\lambda-t} for t<λt<\lambda, while

MY(−t)=μμ−(−t)=μμ+t,−t<μ.M_Y(-t)=\frac{\mu}{\mu-(-t)}=\frac{\mu}{\mu+t}, \qquad -t<\mu.

The condition −t<μ-t<\mu is equivalent to t>−μt>-\mu. Combining the two domain conditions gives −μ<t<λ-\mu<t<\lambda. Consequently,

MX−Y(t)=λλ−tμμ+t,−μ<t<λ.M_{X-Y}(t)=\frac{\lambda}{\lambda-t}\frac{\mu}{\mu+t}, \qquad -\mu<t<\lambda.

For example, if both rates are 22, then

MX−Y(t)=4(2−t)(2+t)=44−t2,−2<t<2.M_{X-Y}(t)=\frac{4}{(2-t)(2+t)}=\frac{4}{4-t^2}, \qquad -2<t<2.

This MGF is symmetric in tt, so its first derivative at zero is zero. That matches E[X−Y]=E[X]−E[Y]=12−12=0\mathbb{E}[X-Y]=\mathbb{E}[X]-\mathbb{E}[Y]=\frac12-\frac12=0. Its second derivative at zero is 12\frac12, which is the variance of X−YX-Y: independence gives Var⁡(X−Y)=Var⁡(X)+Var⁡(Y)=14+14=12\operatorname{Var}(X-Y)=\operatorname{Var}(X)+\operatorname{Var}(Y)=\frac14+\frac14=\frac12.

If X and Y are dependent

Without independence, the correct starting point remains

MX−Y(t)=E[etX−tY],M_{X-Y}(t)=\mathbb{E}[e^{tX-tY}],

but you cannot usually split this into a product of marginal expectations. If (X,Y)(X,Y) has a joint density fX,Y(x,y)f_{X,Y}(x,y), for instance, use

MX−Y(t)=∫−∞∞∫−∞∞et(x−y)fX,Y(x,y) dx dy,M_{X-Y}(t)=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty} e^{t(x-y)}f_{X,Y}(x,y)\,dx\,dy,

provided the integral is finite. A joint probability mass function gives the analogous sum. Dependence matters because knowing the separate distributions of XX and YY does not, in general, tell you the distribution of their difference.

For example, if Y=XY=X, then X−Y=0X-Y=0 with probability one, so MX−Y(t)=1M_{X-Y}(t)=1. Multiplying MX(t)M_X(t) by MY(−t)M_Y(-t) would generally give a different answer: that product treats the variables as independent, not identical copies that are equal on every outcome.

Common mistakes

  • Using MY(t)M_Y(t) instead of MY(−t)M_Y(-t). The negative argument follows directly from et(X−Y)=etXe−tYe^{t(X-Y)}=e^{tX}e^{-tY}.
  • Multiplying MGFs without independence. The factorization is justified by independence, not merely by knowing both marginal MGFs.
  • Ignoring the domain. In the independent case, tt must belong to the domain of MX(t)M_X(t) and also make MY(−t)M_Y(-t) finite. The example’s domain is the intersection (−μ,λ)(-\mu,\lambda).
  • Confusing a difference with a ratio. The MGF concerns et(X−Y)e^{t(X-Y)}; it does not directly give the distribution or MGF of X/YX/Y.

Once the MGF is known near zero, derivatives can provide moments when they exist. In particular, for independent variables with finite means and variances, E[X−Y]=E[X]−E[Y]\mathbb{E}[X-Y]=\mathbb{E}[X]-\mathbb{E}[Y] and Var⁡(X−Y)=Var⁡(X)+Var⁡(Y)\operatorname{Var}(X-Y)=\operatorname{Var}(X)+\operatorname{Var}(Y).

References

  1. A First Course in Probability — Sheldon Ross
  2. Statistical Inference — George Casella and Roger L. Berger

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.