In a linear Gaussian system an unknown vector z∈RL has a Gaussian prior and is observed through a noisy linear map:
p(z)=N(z∣μz,Σz),p(y∣z)=N(y∣Wz+b,Σy)
with W of shape D×L. The posterior is Gaussian (Bayes rule for Gaussians):
Σz∣y−1=Σz−1+W⊤Σy−1W,μz∣y=Σz∣y[W⊤Σy−1(y−b)+Σz−1μz]
and the normalizer, the evidence, is p(y)=N(y∣Wμz+b, Σy+WΣzW⊤).
Implement lgs_posterior(mu_z, Sigma_z, W, b, Sigma_y, y) returning (mu_post, Sigma_post, log_evidence): the posterior mean (shape (L,)), the posterior covariance (shape (L, L)) and logp(y) as a float (natural log).
W is always 2-D (a single scalar unknown has L=1), and b, y have shape (D,).