Skip to main content

observe_normal

Function observe_normal 

Source
pub fn observe_normal(
    mean: &Analytic,
    y: f64,
    sd: f64,
    next: &mut u64,
) -> OpResult<Option<Observed>>
Expand description

Observing y from normal(mean, sd), with mean an outcome of normal draws: the logarithm of its density, and what the world knows about each latent after it. None if the mean isn’t affine in a normal latent or a linear form of several.

With one latent, it’s the conjugate update, by what y says about the latent itself. With several, which are unrestricted, their posterior is normal with a covariance. Each becomes its posterior mean plus a linear form of fresh standard normal latents, numbered after next: with prior standard deviations s, coefficients a and S the variance of y, the covariance is D^½ (I − c cᵀ) D^½ for D = diag(s²) and c = s a / √S, and its square root D^½ (I − γ c cᵀ), γ = 1 / (1 + sd / √S).