Techniques for calculating expected values
December 20, 2025
This is a list of techniques I’ve found useful for computing expected values. In the interest of clarity and intuition over strict theoretical correctness, I’ve opted to take some liberties with the notation and not to document every assumption.
-
Weighted average of possible values
- This is the standard definition of expected value. It’s usually only useful if you can easily calculate the probability distribution .
- Example: If is the value of a single roll of a die, then
-
Linearity of expectation
- Example: If is the sum of two independent rolls of a die, then
- Example: Suppose people enter a restaurant and leave their hats at reception. At the end of dinner, each person gets a hat back at random. In expectation, how many people get their own hat back?
- Let be the number of people who correctly get their own hat back and be an indicator variable indicating whether the th person got their own hat back.
- Note that and aren’t independent, but linearity of expectation works anyway! is a classic example of a random variable whose expected value is much easier to compute than its distribution.
-
Law of total expectation
- Sometimes the random variable is simpler if you condition on another random variable.
- Example: Suppose you roll a fair die and record the value. Then you continue rolling the die until you obtain a value at least as large as the first roll. In expectation, how many additional rolls are there after the first?
- Let be the number of additional rolls after the first and be the value of the first roll.
- Given , each subsequent roll succeeds with probability , so is geometric with mean .
- Then .
- In this case, it’s hard to understand without first conditioning on , but we can calculate by “averaging” over all the possible values of .
-
Symmetry
- If are exchangeable and , then .
- Example: If you randomly break a stick of length into pieces, then the expected length of the leftmost piece is .
- Example: Suppose each day either 100 or 200 birds appear (each with 50% probability) and then divide themselves randomly among 15 statues. Let be the total number of birds on each day and be the number of birds on the th statue. Then
-
Recursion
- Example: What is the expected number of coin flips to see HTH?
- There are 4 states: 0 (Start), 1 (Have seen H), 2 (Have seen HT), and 3 (Done).
- Let represent the number of flips to transition from state to state 3. We want to compute .
- Obviously , so .
- From state 2, we flip once and transition to either state 3 or state 0, so
- From state 1, we flip once and transition to either state 1 or state 2, so
- From state 0, we flip once and transition to either state 0 or state 1, so
- We have three equations in three variables. Solving yields , , .
- Example: What is the expected number of coin flips to see HTH?
-
Product of independent random variables
- If and are independent random variables, then
- Example: A factory makes widgets. Each widget goes through 2 inspections. Each inspection has an independent 90% chance of passing. Let be the indicator variables for passing each respective inspection. Then
-
Wald’s equation
- If are real and iid, and is a random integer, then .
- Example: A pirate opens identical treasure chests one-by-one. Each chest randomly contains between 1 and 6 coins. The pirate stops when he opens a “cursed” chest containing only 1 coin. Let be the number of chests opened, be the total number of coins collected, and be the number of coins in the th chest. Then
-
Tail-sum
- If is non-negative and continuous, then
- If is non-negative and integer-valued, then
- Example: Let be the number of coin flips needed to get the first head. Then , since the event occurs if and only if the first flips are all tails and therefore .