Expected Value (Definition)
A random variable assigns a number to each outcome of a random experiment. Its expected value (or mean) is the probability-weighted average of the values can take:
summing over every value in the range of . Think of as the long-run average of over many independent repetitions.
Expectation is linear under scaling and shifting: for constants ,
The weights are nonnegative and sum to , so is a genuine weighted average and always lies between the smallest and largest possible values of .
A game pays $ if a fair die shows a , pays $ if it shows a or , and pays nothing otherwise. What is the expected payoff?
Solution. The payoff takes value with probability , value with probability , and value with probability :
A fair six-sided die is rolled. Then
Note is not a possible outcome --- the mean need not be attainable.
Tip. To build from scratch, list the distinct values, attach a probability to each, check the probabilities sum to , then take the dot product “value probability.” A missing or extra probability is the most common error.
Linearity of Expectation
For any random variables and defined on the same experiment,
and more generally . This holds even when the are dependent --- no independence is required. Combined with scaling,
Linearity is the single most powerful tool in this unit. It lets you compute the mean of a complicated total by breaking it into simple pieces, computing each piece's mean separately, and adding --- without ever finding the distribution of the total.
Roll two fair dice; let be their sum. Working out the full distribution of (values through ) is tedious. Instead let where is die . Each die has mean , so
The dice need not even be independent for this to work.
Flip fair coins and let count the heads. Write where if flip is heads and otherwise. Each , so .
Key insight. When you must find the expected value of a count or a total, do not chase its distribution. Split it into a sum of simpler variables and add their means. Dependence between the pieces is irrelevant to the sum of the expectations.
Indicator Random Variables
An indicator equals if event happens and otherwise. Its expectation is just the probability of the event:
If counts how many of the events occur, then , and by linearity
This is the workhorse pattern: whenever a quantity counts occurrences (heads, matches, fixed points, adjacent pairs, successes), define one indicator per potential occurrence and add up the individual probabilities. The events may overlap or be highly dependent --- it does not matter.
Deal cards from a standard -card deck. Let be the number of aces. For position , let indicate that the -th card dealt is an ace; by symmetry . Then
The cards are dependent (drawing without replacement), yet linearity still applies.
Randomly permute . Let count the fixed points (positions with ). Let indicate ; then , so
On average a random shuffle leaves exactly one element in place, for every .
Recipe. (1) Identify the count. (2) Write it as , one indicator per possible occurrence. (3) Find for a single (symmetry usually makes them all equal). (4) Add. This four-step recipe cracks a huge fraction of contest expectation problems.
Expected Value via States & Recursion
When a process repeats until something happens, set up an equation for the expected value by conditioning on the first step. Let be the expected number of steps to finish. After one step you either finish or land back in a known state; averaging over the possibilities gives a linear equation in that you solve.
For a process that, each step, succeeds with probability (and otherwise restarts identically):
With several states, write one equation per state and solve the system.
The template is always “.” Finished/absorbing states contribute expected cost .
Flip a fair coin until the first heads. Let be the expected number of flips. One flip always happens; with probability we are done, and with probability we are back where we started:
Flip a fair coin until two heads occur in a row. Let be the expected additional flips from the start (or just after a tails) and the expected additional flips right after a single heads. Then
Substituting the second into the first gives , so , giving and .
Tip. Choose states so that the future depends only on the current state, not the full history. Then each state gets one equation. Absorbing (“done”) states have expected remaining cost --- they anchor the system.
Symmetry Arguments
When outcomes are interchangeable, symmetry pins down probabilities and expectations with almost no computation. Two common forms:
- Uniform position. In a random permutation, each element is equally likely to occupy any given position, so its expected position is the average position .
- Equal-likelihood ordering. Among specific items in random order, each of the relative orders is equally likely; e.g. any one of them is first with probability .
Symmetry pairs beautifully with linearity: use symmetry to argue every indicator has the same probability, then multiply by the number of indicators.
Shuffle a -card deck. The aces split the remaining cards into gaps (before the first ace, between consecutive aces, after the last). By symmetry each of the non-aces is equally likely to fall in any gap, so each gap holds non-aces on average. The first ace sits just after the first gap, so its expected position is
More generally the first of special cards among has expected position .
Three runners finish in a uniformly random order. By symmetry each is equally likely to be the fastest, so . No casework needed.
Tip. Before computing, ask: “Are these objects interchangeable?” If relabeling them leaves the setup unchanged, they share the same probability or expected value. That observation often replaces pages of casework with a single fraction.
Waiting Times & the Geometric Distribution
Repeat independent trials, each succeeding with probability . Let be the number of trials up to and including the first success. Then has a geometric distribution:
The mean wait is the reciprocal of the success probability: rarer events take proportionally longer. (The variance is , rarely needed on contests.)
The formula follows instantly from the recursion of the previous section, so “waiting time” problems and “restart” recursions are two views of the same idea.
Roll a fair die until a appears. Each roll succeeds with , so the expected number of rolls is
Waiting for a or a instead has , giving .
A player makes each free throw with probability . The expected number of attempts to record the first make is .
Careful. counts the trial on which success occurs. If a problem asks for the expected number of failures before the first success, that is . Read carefully which count is wanted.
Going Deeper: Where These Ideas Combine
The four moves below appear again and again in olympiad and AMC/AIME problems:
- Linearity magic. To find the expected value of a total, never compute its distribution --- decompose into indicators or simple pieces and add. This defeats problems whose totals are hopelessly complicated to distribute directly.
- Expected fixed points . In any random permutation of objects, the expected number of elements left in place is exactly , independent of (each of the positions is a fixed point with probability ).
- Absorbing-chain expectations. Model a repeating process as a Markov chain with “done” (absorbing) states; write one linear equation per transient state by conditioning on the next step, then solve. Symmetric gambler's-ruin on started at lasts steps in expectation.
- Coupon collector. To collect all distinct coupons, once you hold of them the chance a new draw is fresh is , a geometric wait of . Summing gives .
Roll a fair die repeatedly until all six faces have appeared. Waiting for the first new face costs roll; from distinct faces seen, the next new face has probability , so its expected wait is . Summing over :
A token starts at vertex of triangle and each step moves to one of the other two vertices with equal probability. How many steps, on average, to first reach ? Let be the expected steps from and . By the transition rules,
By symmetry , so , giving steps.
Big picture. Expectation problems reward the solver who refuses to find the whole distribution. Ask three questions: (1) Is this a count or total? Then split into indicators and add () --- linearity ignores all dependence. (2) Does the process repeat or wander among states? Then condition on the first step and solve a linear system; a pure “restart” collapses to the geometric mean . (3) Are the objects interchangeable? Then symmetry hands you the per-piece probability for free. Almost every advanced expectation problem is one of these three shapes in disguise --- name the shape, and the computation shrinks to a few lines.
Linearity Masterclass: Records, Inversions & Cycles
A uniformly random permutation of hides a zoo of natural statistics. Linearity computes the mean of each one without independence:
- Records (left-to-right maxima): position is a record if exceeds all earlier entries. Among the first values, each is equally likely to be the largest, so .
- Inversions: a pair is inverted if . By symmetry each unordered pair is inverted with probability .
- Fixed points: (already seen: mean ).
- Cycles: the expected number of cycles equals the harmonic number .
In every case, sum the per-object probabilities. The events are wildly dependent; linearity does not care.
The cycle count is the subtle one. Build the permutation by the Chinese-restaurant process: insert elements one at a time, each either sitting after some existing element or starting a new cycle. Element (the -th inserted) closes a new cycle exactly when it is the one that “points back to the start,” which happens with probability among its equally likely choices. So the number of cycles is with , giving .
Let count the left-to-right maxima and the inversions of a random permutation of .
Records. . For , .
Inversions. There are pairs, each inverted with probability :
For this is . Notice records and cycles share the same mean --- not a coincidence, but a bijective fact (Foata's correspondence) that linearity reveals for free.
Key insight. A permutation statistic that is a sum over positions or pairs yields to indicators. The whole art is choosing the right “atom”: positions for records and fixed points, unordered pairs for inversions, insertion steps for cycles. Find the atom, find one probability, multiply or sum. The joint distribution never appears.
Variance & the Second Moment
The variance of measures how far typically strays from its mean :
The second form (“mean of the square minus square of the mean”) is almost always the easier one to compute. Variance scales quadratically: --- shifting by changes nothing, stretching by multiplies spread by .
Unlike expectation, variance does NOT add in general. It adds only when the pieces are independent (or merely uncorrelated):
For a single indicator with , we have (since ), so
This one fact powers the variance of every count built from independent indicators.
Flip independent coins, each heads with probability ; let be the number of heads. The flips are independent, so variances add:
For fair coins (): and , so the standard deviation is . Typical outcomes cluster near .
Let be a fair die roll. We found . For the variance, compute the second moment:
Then
The sum of two independent dice therefore has variance , even though its mean came from linearity without any independence.
Careful. Expectation always adds; variance adds only under independence. When indicators are dependent (drawing without replacement, fixed points of a permutation), you must include covariance terms: . If a problem asks for a variance and the pieces overlap, do not just add --- the cross terms are where the points hide.
Conditional Expectation & the Tower Property
The conditional expectation is the average of once the value of is known; it is itself a random variable (a function of ). The tower property (law of total expectation) says you may average in two stages and recover the plain mean:
Read it as: “condition on whatever you wish you knew, solve the easy conditional problem, then average over the thing you conditioned on.” This is exactly the engine behind first-step analysis --- there is the outcome of the first step.
The tower property turns a hard unconditional expectation into a menu of easy conditional ones. Choosing the right (the first coin flip, the first move, the number of successes so far) is the whole game, and it directly generalizes the state-recursion method of Unit 8's Markov chains.
Roll a fair die to get a number ; then roll fair dice and let be their total. Find .
Solution. Condition on . Given , the inner sum has mean , so as a random variable . By the tower property,
This is Wald's identity in miniature: the mean of a random-length sum of i.i.d. terms is (expected length)(term mean).
A frog sits at position on and each second hops left or right with equal probability; positions and are absorbing. Let be the expected time to get absorbed. Conditioning on the first hop (the tower property with first move),
Solving the symmetric system gives : and . This is the general gambler's-ruin duration on , derived here purely by conditioning on the first step.
Recipe. To use the tower property: (1) pick a variable that, once known, makes easy to average; (2) write for each ; (3) average against . When is “the first step,” this reproduces the one-equation-per-state method --- conditional expectation and first-step analysis are the same tool wearing different hats.
Probability Generating Functions & the Tail-Sum Formula
For a nonnegative integer-valued , its probability generating function (PGF) packs all the probabilities into one power series:
Three facts make PGFs powerful on contests:
- Normalization: .
- Coefficients are probabilities: the coefficient of in is exactly , so extracting one coefficient answers a “what is the chance the total is ” question with pure polynomial bookkeeping.
- Sums multiply: if are independent, then . Convolving distributions becomes multiplying polynomials.
For the mean, the workhorse is the tail-sum formula: for a nonnegative integer variable,
It re-derives many waiting-time means in one line and is often the fastest route when the tail probabilities are simpler than the point probabilities .
PGF part. A single die has PGF . The sum of two independent dice therefore has ; the coefficient of in is , recovering by polynomial multiplication rather than casework. And by linearity of expectation, --- no new machinery needed for the mean.
Tail-sum part. Roll a die until the first ; let be the number of rolls. Then (the first rolls all miss). So
recovering the geometric mean with a single geometric series and no distribution-by-distribution bookkeeping.
Key insight. Reach for a PGF when a problem involves a sum of independent variables: multiply their PGFs and read the answer off a coefficient. Reach for linearity of expectation for means of sums. Reach for the tail-sum formula when the “at least ” probabilities are clean --- it turns a mean into a single series and is the slickest derivation of most waiting-time expectations.
Formulas, Proofs & Tips
What it means. The long-run average outcome; expectations add even when the variables interact.
Example. A fair die: .
Why it works. weights each outcome by how often it happens. Linearity holds because summing over the joint distribution can be regrouped one variable at a time — no independence is needed.
Tip. Linearity is the workhorse: break a complicated count into indicator variables ( if an event happens, if not) and add their expectations.