Unit 3 of 7 · about 4 hours · derive
Expectation, variance, covariance and conditioning laws
Mixture models, hierarchical models and unbiased estimators all rest on iterating expectations correctly. Eve's law is also the variance accounting behind every Monte Carlo error bar later.
You'll be able to
- Explain expectation, variance, covariance and correlation, and why zero correlation need not imply independence.
- Derive total expectation and total variance for a new two-stage model and state every assumption used.
- Compute conditional expectations by taking out what is known and verify the result by simulation.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Linearity, indicators and symmetryHarvard Stat 110 - Probability
Lectures 9 and 10: indicator variables, linearity of expectation and the fundamental bridge
- Covariance, correlation and conditional expectationHarvard Stat 110 - Probability
Lectures 21 and 25 to 27: variance of a sum, covariance, taking out what is known, Adam's law and Eve's law
- Covariance and conditional-expectation drillsStat 110 Strategic Practice
Strategic Practice set 10, Conditional Expectation and Variance Q1-5: Eve's law, residual example and the spam-arrival model
- Moments and the total lawsProbabilistic Machine Learning: An Introduction
Chapter 2, Section 2.2.5 (pp. 40-43): mean, linearity, variance, law of total expectation and law of total variance with the mixture example
Focus on
- Linearity of expectation needs no independence. The variance of a sum needs uncorrelatedness; independence is sufficient, not necessary.
- Eve's law splits variance into explained plus residual: . Name which term each modeling choice changes.
- Taking out what is known, , needs fixed given . Conditioning on the wrong variable breaks it.
- Zero correlation with clear dependence is one construction away: take and , then by symmetry.
Common mistakes · 3
- Pushing a nonlinear function inside an expectation. differs from ; Jensen fixes the direction for convex .
- Dropping the covariance term in without checking uncorrelatedness first.
- Quoting a conditional expectation as a number. is a function of ; only is a number.
Try it yourself
Closed-book, before checking anything
float64: numpy.random.default_rng(21), n = 400000, branch I from integers(0, 2) and then the die from integers(1, 7), with I = 0 taking the die value and I = 1 taking 10; sample mean 6.7493 and variance 12.023 with standard error of the mean 0.00548.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Prove Eve's law from the definition of variance, naming where each assumption is used.Answer
Write , then condition: by Adam's law, which needs finite. Subtract after writing by the same law, and regroup into . Both steps use iterated expectation, hence integrability.
2. and . Show while and are dependent. Why is symmetry alone not enough?Answer
by symmetry and , so . Dependence: while . Symmetry alone fails for or with probability 1/2 each: then is constant and independent of .
3.In Reproduce, which part of 12.0208 comes from within-branch variation and which from between-branch variation?Answer
is , the within part, all of it from the die since the constant branch has zero variance. is , the between part.
4.Why does the reproduce check quote 0.00548 alongside the mean?Answer
It is the simulation standard error, . Without it the comparison of 6.7493 against 6.75 has no scale; agreement means within a few standard errors.
Practice
- Stat 110 Strategic Practice 10: Conditional Expectation and Variance Q1-5
Strategic Practice Q1-5 with the inline solutions; Penultimate Homework Q1 (same file) for a random-count total with mean, variance and MGF
Attempt each problem before reading its solution. The solutions are printed in the same file.
- Stat 110 Strategic Practice 8: Covariance and Correlation Q1-7
Strategic Practice Q1-7: dice sums versus differences, Poisson thinning correlation and Multinomial covariances
Attempt before reading the solutions printed in the same file.
You're done when
You derive Eve's law and the 12.0208 without notes, your rerun of the seed-21 simulation matches the mean to 2 decimals with its standard error, and you can construct a zero-correlation dependent pair on demand.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 2 more in the section
- Harvard Stat 110 - ProbabilityHarvard University · primary
Follow lectures 4-14, 17-23 and 25-30 with matching Strategic Practice. Use lectures 1-3 only for prerequisite repair.
- Stat 110 Strategic PracticeHarvard University · required
Solve the matching sets before marking a probability topic Practised; use solutions to audit reasoning, not to begin it.
- Probabilistic Machine Learning: An IntroductionKevin Murphy · reference
Consult targeted parts of Chapters 2, 3, 4 and 6 for ML notation, Monte Carlo, factorization, posterior prediction and information theory.
Also in this section
- MIT 18.05 - Bayesian bridgeMIT OpenCourseWare · required
Use classes 10-16 for MLE, Bayesian updating, posterior prediction, conjugacy, prior choice and credible intervals.
- D2L - Information TheoryD2L authors · required
Use §§22.11.1-22.11.5 for runnable entropy, cross-entropy, KL and mutual-information examples and exercises.