Memra

Probability & expectation in one page

◈ 5 cards

Indicator random variables, linearity of expectation (even when dependent), and Hₙ = ln n + O(1) — just enough for quicksort and hashing.

The one page you need (the rest is in Module 2)

This course uses probability only as a tool — for randomized quicksort (2.4), selection (2.7), and hashing (3.4). You do not need measure theory; you need three things.

1. Random variables and expectation. A random variable is a function from outcomes to numbers. Its expected value (mean) is For a fair die, .

2. Indicator random variables. An indicator for an event is if happens, otherwise. Its expectation equals the event's probability: This tiny fact is the bridge from probabilities to counts: to count how many of many events occur, sum their indicators.

3. Linearity of expectation. For any random variables, The magic word is any — this holds even when the variables are dependent. No independence is required. (Independence is only needed for and for variances to add — not for sums of expectations.)

The pattern: indicators + linearity

Put 2 and 3 together and you get the single most useful technique in randomized analysis: to find the expected number of times something happens, define an indicator for each opportunity, take each one's expectation (a probability), and sum them — dependence be damned.

Worked example — expected number of heads. Flip a biased coin (heads with probability ) times; let = number of heads. Let if flip is heads. Then , and , so No combinatorics, no — just indicators and one line of linearity. (Even if the flips were correlated, would still hold; only the variance would change.)

Where this goes. In randomized quicksort (Module 2.4) the indicator if elements and are ever compared, with . Summing those indicators gives , and that double sum is a harmonic series — which (from Lesson 0.2) is per element, yielding the famous expected . This is why the harmonic series sits in your toolkit: it is the seam where probability meets running time.

A few facts to keep nearby

  • , and the union bound (true even when events overlap) — handy for bounding "any bad event" probabilities.
  • A geometric wait-for-first-success has mean (probe counts in hashing); a binomial count of successes in trials has mean (the indicator argument above) — both will reappear in Module 3.
StepGeneral formCoin: n flips,Pr{heads}=p1 · indicatorXᵢ = 1 if event i, else 0Xᵢ = 1 if flip i is heads2 · expectationE[Xᵢ] = Pr{event i}E[Xᵢ] = p3 · linearityE[ΣXᵢ] = ΣE[Xᵢ]E[X] = Σp = npStep 3 needs no independence — dependent events sum exactly the same way.
The whole technique in three lines: one indicator per opportunity, each expectation is a probability, then sum.
NORMAL ~/memra/learn/comp-372/probability-expectation-one-page utf-8 LF