Unit 5, lesson 35

Sums of Discrete Random Variables

How to find the distribution of a sum of two discrete random variables with an ordered-pair table and discrete convolution, why variances add for independent variables, and how a cross term enters the variance of a dependent sum.

  • Video 35
  • Sums and Sample Means

Two tasks produce random counts XX and YY, and the question is how their total X+YX + Y is distributed. The mean of the total is the sum of the two means whenever those are finite, but the distribution asks for more. It asks which pairs of counts produce each total and how likely those pairs are. This lesson builds the distribution of a sum from ordered pairs, writes the collecting step as one formula, and shows exactly where independence enters, first in the pair probabilities and then in the variance.

Key terms

Ordered-pair table

Definition Let XX and YY be discrete random variables on the same sample space, each with finitely many possible values. Their ordered-pair table has one row for each possible value xx of XX and one column for each possible value yy of YY. The cell in row xx and column yy stands for the event {X=x,Y=y}\{X = x, Y = y\} and holds its probability P(X=x,Y=y)P(X = x, Y = y), together with the total x+yx + y. Different cells are disjoint events, and their probabilities add to 11. If XX and YY are independent, every cell probability is the product pX(x) pY(y)p_X(x)\,p_Y(y).

In plain words The table records which task produced which count before anything is added. The pair with X=0X = 0 and Y=2Y = 2 and the pair with X=2X = 2 and Y=0Y = 0 give the same total, but they are different outcomes and can have different probabilities.

Example In a constructed model, let XX equal 00, 11 or 22 with probabilities 14\tfrac14, 12\tfrac12 and 14\tfrac14, and let YY equal 00 or 22 with probabilities 34\tfrac34 and 14\tfrac14, independently of XX. Each cell below shows its probability and its total.

y=0y = 0y=2y = 2
x=0x = 0316\tfrac{3}{16}, total 00116\tfrac{1}{16}, total 22
x=1x = 1616\tfrac{6}{16}, total 11216\tfrac{2}{16}, total 33
x=2x = 2316\tfrac{3}{16}, total 22116\tfrac{1}{16}, total 44

For instance, the top left cell has probability 14⋅34=316\tfrac14 \cdot \tfrac34 = \tfrac{3}{16}. The six cell probabilities add to 1616=1\tfrac{16}{16} = 1.

Distribution of a sum

Definition Let XX and YY be discrete random variables on the same sample space. Their sum S=X+YS = X + Y is a discrete random variable, and its PMF is

pS(s)=P(X+Y=s)=∑x+y=sP(X=x,Y=y),\begin{aligned} p_S(s) &= P(X + Y = s) \\[0.4em] &= \sum_{x + y = s} P(X = x, Y = y), \end{aligned}

where the sum runs over all pairs (x,y)(x, y) with xx a possible value of XX, yy a possible value of YY and x+y=sx + y = s. The events {X=x,Y=y}\{X = x, Y = y\} for different pairs are disjoint, so their probabilities add. The formula uses the joint probabilities of the pairs. In general the two separate distributions of XX and YY do not determine pSp_S, and more must be known about how the variables are related, for example that they are independent.

In plain words Group the cells of the table by their total and add the probabilities inside each group. Counting the cells in a group instead of adding their probabilities works when all cells are equally likely, and it can mislead otherwise.

Example In the table above, the total 22 comes from the cells (0,2)(0, 2) and (2,0)(2, 0), so P(S=2)=116+316=14P(S = 2) = \tfrac{1}{16} + \tfrac{3}{16} = \tfrac14. Collecting every total gives the PMF of SS.

ss0011223344
pS(s)p_S(s)316\tfrac{3}{16}616\tfrac{6}{16}416\tfrac{4}{16}216\tfrac{2}{16}116\tfrac{1}{16}

The numerators add to 1616, as they must when every cell is used exactly once. Two cells give the total 22, but the total 11 is more likely, since its one cell has probability 616\tfrac{6}{16}.

Discrete convolution

Definition If XX and YY are independent discrete random variables, the PMF of S=X+YS = X + Y is

pS(s)=∑xpX(x) pY(s−x),p_S(s) = \sum_{x} p_X(x)\, p_Y(s - x),

where xx runs over the possible values of XX, and pY(s−x)=0p_Y(s - x) = 0 whenever s−xs - x is not a possible value of YY. This operation on two PMFs is called discrete convolution, and pSp_S is the convolution of pXp_X and pYp_Y. Once xx and the total ss are fixed, the partner value y=s−xy = s - x is forced, so each compatible pair is counted exactly once.

In plain words For each possible value of the first variable, find the value of the second that completes the total, multiply the two probabilities and add over the first variable. It is the table calculation written as one formula, and the product inside it relies on independence.

Example For the variables of the table, YY takes only the values 00 and 22, so

pS(2)=pX(0) pY(2)+pX(1) pY(1)+pX(2) pY(0)=116+0+316=14.\begin{aligned} p_S(2) &= p_X(0)\,p_Y(2) \\[0.4em] &\quad + p_X(1)\,p_Y(1) \\[0.4em] &\quad + p_X(2)\,p_Y(0) \\[0.4em] &= \tfrac{1}{16} + 0 + \tfrac{3}{16} = \tfrac14 . \end{aligned}

The middle term is 00 because YY never equals 11, and the result matches the two cells collected from the table.

Variance of an independent sum

Definition Let XX and YY be random variables on the same sample space with finite variances. Then E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y], with or without independence. If in addition XX and YY are independent, then

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y).\begin{aligned} \operatorname{Var}(X + Y) &= \operatorname{Var}(X) \\[0.4em] &\quad + \operatorname{Var}(Y). \end{aligned}

For independent XX and YY the standard deviation of the sum is therefore SD⁡(X+Y)=Var⁡(X)+Var⁡(Y)\operatorname{SD}(X + Y) = \sqrt{\operatorname{Var}(X) + \operatorname{Var}(Y)}, which is at most SD⁡(X)+SD⁡(Y)\operatorname{SD}(X) + \operatorname{SD}(Y) and is strictly smaller unless one of the two variances is 00.

In plain words Means add for any two variables with finite means. Variances add for independent variables, because for them the cross term in the next card averages to zero. To combine standard deviations, add the variances first and take the square root at the end.

Example For the independent variables of the table, E[X]=1E[X] = 1 and E[Y]=0⋅34+2⋅14=12E[Y] = 0 \cdot \tfrac34 + 2 \cdot \tfrac14 = \tfrac12, so E[S]=32E[S] = \tfrac32. The deviations of XX are −1-1, 00 and 11, so Var⁡(X)=14+0+14=12\operatorname{Var}(X) = \tfrac14 + 0 + \tfrac14 = \tfrac12, and Var⁡(Y)=4⋅14−(12)2=34\operatorname{Var}(Y) = 4 \cdot \tfrac14 - \big(\tfrac12\big)^2 = \tfrac34, so the rule gives Var⁡(S)=54\operatorname{Var}(S) = \tfrac54. The PMF of SS confirms this, since E[S]=2416=32E[S] = \tfrac{24}{16} = \tfrac32, E[S2]=5616=72E[S^2] = \tfrac{56}{16} = \tfrac72 and 72−94=54\tfrac72 - \tfrac94 = \tfrac54. The standard deviation of SS is 52≈1.118\tfrac{\sqrt{5}}{2} \approx 1.118, smaller than SD⁡(X)+SD⁡(Y)≈0.707+0.866=1.573\operatorname{SD}(X) + \operatorname{SD}(Y) \approx 0.707 + 0.866 = 1.573.

Cross term

Definition Let XX and YY have finite variances, and write DX=X−E[X]D_X = X - E[X] and DY=Y−E[Y]D_Y = Y - E[Y] for their deviations from their means. The deviation of the sum is DX+DYD_X + D_Y, and

(DX+DY)2=DX2+DY2+2DXDY.\begin{aligned} (D_X + D_Y)^2 &= D_X^2 + D_Y^2 \\[0.4em] &\quad + 2D_X D_Y . \end{aligned}

Taking expectations gives

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2E[DXDY].\begin{aligned} &\operatorname{Var}(X + Y) \\[0.4em] &\quad = \operatorname{Var}(X) + \operatorname{Var}(Y) \\[0.4em] &\qquad + 2E[D_X D_Y]. \end{aligned}

The term 2E[DXDY]2E[D_X D_Y] is the cross term. If XX and YY are independent, then E[DXDY]=E[DX] E[DY]=0⋅0=0E[D_X D_Y] = E[D_X]\,E[D_Y] = 0 \cdot 0 = 0, and the variances add. Without independence the cross term can be positive, negative or zero. The average product E[DXDY]E[D_X D_Y] is the covariance of XX and YY, the subject of the lesson Covariance, Correlation and Sums.

In plain words The cross term is twice the average product of the two deviations. A product is positive when both variables fall on the same side of their means and negative when they fall on opposite sides. When the positive products outweigh the negative ones on average, the deviations reinforce each other and the sum spreads more than the two variances alone suggest. When the negative products outweigh the positive ones, the deviations partly cancel and the sum spreads less.

Example Keep XX as before, but now let Y=2Y = 2 exactly when X=2X = 2, and Y=0Y = 0 otherwise. Then P(Y=2)=14P(Y = 2) = \tfrac14 and P(Y=0)=34P(Y = 0) = \tfrac34, the same distribution of YY as before, but now XX and YY are dependent. The sum equals 00, 11 or 44 with probabilities 14\tfrac14, 12\tfrac12 and 14\tfrac14. Its mean is still 32\tfrac32, but E[S2]=12+4=92E[S^2] = \tfrac12 + 4 = \tfrac92, so Var⁡(S)=92−94=94\operatorname{Var}(S) = \tfrac92 - \tfrac94 = \tfrac94 instead of 54\tfrac54. The difference 11 is the cross term. Directly, with DX=X−1D_X = X - 1 and DY=Y−12D_Y = Y - \tfrac12, the product DXDYD_X D_Y equals 12\tfrac12 when X=0X = 0, 00 when X=1X = 1 and 32\tfrac32 when X=2X = 2, so E[DXDY]=18+38=12E[D_X D_Y] = \tfrac18 + \tfrac38 = \tfrac12 and the cross term is 2⋅12=12 \cdot \tfrac12 = 1. The two separate distributions are unchanged, yet the distribution and the variance of the sum are different.

Check yourself

  1. Two independent selections are each uniform on {0,1,2}\{0, 1, 2\}, and TT is their sum. Find the PMF of TT, its mean and its variance.
Show the answer

The nine ordered pairs are equally likely, each with probability 19\tfrac19, so here counting cells is valid. The totals 00, 11, 22, 33 and 44 come from 11, 22, 33, 22 and 11 pairs, so TT takes these values with probabilities 19\tfrac19, 29\tfrac29, 39\tfrac39, 29\tfrac29 and 19\tfrac19. The mean is 22 by symmetry, or 1+11 + 1 by linearity. One selection has second moment 0+1+43=53\tfrac{0 + 1 + 4}{3} = \tfrac53 and variance 53−1=23\tfrac53 - 1 = \tfrac23, so independence gives Var⁡(T)=23+23=43\operatorname{Var}(T) = \tfrac23 + \tfrac23 = \tfrac43. As a check from the PMF, E[T2]=0+2+12+18+169=163E[T^2] = \tfrac{0 + 2 + 12 + 18 + 16}{9} = \tfrac{16}{3} and 163−22=43\tfrac{16}{3} - 2^2 = \tfrac43.

  1. A count XX equals 00 or 11 with probabilities 0.70.7 and 0.30.3, and an independent count YY equals 00, 11 or 22 with probabilities 0.20.2, 0.50.5 and 0.30.3. Use discrete convolution to find the PMF of S=X+YS = X + Y, say which total is most likely, and check that Var⁡(S)=Var⁡(X)+Var⁡(Y)\operatorname{Var}(S) = \operatorname{Var}(X) + \operatorname{Var}(Y).
Show the answer

For each total, add pX(x) pY(s−x)p_X(x)\,p_Y(s - x) over x=0x = 0 and x=1x = 1. This gives pS(0)=0.7⋅0.2=0.14p_S(0) = 0.7 \cdot 0.2 = 0.14, pS(1)=0.7⋅0.5+0.3⋅0.2=0.41p_S(1) = 0.7 \cdot 0.5 + 0.3 \cdot 0.2 = 0.41, pS(2)=0.7⋅0.3+0.3⋅0.5=0.36p_S(2) = 0.7 \cdot 0.3 + 0.3 \cdot 0.5 = 0.36 and pS(3)=0.3⋅0.3=0.09p_S(3) = 0.3 \cdot 0.3 = 0.09, which add to 11. The most likely total is 11. For the variances, E[X]=E[X2]=0.3E[X] = E[X^2] = 0.3 gives Var⁡(X)=0.3−0.32=0.21\operatorname{Var}(X) = 0.3 - 0.3^2 = 0.21, and E[Y]=0.5+0.6=1.1E[Y] = 0.5 + 0.6 = 1.1 with E[Y2]=0.5+1.2=1.7E[Y^2] = 0.5 + 1.2 = 1.7 gives Var⁡(Y)=1.7−1.12=0.49\operatorname{Var}(Y) = 1.7 - 1.1^2 = 0.49. From the PMF, E[S]=0.41+0.72+0.27=1.4E[S] = 0.41 + 0.72 + 0.27 = 1.4, which equals 0.3+1.10.3 + 1.1, and E[S2]=0.41+1.44+0.81=2.66E[S^2] = 0.41 + 1.44 + 0.81 = 2.66, so Var⁡(S)=2.66−1.96=0.70=0.21+0.49\operatorname{Var}(S) = 2.66 - 1.96 = 0.70 = 0.21 + 0.49.

  1. Let XX equal −1-1 or 11 with probability 12\tfrac12 each, so Var⁡(X)=1\operatorname{Var}(X) = 1. In each case below YY has the same distribution as XX. Find Var⁡(X+Y)\operatorname{Var}(X + Y) when YY is independent of XX, when Y=XY = X, and when Y=−XY = -X. What does the comparison show?
Show the answer

With independence, the variances add to 1+1=21 + 1 = 2. With Y=XY = X, the sum is 2X2X, whose variance is 22⋅1=42^2 \cdot 1 = 4, so the cross term is 22. With Y=−XY = -X, the sum is 00 with probability 11, whose variance is 00, so the cross term is −2-2. In all three cases XX and YY have the same separate distributions, yet the variance of the sum is 22, 44 or 00. The variance of a sum depends on how the variables are related. The variances add exactly when the cross term is zero, and independence is one condition that guarantees this.

How this lesson connects