Probability & Expectation

Study Sheet

Probability & Expectation

Indicators, linearity, geometric probability, random walks, coupon collecting

Expectation Without Distributions

Tip
Linearity and indicators

E[∑Xi]=∑E[Xi]E[\sum X_i] = \sum E[X_i] with NO independence assumption. Write a count as a sum of 0/10/1 indicators, and expectation becomes a sum of probabilities.

Expected fixed points of a random permutation: n⋅1n=1n\cdot\tfrac1n = 1. Expected number of adjacent equal letters, expected number of records in a random sequence (HnH_n), expected inversions ((n2)/2\binom n2/2) — all indicator sums. The distribution may be a nightmare; the expectation is a one-liner. Coupon collector: waits are geometric with expectations nn−k\tfrac{n}{n-k}, summing to nHnnH_n (253\tfrac{25}{3} for n=4n = 4).

Tip
Geometric probability and random walks
|x − y| ≥ 1/47/161/401
Two uniform points on [0, 1] as one point of the unit square: |x − y| < 1/4 is the band around the diagonal, of area 1 − (3/4)² = 7/16.

Probability == favorable measure ÷\div total measure; expectations become integrals. A ±1\pm1 walk returns to 00 after 2n2n steps with probability (2nn)/4n≈1πn\binom{2n}{n}/4^n \approx \tfrac{1}{\sqrt{\pi n}}.

Two uniform points on [0,1][0,1]: E∣X−Y∣=13E|X - Y| = \tfrac13, E[max⁡]=23E[\max] = \tfrac23, P(∣X−Y∣<14)=716P(|X - Y| < \tfrac14) = \tfrac{7}{16} (unit-square pictures). Broken-stick triangle: 14\tfrac14. Buffon's needle: 2ℓπd\tfrac{2\ell}{\pi d}. Random walk returns: (42)/16=38\binom42/16 = \tfrac38 after four steps; the 1πn\tfrac{1}{\sqrt{\pi n}} decay is why ∑P(return at 2n)=∞\sum P(\text{return at } 2n) = \infty and the 1D walk is recurrent, while in 3D it is not.

Tip
Conditioning and first-step analysis

For expected times and absorption probabilities, condition on the first step: Ei=1+∑jpijEjE_i = 1 + \sum_jp_{ij}E_j — a small linear system.

Expected rolls until two consecutive sixes: 4242. Expected steps for a walker advancing with probability 23\tfrac23 else staying, to go 33 steps: 3⋅32=4.53\cdot\tfrac32 = 4.5. Gambler's ruin from kk with target NN (fair coin): ruin probability 1−kN1 - \tfrac kN, expected duration k(N−k)k(N - k). Markov-chain steady states (the Linear Algebra course) are the long-run version of the same conditioning.

Side note
When independence is not there

Indicators handle dependence for expectations, but NOT for variances: Var(∑Xi)=∑Var(Xi)+2∑i<jCov(Xi,Xj)\mathrm{Var}(\sum X_i) = \sum\mathrm{Var}(X_i) + 2\sum_{i<j}\mathrm{Cov}(X_i, X_j). Putnam problems that ask for a variance or a probability of a specific count usually intend inclusion–exclusion or a generating function, not linearity.

Side note
Where it goes wrong
startHHHH, ½H, ½T, ½T, ½waiting for HH: E = 6 (for HT: E = 4)
First-step analysis for HH: a tail from state H sends the walk back to the start, which is what makes HH slower than HT.

"HH and HT are equally likely pairs, so by symmetry the expected number of flips until HH appears equals the expected number until HT appears, namely 44." For HT it is 44: wait for the first H (expected 22 flips), then for the first T after it (expected 22 more), and a further H changes nothing. For HH, a T after the first H destroys the progress. First-step analysis with E0E_0 (no progress) and E1E_1 (last flip H): E0=1+12E1+12E0E_0 = 1 + \tfrac12E_1 + \tfrac12E_0 and E1=1+12⋅0+12E0E_1 = 1 + \tfrac12\cdot0 + \tfrac12E_0, giving E0=6E_0 = 6. The patterns are equally likely at any given position, but their OVERLAPS differ — HH overlaps itself, HT does not — and waiting times see overlaps.

Try it
Try it: an indicator sum

A fair coin is flipped 1010 times. What is the expected number of times a head is immediately followed by a tail?

Show the answer

Nine adjacent pairs, each HT with probability 14\tfrac14: expectation 94\tfrac94. The pairs overlap and are dependent — linearity does not care.

Proofs & Why It Matters

Tip
Proof: linearity of expectation

E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y] for ANY random variables with finite expectations.

For discrete variables, E[X+Y]=∑x,y(x+y)P(X=x,Y=y)=∑xx∑yP(X=x,Y=y)+∑yy∑xP(X=x,Y=y)=∑xxP(X=x)+∑yyP(Y=y)E[X + Y] = \sum_{x,y}(x + y)P(X = x, Y = y) = \sum_xx\sum_yP(X=x, Y=y) + \sum_yy\sum_xP(X=x,Y=y) = \sum_xxP(X = x) + \sum_yyP(Y = y) — the joint distribution marginalizes, and no independence was used. ■\blacksquare Significance: the ENTIRE indicator method rests on this; it is worth stating in a solution that independence is not required, because graders check that you know.

Tip
Proof: the coupon collector expectation

Collecting all nn equally likely coupons takes nHnnH_n draws on average.

After kk distinct coupons are held, each draw is new with probability n−kn\tfrac{n-k}{n}, independently of the past; the number of draws until the next new one is geometric with mean nn−k\tfrac{n}{n-k}. Sum over k=0,…,n−1k = 0, \ldots, n - 1 (linearity): n(1n+1n−1+⋯+1)=nHnn\left(\tfrac1n + \tfrac{1}{n-1} + \cdots + 1\right) = nH_n. ■\blacksquare Significance: nHn≈nln⁡nnH_n \approx n\ln n is the universal cost of "cover everything by random sampling" — hashing, epidemic spreading, and randomized algorithms all hit this bound.

Going Deeper: Worked Problems

Example
Worked: expected value of a maximum

Three numbers are chosen independently and uniformly from [0,1][0,1]. Find the expected value of the largest.

Step 1 — the CDF of the max: P(max⁡≤t)=t3P(\max \le t) = t^3.

Step 2 — for a nonnegative variable, E[M]=∫01P(M>t) dt=∫01(1−t3)dt=1−14=34E[M] = \int_0^1P(M > t)\,dt = \int_0^1(1 - t^3)dt = 1 - \tfrac14 = \tfrac34.

Step 3 — general pattern: E[max⁡ of n]=nn+1E[\max\text{ of }n] = \tfrac{n}{n+1} and E[min⁡]=1n+1E[\min] = \tfrac{1}{n+1}; the nn order statistics split [0,1][0,1] into n+1n + 1 pieces of equal expected length.

Step 4 — the tail-integral formula E[X]=∫0∞P(X>t) dtE[X] = \int_0^\infty P(X > t)\,dt is the fastest route to expectations of maxima, minima, and waiting times.

Example
Worked: gambler's ruin by first-step analysis
k12345678910510152025E₃ = 21E₅ = 25
Expected number of bets from each starting stake k: Eₖ = k(10 − k), each value the average of its neighbours plus 1.

A fair-coin gambler starts with $3\$3 and stops at $0\$0 or $10\$10. Find the probability of reaching $10\$10 and the expected number of bets.

Step 1 — let pkp_k be the probability of reaching 1010 from kk: pk=12pk−1+12pk+1p_k = \tfrac12p_{k-1} + \tfrac12p_{k+1}, p0=0p_0 = 0, p10=1p_{10} = 1. The recurrence forces pkp_k linear: pk=k10p_k = \tfrac{k}{10}, so p3=0.3p_3 = 0.3.

Step 2 — let EkE_k be the expected duration: Ek=1+12Ek−1+12Ek+1E_k = 1 + \tfrac12E_{k-1} + \tfrac12E_{k+1} with E0=E10=0E_0 = E_{10} = 0; the particular solution of the constant inhomogeneity is −k2-k^2, so Ek=k(10−k)E_k = k(10 - k) and E3=21E_3 = 21.

Step 3 — sanity: from the midpoint E5=25E_5 = 25 is the longest expected game; near the boundaries games end fast.

Step 4 — conditioning on one step turned a random process into two linear recurrences — the whole method.