# Kalman Filtering

Kalman filtering is an algorithm that tries to reconcile outputs from a mathematical model of a physical system and observations of the same system. It combines these two in such a way as to smooth out noise coming from inaccurate observations in an effort to more accurately estimate the true state of the system at the present time.

Consider the process given by the stochastic difference equation

with the control variables, and consider also measurements

where and represent noise terms, and are assumed to be independent multivariate normals with distributions

It should be recognised that this is somewhat of a special case of the usual Kalman filter, because one may well expect the noise to vary over time, and so then the above would be indexed by .

The algorithm is as follows

- At time , given the previous a posteriori estimates of the system, a prediction is made based upon the prior belief or physical dynamics of the system at time .
- The system is observed at time and this observation is used to correct the a priori estimate and produce an updated estimate .
- Repeat for time .

The above algorithm handles the case that the update as linear. There is absolutely no reason to expect this to be the case and the algorithm can be altered to allow for non-linearities. In the non-linear case we must add a step in the procedure so that we can make the linear Kalman filter applicable. This new procedure is called the extended Kalman filter.

Here, instead of having a relation as in the first equation we have a relation

where is non-linear, and is again the noise term, and we have measurements

Now we assume, if , with derivatives and respectively, that the estimate is given by

for some and to be determined and we have

where K is the so-called Kalman gain matrix. Observe that this linearises the problem, and we thus use the linear Kalman filter as above on this model. This however may be poor if our function is highly non-linear.

The main advantage of using the Kalman filter in practice is that it finds solutions to an estimation problem sequentially and thus reduces the computational cost and time so that it can be performed as and when an observation is made.