S14 · Lesson 8 · The Gaussian distribution in learning
The multivariate Gaussian and its Mahalanobis distance, conditioning and marginalizing a joint Gaussian, Bayesian inference for a Gaussian's mean where precisions add, and sequential estimation that updates with each new sample
The Gaussian is the workhorse of learning, and not only because of the central limit theorem. Conditioning one Gaussian variable on another gives a Gaussian whose mean is a linear function of what was observed: that's linear regression and the Kalman filter of S9 in one line. Combining a Gaussian prior with Gaussian measurements gives a Gaussian posterior whose precision is simply the sum of the precisions. Those two facts carry much of the rest of the course.
- Bayesian inference for a Gaussian's mean: a prior centered at 0 with standard deviation , the likelihood of N measurements averaging 2 (noise σ = 1), and the posterior.
- The posterior sits between the prior and the data, closer to whichever is more precise. Its precision is the prior's plus N times each measurement's.
- With many measurements the prior stops mattering.
Predict
A prior says a sensor's offset is 0 ± 2 (standard deviation). Four readings with noise standard deviation 1 average 2. What's the posterior mean?
Precisions add: the prior contributes 1/4 and the four readings 4 × 1 = 4, for a posterior precision of 4.25 (standard deviation 0.485). The posterior mean weights each source by its precision: (0 × 0.25 + 2 × 4)/4.25 = 1.88. The readings dominate, but the prior still pulls slightly toward 0.
Name it
The multivariate Gaussian
Δ is the Mahalanobis distance: Euclidean distance after scaling each direction by its spread. For a diagonal Σ it's .
Conditioning
For jointly Gaussian x and y with standard deviations , and correlation ρ,
Marginals of a joint Gaussian are Gaussian with the corresponding parts of μ and Σ.
Inference for the mean
With prior and N observations of mean and noise variance , the posterior is Gaussian with
Sequential estimation
The sample mean can be updated one sample at a time: , a correction proportional to the surprise, with a gain that shrinks as data accumulate.
Worked example
Finish the sensor example: posterior variance and mean.
Show the solution
- Posterior precision. so = 0.235 and = 0.485.
- Posterior mean.
- More readings. With 40 readings instead the mean would be 1.988; the prior's influence fades as 1/N.
Answer the posterior has variance 0.235 (standard deviation 0.485) and mean 1.882.
Worked example
x and y are Gaussian with zero means, = 1, = 2 and ρ = 0.6. Given x = 1, what do you know about y?
Show the solution
- Conditional mean.
- Conditional variance. a standard deviation of 1.6 instead of 2.
- What x told us. Knowing x removed 36% of y's variance, .
Answer given x = 1, y has mean 1.2 and standard deviation 1.6 (variance 2.56).
Worked example
A quantity x has prior N(0, 4). A sensor with gain 2 reports , with noise variance 1, and reads y = 3. What's the posterior for x?
Show the solution
- Posterior precision. It's the prior's plus the measurement's, scaled by the gain squared: a variance of 0.235.
- Posterior mean. It's the precision-weighted information:
- Compare the naive estimate. The naive estimate y/2 = 1.5 is pulled slightly toward the prior's 0, because the measurement is good but not perfect.
- Spread. The posterior standard deviation, 0.485, is a little better than the measurement alone would give (0.5).
Answer the posterior for x has mean 1.41 and variance 0.235 (standard deviation 0.485).
Check
A mean has a prior with standard deviation 2. 20 observations with noise variance 0.25 arrive. What's the posterior variance?
Check
Prior N(0, 0.5²), and 10 observations averaging 3 with noise variance 1. What's the posterior mean?
Check
x and y are zero-mean jointly Gaussian with = 1, = 0.5 and correlation 0.8. Given x = 2, what's E[y|x]?
Check
y has standard deviation 2 and correlation 0.3 with x. What's var(y|x)?
Check
A point (x, y) = (1, −2) is compared with a zero-mean Gaussian of diagonal covariance with standard deviations 2 and 3. What's its Mahalanobis distance?
Check
The mean of the first 50 − 1 samples is 2. Sample number 50 is 1. What's the new mean?
Check
A quantity has prior N(0, 1²). A sensor reads with noise variance 2, and reports y = 4.
(a)
What is the posterior variance of x?
(b)
What is its posterior mean?
Check
Two independent unbiased sensors read x and y with noise variances a and b.
Step 1
What is the variance of the best combined estimate?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is that estimate?
Explain why
Why is it the precisions that add when Gaussian information is combined?
Combining a Gaussian prior with Gaussian measurements multiplies their densities, and each density is the exponential of a quadratic in the unknown with a curvature equal to its precision, one over its variance. Multiplying exponentials adds the quadratics, so the curvatures, the precisions, add: each independent source of information tightens the estimate by its own precision. The posterior mean is the point where the summed quadratic is lowest, which is the precision-weighted average of the sources. That's why a very precise measurement swamps a vague prior, and why N equally good measurements shrink the variance by a factor of N.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.