Kalman Filter

The Kalman filter (WB95) estimates the inaccessible internal state $\mathbf{x}\in\mathbb{R}^{n}$ of a discrete-time system in the presence of disturbances, assuming complete knowledge of the system model. In fact, the Kalman filter is the optimal recursive estimator: if the noise is Gaussian, it provides the least-squares estimate of the system's internal state.

For historical reasons, the term Kalman filter properly refers only to filtering a system whose state transition and observation are linear functions of the current state.

According to linear systems theory, the dynamics of a “linear” continuous-time system are represented by a differential equation of the form

\begin{displaymath}
\dot{\mathbf{x}} = \mathbf{A}(t) \mathbf{x}(t) + \mathbf{B} \mathbf{u}(t) + \mathbf{w}(t)
\end{displaymath} (3.11)

which describes the state update, together with an indirect observation of the state through a linear system:
\begin{displaymath}
\mathbf{z}(t) = \mathbf{H}(t) \mathbf{x}(t) + \mathbf{v}(t)
\end{displaymath} (3.12)

where $\mathbf{z} \in \mathbf{R}^{m}$ is the observable.

The discrete-time Kalman filter is suitable for real systems, in which the world is sampled at discrete intervals. It transforms the continuous-time linear system into a linear system of the form

\begin{displaymath}
\left\{
\begin{array}{l}
\mathbf{x}_{k+1} = \mathbf{A}_{k} ...
...mathbf{H}_k \mathbf{x}_{k} + \mathbf{v}_{k}
\end{array}\right.
\end{displaymath} (3.13)

A system that evolves according to this model is called a Linear-Gaussian State Space Model or Linear Dynamic System. If the matrix values are time-invariant, the model is called stationary.

The variables $w_{k}$ and $v_{k}$ represent process and observation noise, respectively, with zero mean $\bar{w_k}=\bar{v_k}=0$ and known covariance matrices $\mathbf{Q}$ and $\mathbf{R}$, respectively (assuming white Gaussian noise). $\mathbf{A}$ is a state transition matrix $n \times n$, $\mathbf{B}$ is a matrix $n \times l$ that relates the optional control input $\mathbf{u} \in \mathbb{R}^{l}$ to the state $\mathbf {x}$, and finally $\mathbf{H}$ is a matrix $m\times n$ that relates the state to the measurement $\mathbf{z}_{k}$. All these matrices, which represent the system model, must be known precisely; otherwise, systematic errors will be introduced.

The Kalman filter is a recursive estimator that requires, at each iteration, the state estimate from the previous step $\hat{\mathbf{x}}_{k-1}$ and the current observation $\mathbf{z}_k$, an indirect observation of the system state.

Let $\hat{\mathbf{x}}^{-}_{k}$ be the prior estimate of the system state, based on the estimate at time $k-1$ and the problem dynamics, and let $\hat{\mathbf{x} }_{k}$ be the posterior state estimate after observing $\mathbf{z}_k$, based on that observation. These definitions allow us to define the prior and posterior estimation errors as

\begin{displaymath}
\begin{array}{l}
\mathbf{e}^{-}_{k} = \mathbf{x}_k - \hat{\...
...bf{e}_{k} = \mathbf{x}_k - \hat{\mathbf{x}}_{k} \\
\end{array}\end{displaymath} (3.14)

The corresponding prior and posterior covariance matrices are
\begin{displaymath}
\begin{array}{l}
\mathbf{P}^{-}_k = \E[\mathbf{e}^{-}_k {\m...
...\mathbf{P}_k = \E[\mathbf{e}_k \mathbf{e}^{\top}_k]
\end{array}\end{displaymath} (3.15)

respectively.

The Kalman filter aims to minimize the posterior error covariance $\mathbf{P}_k$ and provide a way to estimate $\hat{\mathbf{x} }_{k}$ given the prior estimate $\hat{\mathbf{x}}^{-}_{k}$ and the observation $\mathbf{z}_k$.

The Kalman filter provides a posterior state estimate as a linear combination of the previous state estimate and the observation error:

\begin{displaymath}
\hat{\mathbf{x}}_{k} = \hat{\mathbf{x}}^{-}_{k} + \mathbf{K}_k( \mathbf{z}_k - \mathbf{H}_k \hat{\mathbf{x} }^{-}_{k})
\end{displaymath} (3.16)

This reduces the estimation problem to finding the gain factor $\mathbf{K}_k$ (blending factor). The difference $\mathbf{z}_k - \mathbf{H}_k \hat{\mathbf{x} }^{-}_{k}$ is called the residual, or innovation, and represents the discrepancy between the predicted and actual observations. Note that the metric used to compute the residual may depend on the specific problem. The Kalman filter is usually presented in two stages: time update (prediction) and measurement update (observation).

The first stage computes the prior estimate of both $\hat{\mathbf{x}}_k$ and its covariance $\mathbf{P}_{k}$. The prior estimate $\hat{\mathbf{x}}^{-}_{k}$ is obtained from knowledge of the system dynamics (3.13):

\begin{displaymath}
\hat{\mathbf{x}}^{-}_{k} = \mathbf{A}_{k-1} \hat{\mathbf{x}}_{k-1} + \mathbf{B}_{k-1} \mathbf{u}_{k-1}
\end{displaymath} (3.17)

The prior estimate of the error covariance is updated in the same way:
\begin{displaymath}
\mathbf{P}^{-}_{k} = \mathbf{A}_{k-1} \mathbf{P}_{k-1} \mathbf{A}_{k-1}^{\top} + \mathbf{Q}_{k-1}.
\end{displaymath} (3.18)

These are the best prior estimates of the state and covariance at time $k$, before observing the system.

In the second stage, the gain is computed:

\begin{displaymath}
\mathbf{K}_k = \mathbf{P}^{-}_{k} \mathbf{H}_k^{\top} \left...
...hbf{P}^{-}_{k} \mathbf{H}_k^{\top} + \mathbf{R}_k \right)^{-1}
\end{displaymath} (3.19)

This minimizes the posterior covariance. The state is then updated using this gain, according to Equation (3.16).

Using this value for the gain $\mathbf{K}$, the posterior covariance matrix becomes

\begin{displaymath}
\mathbf{P}_{k} = (\mathbf{I} - \mathbf{K}_k \mathbf{H}_k) \mathbf{P}^{-}_{k}
\end{displaymath} (3.20)

To unify the different variants of Kalman filters, these equations can be rewritten using the variance-covariance matrices

\begin{displaymath}
\begin{array}{l}
\cov (x_k, z_k) = \mathbf{P}^{-}_{k} \mat...
...mathbf{H}_k \mathbf{P}^{-}_{k} \mathbf{H}_k^{\top}
\end{array}\end{displaymath} (3.21)

so that Equation (3.19) can be written as
\begin{displaymath}
\mathbf{K}_k = \cov (x_k, z_k) \left( \cov (z_k) + \mathbf{R}_k \right)^{-1}
\end{displaymath} (3.22)

and substituting the covariances (3.21) into (3.20) gives
\begin{displaymath}
\mathbf{P}_{k} = \mathbf{P}^{-}_{k} - \mathbf{K}_k \cov (x_k, z_k)^{\top}
\end{displaymath} (3.23)

As can readily be seen, neither the covariance matrix nor the Kalman gain depends on the state, the observations, or the residual; they evolve independently.

The Kalman filter nevertheless requires initial values for the state variable and covariance matrix: the initial state should be as close as possible to the true value, and the degree of confidence in this value should be encoded in the initial covariance matrix.



Subsections
Paolo medici
2026-10-19