Kalman measurement update (source code)

= Kalman measurement update
{c}
{title2=$m_t=m_t^-+K_te_t,\quad P_t=P_t^--K_tS_tK_t^\top$}

The <Kalman measurement update> incorporates the new observation by <Gaussian conditional expectation>:
$$
m_t=m_t^-+K_t(y_t-H_tm_t^-),\qquad
P_t=P_t^--K_tS_tK_t^\top.
$$
The <posterior covariance matrix> subtracts a <positive semidefinite matrix>, reflecting the information supplied by the measurement. Even if the <innovation> is zero and the mean does not move, the uncertainty can decrease. In this linear <Gaussian> model the <posterior covariance matrix> depends on the observation geometry and its uncertainty, rather than on the numerical observed value.

The derivation is one application of <Gaussian conditional expectation> per measurement. Before observing $y_t$, the state and observation have joint <covariance matrix>
$$
\operatorname{Cov}\begin{pmatrix}x_t\\y_t\end{pmatrix}
=
\begin{pmatrix}
P_t^-&P_t^-H_t^\top\\
H_tP_t^-&S_t
\end{pmatrix}.
$$
Conditioning the upper block on the lower block gives exactly the two update equations. The upper-right block explains the <Kalman gain>: a measured component corrects a state component only to the extent that their prediction errors have <covariance>. The measurement can therefore improve an unobserved <velocity> when a <state-space model> correlates its error with an observed <position>.