Module 2
Prediction Error & Precision
Belief updates in the Bayesian brain are driven by prediction errors(observation minus expectation) weighted by precision (inverse variance). This module introduces Kalman filtering, variational inference with the evidence lower bound (ELBO), and the cognitive role of precision as attention.
1. Kalman Filtering
A Kalman filter is the optimal Bayesian estimator for a linear Gaussian system. The posterior mean after each observation is:
\[ \hat\mu_t = \hat\mu_{t|t-1} + K_t\bigl(y_t - \hat\mu_{t|t-1}\bigr),\qquad K_t = \frac{P_{t|t-1}}{P_{t|t-1} + R} \]
The Kalman gain K is the precision of the likelihood relative to the prior. High-precision likelihood (low sensor noise) pulls the posterior toward the observation; high-precision prior (low system noise) pulls it toward the prediction. This ratio is the key computational lever modulated by attention and psychiatric conditions (M7).
2. Variational Inference & ELBO
When the posterior P(z|x) is intractable, variational inference approximates it with Q(z) from a tractable family, minimising KL divergence. Equivalent to maximising the evidence lower bound:
\[ \log P(x) \;\geq\; \mathbb{E}_{Q(z)}[\log P(x, z)] - \mathbb{E}_{Q(z)}[\log Q(z)] = \text{ELBO} \]
Under Gaussian approximation, the ELBO becomes a precision-weighted sum of squared prediction errors minus a KL-complexity term. M4 shows that this is identical to the negative free energy Friston proposed as the brain’s unifying objective.
3. Precision = Attention
Precision is inverse variance — how confident the brain is in a sensory channel or a top-down prediction. Attentional enhancement can be modelled as up-weighting the precision of attended sensory evidence (Feldman & Friston 2010). Conversely, aberrant precision on priors is proposed as the computational substrate of hallucinations in schizophrenia and atypical sensory precision in autism (M7).
Simulation: Kalman Filter Precision Regimes
Click Run to execute the Python code
Code will be executed with Python 3 on the server
Key References
• Kalman, R. E. (1960). “A new approach to linear filtering and prediction problems.” J. Basic Eng., 82, 35–45.
• Feldman, H. & Friston, K. J. (2010). “Attention, uncertainty, and free-energy.” Front. Hum. Neurosci., 4, 215.
• Jordan, M. I. et al. (1999). “An introduction to variational methods for graphical models.” Mach. Learn., 37, 183–233.
• Kingma, D. P. & Welling, M. (2014). “Auto-encoding variational Bayes.” ICLR.