Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Split into cases
Will you be late today? It depends on the weather. If it rains (30% chance), you’re late 80% of the time. If not, only 10%. Work out each case and weigh it by how likely it is: . That’s the law of total probability.
Averages work the same way. Two classes of 20 and 30 students average 70 and 80 marks. The overall average is . That’s the law of total expectation: the overall average is the average of the case averages.
A factory has three machines with different defect rates. A rover’s battery drain depends on which terrain it crosses. A robot’s time to reach its charger depends on where it starts. Each answer is “condition on the case, then average”, and it’s the same idea behind how reinforcement-learning agents compute the value of a state.
- 1. Rain 30% (late 80%) vs dry 70% (late 10%). P(late) = ?
- 2. 20 students average 70 and 30 average 80. Overall average?
- 3. The cases must…
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.The laws
For a partition (or any random variable you condition on):
- Total probability: .
- Total expectation: , or compactly .
Here is itself a random variable, a function of giving the average of in each case.
A factory: machines A, B and C make 50%, 30% and 20% of parts, with defect rates 1%, 2% and 5%. Then . Bayes then gives .
Roll then flip: roll a die to get , then flip coins. , so , with no need for the full distribution.
- 1. Factory defect rate in the example?
- 2. E[heads] in roll-then-flip?
- 3. E[X | Y] is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.Total variance: within + between
Here’s an example. Resistors come from two machines with means 100 Ω and 110 Ω and small spreads. Most of the batch’s variance comes from mixing the machines, not from either machine’s own noise (Practice Code 3). This is also the decomposition behind ANOVA, and behind the “aleatoric vs epistemic” uncertainty split in Bayesian deep learning.
First-step analysis
To find an expected waiting time, condition on the first step.
- Rolls until a 6: , so .
- Markov chains: expected hitting times satisfy for non-target states, a linear system (Exercise 2).
- Hitting probabilities: the same trick, as in gambler’s ruin.
Random sums (Wald’s identity)
Let , with independent of the i.i.d. . Conditioning on gives
- ;
- .
Examples: packets per second × packet size, insurance claims × claim size, number of steps × cost per step.
- 1. Expected rolls until the first 6?
- 2. Var X = E[Var(X|Y)] + …
- 3. Wald: E[X₁ + … + X_N] = …
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Proofs
- Total expectation (discrete). . ∎
- Total variance. . Subtract , and the second part becomes . ∎
- Wald. and . Then apply total expectation and total variance. ∎
Conditional expectation as projection
is the function of that minimizes . In the Hilbert space it’s the orthogonal projection of onto the functions of (A3.5-5). The tower property is “projecting onto a smaller space after a bigger one”. This is why least-squares regression, and any network trained with MSE, estimates .
Gambler’s ruin by first-step analysis
A fair walk on starting at . Let be P(hit before 0). Then with and , so . The expected duration is .
Exercise 3.1: Expected number of tosses until two heads in a row (HH)
Let be the expectation from the start and just after an H. Then and . Solving gives .
- 1. E[X | Y] minimizes…
- 2. Fair gambler's ruin from 3 with target 10: P(win) = ?
- 3. Expected tosses until HH?
Level 4: Expert
★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.Expected hitting times and Bellman’s equation
A robot moves along a corridor toward its charger, with random slips. Its expected time to arrive from each cell satisfies , one application of total expectation per state. That’s a linear system, solved exactly. Replace “1 step” with “reward ” and add a discount, and you get Bellman’s equation for a policy’s value, (Bellman, 1957; Sutton and Barto, 2018). Policy evaluation, TD learning and the Neumann series of A3.5-6 are all this law of total expectation, iterated.
Conditioning as a design principle
- Mixture and scenario models. Mission-risk analyses condition on scenarios (nominal, sensor failure, high winds) and combine them by total probability (NASA PRA event trees; Stamatelatos et al., 2011).
- Aleatoric vs epistemic uncertainty. For a Bayesian model, , which is noise plus model uncertainty. Ensembles and MC dropout estimate the second term to flag out-of-distribution inputs (Kendall and Gal, 2017).
- Rao–Blackwellization. Replacing an estimator by its conditional expectation never increases variance, by the total-variance law. It’s used in Rao–Blackwellized particle filters such as FastSLAM, where the map is computed analytically given the trajectory (Doucet et al., 2000; Montemerlo et al., 2002).
- Queueing and networking. Wald’s identity and conditioning give mean delays and buffer sizes for robot fleets’ communication links and onboard telemetry.
References
- D. Bertsekas, J. Tsitsiklis (2008). Introduction to Probability, 2nd ed., Ch. 4, 7. Athena Scientific.
- S. Ross (2014). Introduction to Probability Models, 11th ed. Academic Press. (First-step analysis.)
- R. Bellman (1957). Dynamic Programming. Princeton.
- R. Sutton, A. Barto (2018). Reinforcement Learning: An Introduction, 2nd ed. MIT Press.
- A. Wald (1944). “On cumulative sums of random variables.” Annals of Mathematical Statistics, 15(3).
- A. Kendall, Y. Gal (2017). “What uncertainties do we need in Bayesian deep learning for computer vision?” NeurIPS.
- A. Doucet, N. de Freitas, K. Murphy, S. Russell (2000). “Rao-Blackwellised particle filtering for dynamic Bayesian networks.” UAI.
- M. Montemerlo, S. Thrun, D. Koller, B. Wegbreit (2002). “FastSLAM: a factored solution to the simultaneous localization and mapping problem.” AAAI.
- M. Stamatelatos et al. (2011). NASA PRA Procedures Guide. NASA/SP-2011-3421.