7 routes42 sections324 units

Unit 3.3 · about 4 h

67 / 324

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.

  • derive

You can now

  • 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

  • Expectation, variance, covariance and correlation
  • Total probability, expectation and variance
  • Conditional expectation

Study, in this order

4 steps

  1. Linearity, indicators and symmetry
    Harvard Stat 110 - Probability

    Lectures 9 and 10: indicator variables, linearity of expectation and the fundamental bridge

  2. Covariance, correlation and conditional expectation
    Harvard 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

  3. Covariance and conditional-expectation drills
    Stat 110 Strategic Practice

    Strategic Practice set 10, Conditional Expectation and Variance Q1-5: Eve's law, residual example and the spam-arrival model

  4. Moments and the total laws
    Probabilistic 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: \(\operatorname{Var}(Y)=\operatorname{Var}(\mathbb{E}[Y \mid X])+\mathbb{E}[\operatorname{Var}(Y \mid X)]\). Name which term each modeling choice changes.
  • Taking out what is known, \(\mathbb{E}[g(X)Y \mid X]=g(X)\mathbb{E}[Y \mid X]\), needs \(g(X)\) fixed given \(X\). Conditioning on the wrong variable breaks it.
  • Zero correlation with clear dependence is one construction away: take \(X \sim \operatorname{Normal}(0, 1)\) and \(Y=X^2\), then \(\operatorname{Cov}(X, Y)=\mathbb{E}[X^3]=0\) by symmetry.

Reproduce closed-book

Closed-book, derive Eve's law on a two-stage model: with probability 1/2 roll a fair die (mean 3.5, variance 35/12) and otherwise take 10. Then \(\mathbb{E}[X]=6.75\) and \(\operatorname{Var}(X)=35/24+(10-3.5)^2/4=12.0208\): the first term uses LOTUS on the die branch and the second uses \(\operatorname{Var}\) of \(\{3.5, 10\}\). Check with NumPy in 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.

Traps

  • Pushing a nonlinear function inside an expectation. \(\mathbb{E}[g(X)]\) differs from \(g(\mathbb{E}[X])\); Jensen fixes the direction for convex \(g\).
  • Dropping the covariance term in \(\operatorname{Var}(X+Y)\) without checking uncorrelatedness first.
  • Quoting a conditional expectation as a number. \(\mathbb{E}[Y \mid X]\) is a function of \(X\); only \(\mathbb{E}[Y \mid X=x]\) is a number.

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.

Self-test

  1. Prove Eve's law from the definition of variance, naming where each assumption is used.

  2. \(X \sim \operatorname{Normal}(0, 1)\) and \(Y=X^2\). Show \(\operatorname{Cov}(X, Y)=0\) while \(X\) and \(Y\) are dependent. Why is symmetry alone not enough?

  3. In Reproduce, which part of 12.0208 comes from within-branch variation and which from between-branch variation?

  4. Why does the reproduce check quote 0.00548 alongside the mean?

Completion criterion

Stop 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.

Mark passed, then open 3.4 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • Harvard Stat 110 - Probability
    Harvard Universityprimarycourse
    Follow lectures 4-14, 17-23 and 25-30 with matching Strategic Practice. Use lectures 1-3 only for prerequisite repair.
  • Stat 110 Strategic Practice
    Harvard Universityrequiredpractice
    Solve the matching sets before marking a probability topic Practised; use solutions to audit reasoning, not to begin it.
  • Probabilistic Machine Learning: An Introduction
    Kevin Murphyreferencetheory
    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 bridge
    MIT OpenCourseWarerequiredcourse
    Use classes 10-16 for MLE, Bayesian updating, posterior prediction, conjugacy, prior choice and credible intervals.
  • D2L - Information Theory
    D2L authorsrequiredimplementation
    Use §§22.11.1-22.11.5 for runnable entropy, cross-entropy, KL and mutual-information examples and exercises.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels