S148 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 σ0, 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?

Name it

The multivariate Gaussian

𝒩(𝐱|𝝁,Σ)=1(2π)D/2|Σ|1/2exp⁡(−12Δ2),Δ2=(𝐱−𝝁)TΣ−1(𝐱−𝝁)

Δ is the Mahalanobis distance: Euclidean distance after scaling each direction by its spread. For a diagonal Σ it's ∑(xi−μi)2/σi2.

Conditioning

For jointly Gaussian x and y with standard deviations σx, σy and correlation ρ,

E[y|x]=μy+ρσyσx(x−μx),var(y|x)=σy2(1−ρ2)

Marginals of a joint Gaussian are Gaussian with the corresponding parts of μ and Σ.

Inference for the mean

With prior 𝒩(μ0,σ02) and N observations of mean x¯ and noise variance σ2, the posterior is Gaussian with

1σN2=1σ02+Nσ2,μN=σN2(μ0σ02+Nx¯σ2)

Sequential estimation

The sample mean can be updated one sample at a time: μN=μN−1+1N(xN−μN−1), 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
  1. Posterior precision. 1/σN2=1/4+4=4.25 so σN2 = 0.235 and σN = 0.485.
  2. Posterior mean. μN=σN2(0+4×2)=8/4.25=1.882
  3. 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, σx = 1, σy = 2 and ρ = 0.6. Given x = 1, what do you know about y?

Show the solution
  1. Conditional mean. E[y|x]=0.6×2/1×1=1.2
  2. Conditional variance. var(y|x)=4(1−0.36)=2.56 a standard deviation of 1.6 instead of 2.
  3. What x told us. Knowing x removed 36% of y's variance, ρ2.

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 y=2x+n, with noise variance 1, and reads y = 3. What's the posterior for x?

Show the solution
  1. Posterior precision. It's the prior's plus the measurement's, scaled by the gain squared: 14+221=4.25 a variance of 0.235.
  2. Posterior mean. It's the precision-weighted information: μ=2×3/14.25=1.41
  3. 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.
  4. 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 σx = 1, σy = 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 y=0.5x+n 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°.

Explain why

Why is it the precisions that add when Gaussian information is combined?

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.