What Is a Kalman Filter?
The Kalman filter is an algorithm that fuses multiple sources of information to estimate the state of a dynamic system. It does this by combining predictions from a mathematical model with noisy measurements, producing an optimal estimate in the leastsquares sense when the underlying noise is Gaussian.
Why Use It?
- Realtime performance: The equations are recursive, requiring only the previous estimate and the newest measurement.
- Robustness to noise: It explicitly models measurement and process noise, weighing each source appropriately.
- Broad applicability: Navigation, finance, robotics, economics, and many engineering fields rely on it.
Key Concepts
State Vector
The state vector x contains all quantities needed to describe the system at a given instant (position, velocity, temperature, etc.).
Process Model
Often written as
x = Fx + Bu + w
where F is the statetransition matrix, B maps control inputs u, and w is process noise with covariance Q.
Measurement Model
Relates the hidden state to observable data:
z = Hx + v
H maps the state to the measurement space, and v is measurement noise with covariance R.
The TwoStep Cycle
- Prediction (Time Update)
- Predict the next state:
x| = Fx| + Bu - Predict the error covariance:
P| = FP|F + Q
- Predict the next state:
- Update (Measurement Update)
- Compute the Kalman gain:
K = P|H(HP|H + R) - Correct the state estimate:
x| = x| + K(z Hx|) - Update the covariance:
P| = (I KH)P|
- Compute the Kalman gain:
Simple Example: OneDimensional Position Tracking
Assume a vehicle moves along a straight line. The state vector contains position p and velocity v:
x = [p; v]
With a sampling interval t, the transition matrix is
F = [[1, t], [0, 1]]
If a GPS sensor provides noisy position measurements z = p + noise, the measurement matrix is
H = [1, 0]
Choosing appropriate covariances Q and R, the filter continuously corrects the velocity estimate even though the sensor never measures velocity directly.
Extensions and Variants
- Extended Kalman Filter (EKF): Linearizes nonlinear models by using Jacobians.
- Unscented Kalman Filter (UKF): Propagates a set of sigma points through the nonlinear functions, often yielding better performance than EKF.
- Information Filter: Works with the inverse covariance (information matrix), useful when many measurements share the same state.
- Ensemble Kalman Filter (EnKF): Uses MonteCarlo ensembles, popular in meteorology and largescale geophysical modeling.
Implementation Tips
- Start with a simple linear model. Validate the filter with synthetic data where the true state is known.
- Make sure
QandRreflect realistic uncertainties. Overconfident covariances cause divergence. - Monitor the innovation (measurement residual). Its covariance should match the predicted value; large discrepancies hint at model mismatch.
- When dealing with poorly conditioned matrices, use numerically stable forms such as the Joseph covariance update.
- For highdimensional problems, consider squareroot filters to preserve positive definiteness.
Common Pitfalls
- Incorrect noise modeling: Assuming too low process noise can make the filter ignore new measurements.
- NonGaussian noise: The optimality of the Kalman filter relies on Gaussian assumptions; heavytailed noise may require robust alternatives.
- Discretetime vs. continuoustime: Mixing continuous equations with discrete updates leads to instability.
Further Reading
Wikipedia Kalman filter
Kalman Filter website tutorials and examples
A survey of Kalman filtering and its extensions
