Skip to content

Sums of random variables

Slide one die’s chances across the other’s to build the triangle of a two-dice total, and see why spreads add as squares, not directly.

Helps to know firstCovariance and correlation

Helps to know first
This topic

First, the picture

Throw two dice and add them. Why is 7 the most likely total? Watch one die’s chances slide across the other’s.

Why two dice make a triangle

One die, the other turned round and slid along it: the bars that line up give a total.

One die on top. Below it, the other die turned round, which slides along: where bars line up, their faces add to the same total.

total T
–
chance of T
–
0.00 / 13.15 s
Describe this picture

Three rows of bars on one axis. The top row is one die, “first die”: six bars of height 16\tfrac16 over the faces 1 to 6. Under it, “second die, turned round”: the other die with its faces in reverse order, which slides along to the right. For each total TT from 2 to 12, the turned die stops where its faces add to TT with the faces above; the bars that line up are lit, joined by dotted lines, and their products, 136\tfrac1{36} each, stack into one bar of the bottom row, “chance of the total”, labelled with its count out of 36. As TT runs from 2 to 12 that row grows into a triangle: 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, each out of 36, with its peak at 7. Readouts give TT and its chance. When the clip has finished, a slider, “Total of the two dice, T”, moves the turned die, and the lit bars and the caption follow; at T=4T=4 the caption lists (1,3)(1,3), (2,2)(2,2) and (3,1)(3,1), a chance of 3/363/36.

Counting the ways

Why does 7 come up more often than 2? There is only one way to throw 2: a 1 and a 1. There are six ways to throw 7: 1 and 6, 2 and 5, 3 and 4, 4 and 3, 5 and 2, 6 and 1. Each of the 36 pairs has chance 136\tfrac1{36}, so Pr⁡{7}=636=16\Pr\{7\}=\tfrac6{36}=\tfrac16, and Pr⁡{2}=136\Pr\{2\}=\tfrac1{36}.

The picture does the same count with the chances themselves. For a total TT, the first die shows some kk and the second shows T−kT-k. If the dice are independent, the chance of that pair is pX(k) pY(T−k)p_X(k)\,p_Y(T-k). Add over every kk:

pX+Y(T)=∑kpX(k) pY(T−k).p_{X+Y}(T)=\sum_k p_X(k)\,p_Y(T-k).

That sum is a convolution, written pX+Y=pX∗pYp_{X+Y}=p_X*p_Y. The second die is reversed because as kk goes up, T−kT-k goes down. After the clip, drag the total TT to 4: three pairs line up, (1,3)(1,3), (2,2)(2,2) and (3,1)(3,1), so Pr⁡{4}=336\Pr\{4\}=\tfrac3{36}.

Means add, always

The mean of a sum is the sum of the means:

E{X+Y}=E{X}+E{Y}.\mathbb{E}\{X+Y\}=\mathbb{E}\{X\}+\mathbb{E}\{Y\}.

This holds whether or not XX and YY are independent, because an average of sums is a sum of averages. Two dice have mean 3.5+3.5=73.5+3.5=7, the peak of the triangle.

Variances add, if uncorrelated

Spreads are different. Square the distance of the sum from its mean, and multiply out:

((X−μX)+(Y−μY))2=(X−μX)2+(Y−μY)2+2 (X−μX)(Y−μY).\begin{aligned} \big((X-\mu_X)+(Y-\mu_Y)\big)^2&=(X-\mu_X)^2+(Y-\mu_Y)^2\\ &\quad+2\,(X-\mu_X)(Y-\mu_Y). \end{aligned}

Take the mean of each part. The first two are the variances, and the last is twice the covariance of Covariance and correlation:

Var{X+Y}=Var{X}+Var{Y}+2 Cov{X,Y}.\mathrm{Var}\{X+Y\}=\mathrm{Var}\{X\}+\mathrm{Var}\{Y\}+2\,\mathrm{Cov}\{X,Y\}.

When XX and YY are uncorrelated, and in particular when they are independent, the covariance is 0 and the variances add. Two dice have variance 3512+3512=356=5.833\tfrac{35}{12}+\tfrac{35}{12}=\tfrac{35}{6}=5.833, so the total has spread 2.4152.415.

The correlation matters. Take two variables, each with spread 1. If ρXY=0.5\rho_{XY}=0.5, the sum has variance 1+1+2⋅0.5=31+1+2\cdot0.5=3. If ρXY=1\rho_{XY}=1, they always move together and the variance is 4. If ρXY=−1\rho_{XY}=-1, each cancels the other and the variance is 0: the sum never moves.

Spreads add as squares

So spreads do not add; variances do. Two independent errors with spreads 3 and 4 give a total with variance 9+16=259+16=25, so a spread of 5, not 7. It is the right-angle rule for the sides of a triangle, with spreads as the sides.

The same goes for a difference. Var{X−Y}=Var{X}+Var{Y}−2 Cov{X,Y}\mathrm{Var}\{X-Y\}=\mathrm{Var}\{X\}+\mathrm{Var}\{Y\}-2\,\mathrm{Cov}\{X,Y\}, so for independent variables the variances still add: the difference of two independent unit-variance variables has variance 2, not 0.

And it explains a fact about dice. Adding a second die doubles the variance, so the spread grows only by 2\sqrt2, about 1.41 times. That slow growth is where the σX/n\sigma_X/\sqrt n of The law of large numbers comes from.

How errors spread

A measured length is 20.0±0.120.0\pm0.1 cm and a width is 10.0±0.110.0\pm0.1 cm, where each ±0.1\pm0.1 is a spread and the two errors are independent. What is the spread of the area, 20×10=20020\times10=200 cm²?

A small error ε\varepsilon in the length changes the area by about 10 ε10\,\varepsilon, because the area is length times 10. A small error in the width changes it by about 2020 times that error. The two changes are independent, so their variances add:

σA2≈(10⋅0.1)2+(20⋅0.1)2=1+4=5,σA=2.236 cm2.\sigma_A^2\approx(10\cdot0.1)^2+(20\cdot0.1)^2=1+4=5,\qquad \sigma_A=2.236\ \text{cm}^2 .

In general, if a result ff changes by ckc_k for each unit change in input kk, and the inputs have independent errors with spreads σk\sigma_k, then σf2≈∑kck2σk2\sigma_f^2\approx\sum_k c_k^2\sigma_k^2. This is called propagation of error. It holds well when the errors are small.

Worked example

  1. Two dice. Mean 7, variance 35/6=5.83335/6=5.833, spread 2.4152.415, Pr⁡{7}=16\Pr\{7\}=\tfrac16.
  2. A total of 4. Pr⁡{4}=336\Pr\{4\}=\tfrac3{36}.
  3. Correlated parts. Spreads 1 and 1: variance of the sum 3 at ρXY=0.5\rho_{XY}=0.5, 4 at ρXY=1\rho_{XY}=1, 0 at ρXY=−1\rho_{XY}=-1.
  4. Spreads 3 and 4, independent. The sum has spread 5, not 7.
  5. A difference. For independent XX and YY with variance 1 each, Var{X−Y}=2\mathrm{Var}\{X-Y\}=2.
  6. A rectangle. 20.0±0.120.0\pm0.1 by 10.0±0.110.0\pm0.1: area 200, spread 5=2.236\sqrt5=2.236.

Where you’ll meet this

An amplifier with two independent noise sources has a total noise power equal to the sum of the two powers, because power is a variance. A machine part built from a stack of pieces, each with a small error in thickness, has a total error whose spread grows like the square root of the number of pieces, not in proportion to it. Engineers rely on this when they set tolerances.

In signal processing · convolution

The sum of this page is the convolution of Discrete convolution: there a filter slides a reversed impulse response along a signal, and here one die’s chances slide along the other’s. The page Finite word-length effects adds up independent rounding errors as variances, exactly as above.

Where this leads · convolution as a matrix

A convolution is also a matrix times a vector, with shifted copies of one list as the columns. The page A matrix moves the plane in the linear algebra course shows that view.

Reference card

QuantityFormulaNotes
Mean of a sumE{X+Y}=E{X}+E{Y}\mathbb{E}\{X+Y\}=\mathbb{E}\{X\}+\mathbb{E}\{Y\}always
Variance of a sumVar{X}+Var{Y}+2 Cov{X,Y}\mathrm{Var}\{X\}+\mathrm{Var}\{Y\}+2\,\mathrm{Cov}\{X,Y\}the covariance term vanishes if uncorrelated
SpreadsσX+Y=σX2+σY2\sigma_{X+Y}=\sqrt{\sigma_X^2+\sigma_Y^2}independent; 3 and 4 give 5
Chances of a sumpX+Y(T)=∑kpX(k) pY(T−k)p_{X+Y}(T)=\sum_k p_X(k)\,p_Y(T-k)convolution, independent
Two dice1,2,…,6,…,2,11,2,\dots,6,\dots,2,1 over 36peak at 7
Error propagationσf2≈∑kck2σk2\sigma_f^2\approx\sum_k c_k^2\sigma_k^2small independent errors

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look