Professional Documents
Culture Documents
The Scalar Kalman Filter
The Scalar Kalman Filter
The Scalar Kalman Filter
Back
This document gives a brief introduction to the derivation of a Kalman filter when the
input is a scalar quantity. It is split into several sections:
Equation 1
where the state, xj, is a scalar, a and b are constants and the input uj is a
scalar; j represents the time variable. Note that many texts don't include
the input term (it may be set to zero), and most texts use the variable k to
represent time. I have chosen to use j to represent the time variable
because we use the variable k for the Kalman filter gain later in the text.
Equation 1 can be represented pictorially as shown below, where the block
with T in it represents a time delay..
Figure 1
Now imagine some noise is added to the process such that:
Equation 2
The noise, w, is white noise source with zero mean and covariance Q and
is uncorrelated with the input. The process can now be represented as
shown:
Figure 2
Given a situation like the one shown above, a typical question might be:
Can we filter the signal x so that the effects of the noise w are minimized?
The answer, it turns out is yes. However, with Kalman filters we can go
one step further.
Let us assume that the signal x is measured, and the measured value is z.
Equation 3
The task of the Kalman filter can now be stated as: Given a system such as
the one shown above, how can we filter z so as to estimate the variable x
while minimizing the effects of w and v?
Figure 4
This approach has two glaring weakness. The first is that there is no
correction. If we don't know the quantities a, b or h exactly (or the initial
value x0), the estimate will not track the exact value of x. Secondly, we
don't compensate for the addition of the noise sources (w and v). An
improved setup which takes care of both of these problems is shown
below.
Figure 5
This figure is much like the previous one. The first difference noted is that
the original estimate of xj is now called x^j-; we will refer to this as the a
priori estimate.
Equation 4
We use this a priori estimate to predict an estimate for the output, z^j. The
difference between this estimated output and the actual output is called the
residual, or innovation.
Equation 5
Equation 6
The only task now is to find the quantity k that is used to refine our
estimate, and it is this process that is at the heart of Kalman filtering.
To begin, let us define the errors of our estimate. There will be two errors,
an a priori error, ej-, and an a posteriori error, ej. Each one is defined as the
difference between the actual value of xj and the estimate (either a priori or
a posteriori).
Equation 7
Equation 8
Equation 9
Equation 10
Equation 11
Equation 12
Equation 13
Equation 14
Again, we can use the orthogonality condition from equation 12 to set the
last term to zero, so:
Equation 15
where we used the simplification from equation 13 for the first term in the
expression, and using the definition of the measurement noise for the
second term.
Equation 16
However, there is still a problem because this expression needs a value for
the a priori covariance which in turn requires a knowledge of the system
variable xj. Therefore our next task will be to come up with an estimate
for the a priori covariance.
Before we move on, let's look at this equation in detail. First not that the
"constant", k, changes at every iteration. For this reason it should really
be written with a subscript (i.e., kj). We'll be more careful about this
later.
The middle term drops out as before because the process noise is
uncorrelated with previous values of the either the state or its a priori
estimate.
Equation 17
so
Equation 18
We are still not finished, however, because we need an expression for pj,
the a posteriori estimate.
Equation 19
The middle term drops out as before because the measurement noise is
uncorrelated with the current values of the either the state or its a priori
estimate.
Equation 20
So
Equation 21
Equation 22
Equation 23
Predictor Step
Corrector Step
Notation
Variable in this More Common Notation
Document
time
variable
j k
state xj x(k)
system
gains
a, b, h a, b, h (note: b is often 0)
input uj u(k) (note: often there is no input)
output zj z(k)
gain kj Kk
a priori
estimate
a posteriori
estimate
a priori
covariance
pj- p(k|k-1) or p(k+1|k)
a posteriori
covariance
pj p(k|k) or p(k+1|k+1)
The notation
Examples
1. Example of estimating a constant (along with Matlab code).
2. Example of estimating a first order process (along with Matlab
code).
Going further
A matrix based (higher order system) Kalman filter is a simple extension
of the scalar case presented here. The results are given here, a full
description of the mathematics can be found in the reference [3].
References
[1] An Introduction to Kalman Filters, G Welch and G Bishop,
http://www.cs.unc.edu/~welch/kalman/kalman_filter/kalman.html. See
also their other introductory information on Kalman Filters.