





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






The expectation or expected value of a random variable is a single number that tells you a lot about the behavior of the variable. Roughly, the expectation is the average value, where each value is weighted according to the probability that it comes up. Formally, the expected value of a random variable R defined on a sample space S is:
Ex (R) = R(w) Pr (w) wāS
To appreciate its signficance, suppose S is the set of students in a class, and we select a student uniformly at random. Let R be the selected studentās exam score. Then Ex (R) is just the class averageā the first thing everyone want to know after getting their test back! In the same way, expectation is usually the first thing one wants to determine about any random variable.
Letās work through an example. Let R be the number that comes up on a fair, sixsided die. Then the expected value of R is:
ļæ½^6 1 Ex (R) = k k=1^6 1 1 1 1 1 1 = 1 Ā· + 2 Ā· + 3 Ā· + 4 Ā· + 5 Ā· + 6 Ā· 6 6 6 6 6 6 7 = 2
This calculation shows that the name āexpected valueā is a little misleading; the random variable might never actually take on that value. You canāt roll a 312 on an ordinary die!
Dan, Eric, and Nick decide to play a fun game. Each player puts $2 on the table and secretly writes down either āheadsā or ātailsā. Then one of them tosses a fair coin. The $6 on the table is divided evenly among the players who correctly predicted the outcome of the coin toss. If everyone guessed incorrectly, then everyone takes their money back. After many repetitions of this game, Dan has lost a lot of moneyā more than can be explained by bad luck. Whatās going on?
A tree diagram for this problem is worked out below, under the assumptions that everyone guesses correctly with probability 1 / 2 and everyone is correct independently.
1/
1/
1/
1/
1/
1/
1/
1/
probability
Dan right?
Eric right?
Nick right? Danās payoff
Y
N
Y
Y
Y
Y
Y
Y
N
N
N
N
N
N $
ā$
ā$
ā$
$
$
$
$
1/
1/
1/ 1/ 1/
1/ 1/
1/ 1/
1/ 1/ 1/
1/
1/
In the āpayoffā column, weāre accounting for the fact that Dan has to put in $2 just to play. So, for example, if he guesses correctly and Eric and Nick are wrong, then he takes all $ on the table, but his net profit is only $4. Working from the tree diagram, Danās expected payoff is:
Ex (payoff) = 0 Ā· + 1 Ā· + 1 Ā· + 4 Ā· + (ā2) Ā· + (ā2) Ā· + (ā2) Ā· + 0 Ā· 8 8 8 8 8 8 8 8 = 0
So the game perfectly fair! Over time, he should neither win nor lose money.
The trick is that Nick and Eric are collaborating; in particular, they always make oppo site guesses. So our assumption everyone is correct independently is wrong; actually the events that Nick is correct and Eric is correct are mutually exclusive! As a result, Dan can never win all the money on the table. When he guesses correctly, he always has to split his winnings with someone else. This lowers his overall expectation, as the corrected tree diagram below shows:
This is a lot like our betting game, except that there are more players and more choices. Chernoff discovered that a small set of numbers was selected by a large fraction of the populationā apparently many people think the same way. It was as if the players were collaborating to lose! If any one of them guessed correctly, then theyād have to split the pot with many other players. By selecting numbers uniformly at random, Chernoff was unlikely to get one of these favored sequences. So if he won, heād likely get the whole pot! By analyzing actual state lottery data, he determined that he could win an average of 7 cents on the dollar this way!
There are some other ways of writing the definition of expectation. Sometimes using one of these other formulations can make computing an expectation a lot easier. One option is to group together all outcomes on which the random variable takes on the same value.
Theorem 1. (^) ļæ½ Ex (R) = x Ā· Pr (R = x) xā range(R)
Proof. Weāll transform the left side into the right. Let [R = x] be the event that R = x.
Ex (R) = R(w) Pr (w) wāS = R(w) Pr (w) xā range(R) wā[R=x] = x Pr (w) xā range(R) wā[R=x] ā
= āx
Ā· Pr (w)ā xā range(R) wā[R=x] = x Ā· Pr (R = x) xā range(R)
On the second line, we break the single sum into two. The outer sum runs over all possible values x that the random variable takes on, and the inner sum runs over all outcomes taking on that value. Thus, weāre still summing over every outcome in the sample space exactly once. On the last line, we use the definition of the probability of the event [R = x].
Corollary 2. If R is a naturalvalued random variable, then:
ā Ex (R) = i Ā· Pr (R = i) i=
There is another way to write the expected value of a random variable that takes on values only in the natural numbers, N = { 0 , 1 , 2 ,... }.
Theorem 3. If R is a naturalvalued random variable, then:
ā Ex (R) = Pr (R > i) i=
Proof. Consider the sum:
Pr (R = 1) + Pr (R = 2) + Pr (R = 3) + Ā· Ā· Ā·
The columns sum to 1 Ā· Pr (R = 1), 2 Ā· Pr (R = 2), 3 Ā· Pr (R = 3), etc. Thus, the whole sum is equal to: ā i Ā· Pr (R = i) = Ex (R) i=
Here, weāre using Corollary 2. On the other hand, the rows sum to Pr (R > 0), Pr (R > 1), Pr (R > 2), etc. Thus, the whole sum is also equal to:
ā Pr (R > i) i=
These two expressions for the whole sum must be equal, which proves the theorem.
Letās look at a problem where one of these alternative definitions of expected value is particularly helpful. A computer program crashes at the end of each hour of use with probability p, if it has not crashed already. What is the expected time until the program crashes?
If we let R be the number of hours until the crash, then the answer to our problem is Ex (R). This is a naturalvalued variable, so we can use the formula:
ā Ex (R) = Pr (R > i) i=
Proof. Let S be the sample space.
Ex (R 1 + R 2 ) = (R 1 (w) + R 2 (w)) Ā· Pr (w) wāS = R 1 (w) Ā· Pr (w) + R 2 (w) Ā· Pr (w) wāS wāS = Ex (R 1 ) + Ex (R 2 )
Linearity of expectation generalizes to any finite collection of random variables by induction:
Corollary 5. For any random variables R 1 , R 2 ,... , Rk,
Ex (R 1 + R 2 + Ā· Ā· Ā· + Rk) = Ex (R 1 ) + Ex (R 2 ) + Ā· Ā· Ā· + Ex (Rk)
The reason linearity of expectation is so wonderful is that, unlike many other probabil ity rules, the random variables are not required to be independent. This probably sounds like a āyeah, whateverā technicality right now. But when you give an analysis using linearity of expectation, someone will almost invariably say, āNo, youāre wrong. There are all sorts of complicated dependencies here that youāre ignoring.ā But thatās the magic of linearity of expectation: you can ignore such dependencies!
What is the expected value of the sum of two fair dice?
Let the random variable R 1 be the number on the first die, and let R 2 be the number on the second die. At the start of these Notes, we showed that the expected value of one die is 312. We can find the expected value of the sum using linearity of expectation:
Ex (R 1 + R 2 ) = Ex (R 1 ) + Ex (R 2 ) 1 1 = 3 + 3 2 2 = 7
Notice that we did not have to assume that the two dice were independent. The expected sum of two dice is 7, even if they are glued together! (This is provided that gluing some how does not change weights to make the individual dice unfair.)
Proving that the expected sum is 7 with a tree diagram would be hard; there are 36 cases. And if we did not assume that the dice were independent, the job would be a nightmare!
There is a dinner party where n men check their hats. The hats are mixed up during dinner, so that afterward each man receives a random hat. In particular, each man gets his own hat with probability 1 /n. What is the expected number of men who get their own hat?
Without linearity of expectation, this would be a very difficult question to answer. We might try the following. Let the random variable R be the number of men that get their own hat. We want to compute Ex (R). By the definition of expectation, we have:
ā Ex (R) = k Ā· Pr(R = k) k=
Now weāre in trouble, because evaluating Pr(R = k) is a mess and we then need to substitute this mess into a summation. Furthermore, to have any hope, we would need to fix the probability of each permutation of the hats. For example, we might assume that all permutations of hats are equally likely.
Now letās try to use linearity of expectation. As before, let the random variable R be the number of men that get their own hat. The trick is to express R as a sum of indicator variables. In particular, let Ri be an indicator for the event that the ith man gets his own hat. That is, Ri = 1 is the event that he gets his own hat, and Ri = 0 is the event that he gets the wrong hat. The number of men that get their own hat is the sum of these indicators: R = R 1 + R 2 + Ā· Ā· Ā·+ Rn
These indicator variables are not mutually independent. For example, if n ā 1 men all get their own hats, then the last man is certain to receive his own hat. But, since we plan to use linearity of expectation, we donāt have worry about independence!
Letās take the expected value of both sides of the equation above and apply linearity of expectation:
Ex (R) = Ex (R 1 + R 2 + Ā· Ā· Ā· + Rn) = Ex (R 1 ) + Ex (R 2 ) + Ā· Ā· Ā· + Ex (Rn)
All that remains is to compute the expected value of the indicator variables Ri. Weāll use an elementary fact that is worth remembering in its own right:
Fact 1. The expected value of an indicator random variable is the probability that the indicator is
Proof.
Ex (I) = 1 Ā· Pr (I = 1) + 0 Ā· Pr (I = 0) = Pr (I = 1)