Let y∼N(μ,Σ) and split its coordinates into observed ones (indices idx_obs, block 2) and hidden ones (all other indices in increasing order, block 1). Conditioning on the observed values y2 gives a Gaussian p(y1∣y2)=N(μ1∣2,Σ1∣2), which can be computed in two equivalent ways:
- Moment form: μ1∣2=μ1+Σ12Σ22−1(y2−μ2) and Σ1∣2=Σ11−Σ12Σ22−1Σ21.
- Precision form: with Λ=Σ−1 partitioned the same way, Σ1∣2=Λ11−1 and μ1∣2=μ1−Λ11−1Λ12(y2−μ2).
Implement condition_gaussian(mu, Sigma, idx_obs, y_obs) returning (mu_m, Sigma_m, mu_p, Sigma_p): the conditional mean and covariance from the moment form, then from the precision form, as float arrays over the hidden coordinates in increasing index order.
idx_obs may list the observed indices in any order; y_obs[k] is the observed value of coordinate idx_obs[k]. Use linear solves rather than explicit inverses where you can.