Sub topic 12
Expected Value of a Simple Game
This chapter assumes you can compute classical probabilities, use the complement rule, and count with combinations. It also assumes you can read a probability tree. Expected value takes these skills and answers a different question: what happens on average if a random process is repeated many times?
What expected value means
A random quantity takes different numerical values with different probabilities. Examples are the number on a die, the money won in a game, or the number of red balls in a draw. The expected value of such a quantity X is the sum of each value multiplied by its probability:
E(X) = x1·p1 + x2·p2 + ... + xn·pn
The probabilities must add up to 1. If they don't, a case is missing or a probability is wrong. Check this before you do anything else.
The expected value of one fair die roll is the sum of each face times 1/6:
from fractions import Fraction
print(sum(Fraction(k, 6) for k in range(1, 7))) # 7/2The result 7/2 = 3.5 shows two properties.
- The expected value need not be a value the quantity can actually take. A die never shows 3.5.
- It is a long-run average, not a prediction for one trial. Over thousands of rolls, the mean of the results settles near 3.5.
Expected value is also not the most likely outcome. A die has no single most likely face, yet it still has an expected value.
Setting up a game
Most CAT questions on this topic describe a game with a payoff for each outcome. Use this routine:
- List the outcomes and group them by payoff.
- Find the probability of each group, using the methods from earlier chapters.
- Check that the probabilities sum to 1.
- Multiply each payoff by its probability and add the products.
The payoff must be the net amount for that outcome. A loss is negative. An entry fee is subtracted from every outcome, including the winning ones.
Worked example: a die game
You roll a fair die. If the face is even, you receive that many rupees. If it is odd, you receive nothing. What is the expected receipt, and what entry fee makes the game fair?
The faces 2, 4 and 6 pay ₹2, ₹4 and ₹6. The other faces pay ₹0. Each face has probability 1/6.
E = (2 + 4 + 6)/6 = 12/6 = ₹2
A game is fair when its expected net gain is zero. The fair entry fee is therefore ₹2. If the fee is ₹5, the expected net gain is 2 − 5 = −₹3 per play.
from fractions import Fraction
gross = sum(Fraction(face, 6) for face in range(1, 7) if face % 2 == 0)
for fee in (2, 5):
print(fee, gross - fee) # 2 0 then 5 -3Linearity of expectation
Linearity of expectation is the most useful time-saver in this chapter. For any random quantities X and Y, E(X + Y) = E(X) + E(Y). It also holds for a constant multiple: E(cX) = c·E(X). Linearity holds even when X and Y are dependent. You do not need the joint distribution.
For two dice, the sum has 11 possible values with unequal probabilities. Linearity skips all that:
E(sum) = 3.5 + 3.5 = 7
Indicator variables
An indicator is a quantity that equals 1 if an event happens and 0 if it does not. Its expected value is 1·p + 0·(1 − p) = p, the probability of the event.
To count something, write the count as a sum of indicators and add their probabilities. Take the bag from the draws chapter: 5 red and 3 blue balls, with 2 drawn without replacement. What is the expected number of red balls?
Let the indicator for draw i be 1 if draw i is red. By symmetry, each draw is red with probability 5/8, even though the second draw depends on the first. So the expected number is 2 · 5/8 = 5/4.
You can confirm this with the full distribution. It uses the combination counts from the first chapter:
from math import comb
from fractions import Fraction
# Number of red balls k in 2 draws from 5 red and 3 blue, without replacement.
dist = {k: Fraction(comb(5, k) * comb(3, 2 - k), comb(8, 2)) for k in range(3)}
print(dist) # probabilities 3/28, 15/28, 5/14
print(sum(dist.values())) # 1
print(sum(k * p for k, p in dist.items())) # 5/4The distribution method needs three probabilities. The indicator method needs one multiplication. In an exam, prefer the indicator method whenever the question asks for an expected count.
Binomial counts
For n independent trials with success probability p, the number of successes is a sum of n indicators. Its expected value is np. For 4 rolls of a die, the expected number of sixes is 4 · 1/6 = 2/3. You never need to sum over the binomial probabilities.
Expected waiting time
Sometimes the question asks how many trials are needed until the first success. If each trial succeeds with probability p, the expected number of trials is 1/p.
For a die and the first six, the expected number of rolls is 6. A short argument shows why. Let E be the expected number of rolls. You always roll once. With probability 5/6 you fail and are back at the start. So:
E = 1 + (5/6)E, which gives E/6 = 1 and E = 6.
This "restart" equation works for many other problems. Write E in terms of itself and solve. Take rolling until a 5 or a 6 appears. Then p = 1/3, so the expected number of rolls is 3.
import random
random.seed(7)
def rolls_until_six():
count = 0
while True:
count += 1
if random.randint(1, 6) == 6:
return count
trials = 100_000
print(sum(rolls_until_six() for _ in range(trials)) / trials) # close to 6The printed average is close to 6, not exactly 6, because it is a simulation.
Common errors and edge cases
| Mistake | Why it is wrong | Fix |
|---|---|---|
| Using gross payoff when there is an entry fee | The fee is paid in every outcome | Subtract the fee from every outcome, or subtract it once from the total |
| Probabilities that do not sum to 1 | An outcome is missing or double counted | Add the probabilities before multiplying |
| Treating a loss as positive | The sign decides whether the game favours you | Write losses as negative numbers |
| Averaging the payoffs without weights | The outcomes are not equally likely | Weight each payoff by its probability |
| Using np for draws that are not independent and then using p wrongly | Without replacement, p changes between draws | Use indicators with the symmetric probability, as in the bag example |
| Reading E(X) as "what will happen" | E(X) describes the long-run average | State the result as "on average" |
Two more cautions apply.
- E(XY) = E(X)·E(Y) only when X and Y are independent. Linearity for sums has no such condition, but products do.
- E(X²) is not (E(X))². For a die, E(X²) = 91/6, while (E(X))² = 49/4. The two differ, so do not square the average.
Choosing a method in the exam
Decide quickly which route to take:
- Is the quantity a count of successes? Use indicators or np.
- Is it a waiting time for the first success? Use 1/p or the restart equation.
- Does it have a few distinct payoffs? Use the payoff table.
- Does the question ask "is the game fair" or "what fee"? Set the expected net gain to zero and solve for the fee.
A negative-marking check
Negative marking is a common CAT-style setting. A test gives +3 for a correct answer and −1 for a wrong one. A student guesses one question with 4 equally likely options:
E = 3 · 1/4 + (−1) · 3/4 = 0
Guessing gains nothing on average. With 5 options, E = 3/5 − 4/5 = −1/5, so a blind guess loses marks on average. If the student can eliminate one option and guess among the remaining 4, the guess has expected value 0. If the student can eliminate two options, the guess has 3 options and E = 3/3·... computed properly: 3 · 1/3 − 1 · 2/3 = 1/3, which is positive.
Exercise
A card is drawn from a standard 52-card deck. You win ₹10 for an ace, ₹5 for a jack, queen or king, and lose ₹2 for any other card. What is the expected net gain?
Show answer
There are 4 aces, 12 face cards (J, Q, K) and 36 other cards. E = (4·10 + 12·5 − 36·2)/52 = (40 + 60 − 72)/52 = 28/52 = 7/13, about ₹0.54 per play in your favour.
Exercise
A multiple-choice test gives +3 for a correct answer and −1 for a wrong answer, and each question has 5 options. A student guesses on 20 questions at random. What is the expected total score?
Show answer
For one guess, E = 3 · 1/5 − 1 · 4/5 = −1/5. By linearity, 20 guesses give 20 · (−1/5) = −4 marks.
Exercise
A fair die is rolled repeatedly until a 5 or a 6 appears. What is the expected number of rolls? Then find the expected number of rolls until a 6 appears at least once and a 5 appears at least once, if you are only told the answer for one target is 6.
Show answer
A 5 or 6 appears with probability 1/3 per roll, so the expected number of rolls is 1/(1/3) = 3. The second part only restates the first-six result: waiting for a 6 alone takes 6 rolls on average, so the answer to the part that asks for a single target is 6.
Exercise
Four cards are dealt from a 52-card deck without replacement. What is the expected number of hearts? Does the dependence between the draws change the answer?
Show answer
Each card is a heart with probability 13/52 = 1/4, by symmetry. By linearity, the expected number of hearts is 4 · 1/4 = 1. The dependence between draws does not change the answer, because linearity of expectation holds for dependent quantities.