Course:CPSC522/Kalman filter

From UBC Wiki
Jump to navigation Jump to search


The Kalman filter is a type of Bayesian filter used to estimate the system state of a linear system over time given inaccurate or noisy state measurements.

Principal Author: Jocelyn Minns
Collaborators: Kevin Dsouza


The Kalman filter is a type of Bayesian filter used to estimate the system state of a linear system over time given inaccurate or noisy state measurements. The filter is divided into two distinct parts: the estimation over time given the control and incorporating the system measurements to the estimation. The combination of these two parts yields a more accurate result than either method individually. We will give an overview of the Kalman filter, look at the the algorithm and provide an example of the filter in use.

Builds on

Kalman filter is recursive online filter that calculates an estimation of the true state as a Gaussian distribution using the probability density functions (PDF).

Related Pages



Kalmin filters were created by Rudolf E. Kálmán in 1960, although others have been credited for similar algorithms near the same time[1]. Kalman filters address the problem with updating the state information when the state data is noisy or inaccurate. Say you want to know the position, with high accuracy, of an autonomous vehicle that traveling along a straight road. On the surface, this seems to be a very simple problem. Say the vehicle has the information on the throttle and the GPS. To update the position of the vehicle over a given time estimate you could calculate the distance travelled based on the throttle, but the throttle applied is not equivalent to the acceleration since a number of physical forces may interfere. The alternative is to rely on the GPS system for position, but these readings also have a large error. The Kalman filter combines these two position estimations to produce an estimation with higher accuracy than either one on its own.

The Kalman filter has two distinct step. Estimation of the state given the control vector and incorporating the state measurements into the estimation

The Kalman filter produces a state estimation represented as a Gaussian distribution over mean and covariance , given the previous state , the control vector and the position measurements . The control vector is the combination of any actions taken on the system. For example: say we have a robot with two motors that control each degree of freedom. Then the control vector would be the accelerations in each direction at time t. The position measurements is the readings of the current system state at time t given from some type of sensor. The filter can run recursively thus it is not needed to remember the previous location estimations or measurements.

The first implementation of the filter was used in the Apollo program for trajectory estimations. Since then it has become common in guidance and navigation systems in aircrafts and spacecrafts[1]. The Kalman filter is best suited for filtering and prediction on linear Gaussian systems with continues states. It has also been used for time series analysis in signal processing.

Kalman filters are a type of Bayesian filter so it must hold the Markov assumptions of a Bayesian filter. Three other properties must also hold[2]:

  1. The state transition probability must be a linear function in its arguments. This can be expressed with the equation where
    • is a state vector at time i
    • is a control vector at time i
    • is a matrix that describes the linear transition from the previous state
    • is a matrix that describes the linear transition from of the state from the control vector
    • is a Gaussian random variable that models the uncertainty introduced by the state transition such that
  2. The measurement probability must also be a linear function in its arguments. This can be expressed by the function where
    • is a matrix that describes the linear transition of the state to the state measurements
    • is a Gaussian random variable that models the uncertainty of the measurements such that
  3. The initial belief of the of the system state must be normally distributed with mean and


With the properties listed above, we can derive the algorithm shown below[2]. In lines 1 and 2, we make a predicted estimate of the mean and covariance given only the linear model of the system change from time t-1 to t. This step does not take into account measurements of the state at time t. Next, in lines 3-5, we incorporate the measurements given. At line 3, we calculate the Kalman gain. This specifies the degree of belief of the accuracy of the measurements. If Kt is large, then we have a large degree of confidence in the measurements so they will play a large part in our final estimation. Lines 4 and 5, we calculate the final state estimation and .

Algorithm Kalman_Filter(mu_prev, sigma_prev, u, z)
1:  mu_tilde := A*mu_prev + B*u                     \\ predict the mean
2:  sigma_tilde := A*sigma_prev*A' + R              \\ predict the covariance 
3:  K := sigma_tilde*C'*(C*sigma_tilde*C' + Q)'     \\ get the Klaman Gain
4:  mu := mu_tilde + K*(z-C*mu_tilde)               \\ update mean given measurements  
5:  sigma := (I - K*C)*sigma_tilde                  \\ update covariance given measurements  
6:  return mu, sigma

Practical Example

An illustration of the steps of an iteration of the Kalman filter[2]. a) The initial . b) The prediction . c) The measurement data . d) The new estimation .

In this section, we will show how to build the needed matrices A, B, and C for the Kalman filter algorithm. We can return to the autonomous vehicle example. We want to get the position of the vehicle and we are given the throttle and the GPS data. Before we give the data to he Kalman filter, we will do some simple linear transformation (with no adjustments for the known errors) such that the throttle will be converted into the expected acceleration and the GPS signal will be converted to the expected vehicle position. We can then define the system as such:

We will define the position vector as: were is the position and is the velocity

Next we remember Newton’s Laws of motion and . Then we get he matrices:

These will be constant for all iterations thus we drop the subscript t

Since the data readings give us the position x, we can define C simply as

Often there is no simple way to determine distribution of the error since it varies widely from model to model. Since we are using a Kalman filter, we will assume a Gaussian distribution of the error and we will leave the covariance as and .

Thus we have all the needed equations for the Kalman filter.

Annotated Bibliography

  1. 1.0 1.1 Wikipedia: "Kalman filter"
  2. 2.0 2.1 2.2 Thrun, Sebastian, et al. Probabilistic Robotics. MIT Press, 2010.

To Add

Put links and content here to be added. This does not need to be organized, and will not be graded as part of the page. If you find something that might be useful for a page, feel free to put it here.

Some rights reserved
Permission is granted to copy, distribute and/or modify this document according to the terms in Creative Commons License, Attribution-NonCommercial-ShareAlike 3.0. The full text of this license may be found here: CC by-nc-sa 3.0