Kalman Filters
Kalman Filters
Kalman Filters
Overview
What could Kalman Filters be used for in Hydrosciences? What is a Kalman Filter? Conceptual Overview The Theory of Kalman Filter (only the equations you need to use) Simple Example (with lots of blah blah talk through handouts)
2
A Hydro Example
Suppose you have a hydrologic model that predicts river water level every hour (using the usual inputs). You know that your model is not perfect and you dont trust it 100%. So you want to send someone to check the river level in person. However, the river level can only be checked once a day around noon and not every hour. Furthermore, the person who measures the river level can not be trusted 100% either. So how do you combine both outputs of river level (from model and from measurement) so that you get a fused and better estimate? Kalman filtering
3
Graphically speaking
External Controls
System
System State (desired but not known)
Sometimes the system state and the measurement may be two different things (not like river level example)
Observed Measurements Optimal Estimate of System State
Measuring Devices
Measurement Error Sources
Estimator
System state cannot be measured directly Need to estimate optimally from measurements
6
Recursive?
Doesnt need to store all previous measurements and reprocess all data each time step
7
Conceptual Overview
Simple example to motivate the workings of the Kalman Filter The essential equations you need to know (Kalman Filtering for Dummies!) Examples: Prediction and Correction
Conceptual Overview
Lost on the 1-dimensional line (imagine that you are guessing your position by looking at the stars using sextant) Position y(t) Assume Gaussian distributed measurements
9
Conceptual Overview
0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 0
10
20
30
40
50
60
70
80
90
100
Sextant Measurement at t1: Mean = z1 and Variance = z1 Sextant is not perfect Optimal estimate of position is: (t1) = z1 Variance of error in estimate: 2x (t1) = 2z1 Boat in same position at time t2 - Predicted position is z1
10
Conceptual Overview
0.16 0.14
10
20
30
40
50
60
70
80
90
100
So we have the prediction -(t2) GPS Measurement at t2: Mean = z2 and Variance = z2 Need to correct the prediction by Sextant due to measurement to get (t2) Closer to more trusted measurement should we do linear interpolation?
11
Conceptual Overview
prediction -(t2)
0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 0
measurement z(t2)
Kalman filter helps you fuse measurement and prediction on the basis of how much you trust each
(I would trust the GPS more than the sextant)
10
20
30
40
50
60
70
80
90
100
Corrected mean is the new optimal estimate of position (basically youve updated the predicted position by Sextant using GPS New variance is smaller than either of the previous two variances
12
Optimal estimate () = Prediction + (Kalman Gain) * (Measurement - Prediction) Variance of estimate = Variance of prediction * (1 Kalman Gain)
13
Conceptual Overview
0.16
10
20
30
40
50
60
70
80
90
100
At time t3, boat moves with velocity dy/dt=u Nave approach: Shift probability to the right to predict This would work if we knew the velocity exactly (perfect model)
14
Conceptual Overview
0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 0
(t2)
Prediction -(t3)
10
20
30
40
50
60
70
80
90
100
Better to assume imperfect model by adding Gaussian noise dy/dt = u + w Distribution for prediction moves and spreads out
15
Conceptual Overview
0.16 0.14 0.12 0.1 0.08 0.06
10
20
30
40
50
60
70
80
90
100
Now we take a measurement at t3 Need to once again correct the prediction Same as before
16
Conceptual Overview
Lessons learnt from conceptual overview:
Initial conditions (k-1 and k-1) Prediction (-k , -k) Measurement (zk)
Correction (k , k)
Use initial conditions and model (eg. constant velocity) to make prediction Take measurement Use measurement to correct prediction by blending prediction and residual always a case of merging only two Gaussians Optimal estimate with smaller variance
17
Blending Factor
If we are sure about measurements:
Measurement error covariance (R) decreases to zero K decreases and weights residual more heavily than prediction
18
Pk = (I - KH)P-k
19
20
What if the noise is NOT Gaussian? Given only the mean and standard deviation of noise, the Kalman filter is the best linear estimator. Non-linear estimators may be better. Why is Kalman Filtering so popular? Good results in practice due to optimality and structure. Convenient form for online real time processing. Easy to formulate and implement given a basic understanding. Measurement equations need not be inverted. ALSO popular in hydrosciences, weather/oceanography/ hydrologic modeling, data assimilation 21
Now ..to understand the jargons (You may begin the handouts)
First read the hand out by PD Joseph Next, read the hand out by Welch and Bishop titled An Introduction to the Kalman Filter. (you can skip pages 4-5, 711). Pages 7-11 are on Extended Kalman Filtering (for non-linear systems). Read the solved example from pages 11-16.
22
Homework (conceptual)
Explain in NO MORE THAN 1 PAGE the example that you read from pages 11-16 in the handout by Welch and Bishop. Basically, I want you to give me a simple conceptual overview of why and how filtering was applied using the previous analogy on a boat lost in sea. DUE Same date as the Class project report. EXTRA CREDIT 5% marks If you review (3-4 pages) the classic paper in 1960 by Kalman (hand out) EXTRA CREDIT 5% marks if you turn in a detailed summary of the STEVE software (pros/cons, what it is etc.)
23
References
1. 2. Kalman, R. E. 1960. A New Approach to Linear Filtering and Prediction Problems, Transaction of the ASME--Journal of Basic Engineering, pp. 35-45 (March 1960). Welch, G and Bishop, G. 2001. An introduction to the Kalman Filter, http://www.cs.unc.edu/~welch/kalman/
By the way Dr. Rudolf Kalman is alive and living well today
24