Before you readTwo noisy measurements can be explained by many straight lines. Where would those lines agree most, and where might they disagree?
Watch: Statistical Rethinking, lecture 4 · Richard McElreath · Watch the opening example on uncertainty over lines
Ordinary least squares picks one line. Bayesian linear regression gives a distribution over lines: draw an intercept w0 and slope w1 to get one whole function f(x)=w0+w1x.
Put a Gaussian prior on those weights before seeing data. The likelihood says the observations are yi=f(xi)+εi, with independent Gaussian noise εi of mean zero and variance σn2.Bayes’ rule multiplies the prior by the likelihood and normalises. The resulting posterior is still Gaussian over weights, but now gives more weight to lines that explain the data.
Each line is one draw of the slope and intercept. Show the posterior to see what two observations change.
From weights to function values
Write f(x)=ϕ(x)Tw, where ϕ(x)=(1,x)T. The weight covariance Σw determines the covariance of two function values:
Cov(f(x),f(x′))=ϕ(x)TΣwϕ(x′).
The same random weights generate both values. For example, with independent weights of variance one, the covariance is 1+xx′. Any finite list of function values is a linear transformation of the Gaussian weights, so it is jointly Gaussian. That’s already a Gaussian process. Next we’ll specify the covariance directly so that the functions needn’t be straight lines.
Recall
What does one draw of the weights give you?
Recall
What turns a prior over lines into a posterior over lines?
Exercise
The intercept and slope are independent, each with variance one. What are Cov(f(−1),f(1)) and Var(f(1)), in that order?
Exercise
Use the figure's two observations: y−=−0.8 at x=−2 and y+=1.2 at x=2. The intercept and slope have independent standard Gaussian priors, and each observation has independent Gaussian noise of variance 0.09. Find the posterior mean of the slope w1, to three decimal places.