Project - Kalman Filter
What is Kalma Filter
The Kalman Filter is a mathematical algorithm used for estimating and predicting the state of a dynamic system, particularly in the presence of noisy or uncertain data. It consist of five equations.
Predict State
Predict State:
Predict Noise:
Update State
Kalman Gain:
Update State:
Update Noise:
State Extrapolation Equation
Item | Mean |
---|---|
predicted system state vector at time step | |
estimated system state vector at time step | |
a control variable or input variable - a measurable (deterministic) input to the system | |
a process noise or disturbance - an unmeasurable input that affects the state | |
a state transition matrix | |
a control matrix or input transition matrix (mapping control to state variables) |
Prediction
Update
Get the best estimation using the measurment.
Kalman gamin.
Update the noise distribution of best estimates.
Important basic concepts
- Mean
- Expectation: The mean of multiple measurements, similar with mean
- Variance:
- Standard Variance:
- Normal Distribution (All called Gaussian Distribution)
Typically, measurement errors are normally distributed. The Kalman filter assumes that the measurement errors have a normal distribution. - Estimation: An estimate of the hidden state of the system.
- Accuracy: Describes how close a measured value is to the true value.
- Precision: Describes the deviation distribution of a series of measured values relative to the same true value
Info
High-precision systems have measurements with very low variance (i.e., low uncertainty), while low-precision systems have high variance (i.e., high uncertainty).
Info
Typically, measurement errors are normally distributed. The Kalman filter assumes that the measurement errors have a normal distribution.
Example
How to measure a gold
How to weight a

Info
item | mean |
---|---|
The true weight of the gold. | |
The measurement of gold. | |
The estimation of | |
It is the prediction of the future state (time | |
The estimated value of | |
Apriori estimate - a prediction of the system state at time n at time n−1 (Annotation: for the |
In order to estimate
A more realistic consideration is that it is best to only store the estimated value

Formula | Meaning |
---|---|
The mean of measurement | |
The orange item is the estimation at time n-1 | |
The final formula |
The final formula is the status update equation. One of five equations of Kalman filter.
Track constant velocity car in one-dimension
Accelerate:
Velocity prediction:
Velocity update:
How to track a Car

Position | |
Speed |
The two formula could be transfored into
Then the formulas could be transformed into
How to track a plane
If we want to track a plane, how to do it.
The state will be
Info
Item | Mean |
---|---|
The position of an airplan | |
The initial postion | |
The initial speed | |
The acceleration | |
Sample period |
Predict State
Predict State:
Predict Noise:
Update States
Kalman Gain:
Update State:
Update Noise:
1. State Extrapolation equation
Item | Mean |
---|---|
Predicted system state vector at time step | |
Estimated system state vector at time step | |
Control variable or input variable - a measurable (deterministic) input to the system | |
process noise or disturbance - an unmeasurable input that affects the state | |
state transition matrix | |
control matrix or input transition matrix (mapping control to state variables) |
Airplane without control input
Consider an airplane moving in three-dimensional space with constant acceleration.
The state vector
The state transition matrix
The state extrapolation equation is:
Airplane with control input
The state vector
The control vector
The state transition matrix:
The control matrix:
Thus the state prediction formula
2. Covariance extrapolation equation
Item | Mean |
---|---|
The squared uncertainty of an estimate (covariance matrix) of the current state | |
The squared uncertainty of a prediction (covariance matrix) for the next state | |
The state transition matrix that we derived in the "Modeling linear dynamic systems" section | |
The process noise matrix |
Estimate covariance without process noise
Assume that the process noise is equal to zero (Q=0)
Becuase of:
Thus,
Because of the state prediction like
Therefore:
Estimate covariance with process noise
Becuase of process noise
Where
We've seen that the process noise variance has a critical influence on the Kalman Filter performance. Too small
The process noise can be independent between different state variables. In this case, the process noise covariance matrix
The process noise can also be dependent. For example, the constant velocity model assumes zero acceleration (
There are two models for the environmental process noise.
- Discrete noise model
- Continuous noise model
3. Measurement equation
The generalized measurement
Item | Mean | Dimension |
---|---|---|
measurement vector | ||
true system state (hidden state) | ||
Random noise vector | ||
an observation matrix |
In many cases, the measured value is not the desired system state. For example, a digital electric thermometer measures an electric current, while the system state is the temperature. There is a need for a transformation of the system state (input) to the measurement (output).
The purpose of the observation matrix
Scaling
A range meter sends a signal toward a destination and receives a reflected echo. The measurement is the time delay between the transmission and reception of the signal. The system state is the range.
In this case, we need to perform a scaling:
Item | Desc |
---|---|
The speed of light | |
The range | |
The measured time delay |
State Selection
Sometimes certain states are measured while others are not. For example, the first, third, and fifth states of a five-dimensional state vector are measurable, while the second and fourth states are not measurable:
Combination of States
Sometimes some combination of states can be measured instead of each separate state. For example, maybe the lengths of the sides of a triangle are the states, and only the total perimeter can be measured:
4. State Update Equation
The State Update Equation in the matrix form is given by
Item | Mean | Dimensions |
---|---|---|
Estimated system state vector at time step | ||
Predicted system state vector at time step | ||
Kalman Gain | ||
Measurement | ||
observation matrix |
Pay attention to the dimensions. If, for instance, the state vector has 5 dimensions, while only 3 dimensions are measurable (the first, third, and fifth states):
5. Covariance update equation
Item | Mean |
---|---|
The squared uncertainty of an estimate (covariance matrix) of the current state | |
The squared uncertainty of a prediction (covariance matrix) for the next state | |
The state transition matrix that we derived in the "Modeling linear dynamic systems" section | |
The process noise matrix |
The Estimate covariance without process noise
Assume the process noise is equals to zero (
According to the state extrapolation equation:
Therefore,
6. Simpllified covariance update equation
7. The Kalman gain
Item | Mean |
---|---|
Kalman Gain | |
The prior estimate covariance matrix of the current state (predicted at the previous step) | |
Observation matrix | |
The measurement noise covariance matrix |
Derivation of the Kalman Gain Equation
Notes | |
---|---|
Covariance Update Equation | |
Apply the matrix transpose property: | |
Expand | |
Group the last two terms |