1.6 Sums and Other Functions of Random Variables: Example 1. We Roll A Die Twice. Let X
1.6 Sums and Other Functions of Random Variables: Example 1. We Roll A Die Twice. Let X
Example 1. We roll a die twice. Let X1 = result of first roll and X2 = result of second roll. Let T be the
sum of the two rolls. Then T is the sum of X1 and X2, i.e. T = X1 + X2. In section 1.3 we found the
probablility mass function of T.
Example 2. We flip a coin n times. Let Xk = 1 if the kth flip is a head and Xk = 0 it the kth flip is a tail. Let
N = the number of heads in the n flips. Then N = X + + X . Recall from section 1.6 that N has a
1 n
binomial distribution.
In general, we want to find the probablility mass function fS(s) of the sum S = X + Y of two random variables
X and Y or S = X + + X of n random variables X , …, X .
1 n 1 n
Consider the case S = X + Y and let X = {x0, x1, …, xn} and Y = {y0, y1, …, ym} be the set of values X and
Y take on. Then S = {s = x + y: x X and y Y} is the set of values S takes on. If s is one of these
values then
where fX,Y(x, y) is the joint probability mass function of X and Y and in the sums we are summing over those
pairs (x, y) where x X and y Y and x + y = s. We can write this as
n
(2) fS(s) = f(x, s - x) = f(xi, s – xi)
x X i=0
with the understanding that f(x, s - x) = 0 if the pair x is not in X or s – x is not in Y.
Example 3. Mary is making two investment, one the Angolian Oil Company and the other in Speedy
Computer Corporation. Suppose
1. The profit X from the Angolian Oil investment will be either $0, $1000 or $2000
2. The profit Y from the Speedy Computer investment will be either $0, $1000 or $2000.
3. The joint probability mass function fX,Y(x, y) is given by the following table.
1.6 - 1
For simplicity we are measuring the values of X and Y in units of thousands of dollars so X = 1 or Y = 1
means $1000.
We want to find the probability mass function fS(s) of the sum S = X + Y of the profits from the two
investments.
Solution. Here is the same table where we also include the value of S for each combination of values of X
and Y.
From the table we can find the pairs (x, y) that have given sums. One has
fS(0) = f(0, 0) = 0.05
fS(1) = f(0, 1) + f(1, 0) = 0.10 + 0.15 = 0.25
fS(2) = f(0, 2) + f(1, 1) + f(2, 0) = 0.15 + 0.20 + 0.10 = 0.45
fS(3) = f(1, 2) + f(2, 1) = 0.10 + 0.10 = 0.20
fS(4) = f(2, 2) = 0.05
Note that to compute fS(s) we are summing the diagonal of the above table where X + Y = s.
Finding the probability mass function for some other function of one or two random variables is similar to
the sum. In the table for the joint probability mass function one simply replaces the values of the sum by
the value of whatever function of the two random variables we are considering.
Things are a little simpler in the case where X and Y are independent. Then f(x, y) = fX(x)fY(y) so (2) can be
rewritten as
n
(3) fS(s) = fX(xi)fY(s - xi)
i=0
A sum of this form is often called the convolution of the functions fX(x) and fY(y). If we let gs(y) = fY(s – y),
then (3) can be written as
n
(4) fS(s) = fX(xi)gs(xi) = <fX, gs >
i=0
1.6 - 2
The term <fX, gs > on the right is the inner product of two vectors. The first, fX, is the vector of fX(x) values
in increasing order of the value of x. The second gs is the vector of fY(y) values in decreasing order of the
value of y and shifted so the value of f(x) is in the same position as gs(x) = fY(s – x). Both vectors are
padded on the left and/or right so they are the same length.
Example 4. In Example 3 suppose that the assumptions are changed to the following.
1. The profit X from the Angolian Oil investment will be either $0, $1000 or $2000 with
probabilities 0.3, 0.5 and 0.2 respectively.
2. The profit Y from the Speedy Computer investment will be either $0, $1000 or $2000
with probabilities 0.1, 0.6 and 0.3 respectively.
3. The return from the two investments are independent.
Solution. The vector fX is (0.3, 0.5, 0.2). The corresponding vector of x values is (0, 1, 2). The vector of
fY(y) values in decreasing order of the value of y is (0.3, 0.6, 0.1). The corresponding vector of y values is
(2, 1, 0). To compute fS(0) we must align the vectors (0.3, 0.5, 0.2) and (0.3, 0.6, 0.1) so that corresponding
elements correspond to the sum of the x and y values being 0. This alignment is when the 0.3 at the
beginning of the first vector is over the 0.1 at the end of the second, i.e. 0.3 0.6 0.1 0
0 0 0.3 0.5 0.2
0 . Now we
multiply corresponding component and add.
To compute fS(1) we shift the bottom vector one position to the right so that it is 0.3 0.6 0.1 0 and
0 0.3 0.5 0.2
To compute fS(2) we shift the bottom vector one more position to the right so that it is 0.3 0.6 0.1 and
0.3 0.5 0.2
repeat.
1.6 - 3
k
fX(i) fY(k-i) for k = 0, … , m
i=0
min{n, k} k
(5) fS(k) = fX(i) fY(k - i) = fX(i) fY(k-i) for k = m, … , n
i = max{0, k-m} i = k-m
n
fX(i) fY(k-i) for k = n, … , n+m
i = k-m
Example 5. John is very lucky and when ever he buys a raffle ticket he either makes a profit of $0, $1 or
$2 each with probability 1/3. Suppose he buys two raffle tickets and the outcome of the two tickets are
independent of each other. Let S be the amount of profit he makes on the two tickets. Find the probability
mass function of S.
Solution. T = U + V where U is the profit on the first ticket and V is the profit on the second ticket. Then
U and V are independent and both have probability mass function f given by f(0) = f(1) = f(2) = 1/3. Then
(5) becomes
k
1
k for k = 0, 1, 2
f(i) f(k-i) for k = 0, 1, 2 9 k + 1 for k = 0, 1, 2
f (k) = 2
9
= 5-k
i=0 i=0
(6) T = 2
9
i =k-2f(i) f(k-i) for k = 2, 3, 4
1
9
for k = 2, 3, 4
for k = 2, 3, 4
i = k-2
k
(7) fS(k) = fX(i) fY(k - i)
i=0
Example 6. Suppose that X and Y have Poisson distributions with means and respectively. Find the
probability mass function of S = X + Y.
i e - j e -
Solution. One has fX(i) = for i = 0, 1, 2, …. and fY(j) = for j = 0, 1, 2, …. . Using (5) one has
i! j!
k k
where we have used the binomial theorem discussed at the end of section 1.6. So S is again a Poisson
random variable with mean + .
We can extend (5) to the case where the values of X and Y are equally spaced with the same spacing h, i.e.
X = {a + ih: i = 0, … , n} and Y = {b + jh: j = 0, … , m} for some a and b and m n. Then
S = {a + b + kh: k = 0, … , n + m}. Then the random variables U = (X – a)/h and V = (Y – b)/h have the
property that U = {0, 1, … , n} and V = {0, 1, … , m} so we can apply (5) to them to get the probability
1.6 - 4
mass funtion of U + V. Then X + Y = a + b +h(U + V) and we can get the probability mass function of
X + Y from that of U + V.
Example 7. Suppose that each day a newsstand either makes a profit of $100, $200 or $300 each with
probability 1/3 and each day is independent of any other day. Let S be the amount of profit the newsstand
makes in a two day period. Find the probability mass function of S.
Solution. S = X + Y where X is the profit the newsstand makes in the first day and Y is the amount of profit
in the second day. Let U = (X – 100)/100 and V = (Y – 100)/100. Then U and V have the same probability
mass function as in Example 5. So the sum T = U + V has probability mass function given by (6). Then
X + Y = 200 +100T so the probability mass function of S = X + Y is
As we have seen, finding the probability mass function of the sum of just two random variables requires
some effort even in the case where they are independent and have the same distribution. Finding the
probability mass function of the sum S = X + + X of n random variables X , …, X is usually more
1 n 1 n
difficult and it may not be possible to find a simple formula for it. One case which one can handle is the
sum of independent Bernoulli random variables which was seen in section 1.4 to have a binomial
distribution. As one can see from Example 6, the sum of independent Poisson random variables is again
Poisson with the mean being the sum of the means. Sometimes finding the probability mass function of a
sum of random variables is easier using moment generating functions. The moment generating function of a
n
random variable X is M(t) = etxifX(xi) and how they are used is discussed in various books.
i=0
1.6 - 5