What is Kalman Filter?
A Kalman Filter is a recursive Bayesian estimator that computes the filtering mean and covariance for a linear state-space model from noisy, sequential observations.
Quick Facts
| Specification | Official Specification |
|---|
How It Works
Predict a state and its uncertainty
For x_k = F x_(k-1) + B u_k + w_k with w_k ~ N(0, Q), prediction computes m_k^- = F m_(k-1) + B u_k and P_k^- = F P_(k-1) F^T + Q. The mean follows the dynamics while process noise increases uncertainty. A missing observation normally means retaining this prediction rather than inventing a correction.
Kalman's 1960 paper formulates recursive linear filtering and the error-covariance equation. Exact Bayesian Gaussian filtering additionally requires a Gaussian initial state and compatible independent Gaussian noises; with weaker second-moment assumptions, optimality claims must be stated as linear-estimator results.
Correct with the innovation and Kalman gain
For measurement y_k = H x_k + v_k, define innovation r_k = y_k - H m_k^- and innovation covariance S_k = H P_k^- H^T + R. The gain K_k = P_k^- H^T S_k^-1 corrects the mean by K_k r_k; it is a matrix derived from uncertainty, not a manually selected trust percentage.
Do not form a dense inverse when a linear solve or Cholesky factorization is available. The Joseph covariance update (I-KH)P^-(I-KH)^T + K R K^T costs more than the simplified form but better preserves symmetry and positive semidefiniteness under finite precision.
Validate the model with innovation statistics
A smooth trajectory does not prove a calibrated filter. Whitened innovations should be approximately zero-mean, temporally uncorrelated, and consistent with S_k when the model assumptions hold. Persistent bias, autocorrelation, or extreme normalized innovation squared values can reveal wrong dynamics, sensor bias, time misalignment, outliers, or mis-specified Q and R.
Report initialization, discretization, units, missing-data handling, numerical form, innovation coverage, state error on held-out or simulated truth, and latency. Use an Extended or Unscented Kalman Filter for declared nonlinear approximations, a Particle Filter for broader non-Gaussian posteriors, and an RTS Smoother only when future observations are legitimately available.
Key Characteristics
- Maintains a Gaussian state estimate through its mean and covariance
- Alternates model-based prediction with measurement-based correction
- Uses innovation covariance to compute the Kalman gain
- Is exact for a specified linear Gaussian state-space model
- Runs recursively with bounded state memory per time step
- Depends critically on model, noise, initialization, and numerical quality
Common Use Cases
- Real-time position and velocity tracking
- Sensor fusion for navigation and control
- Online estimation of latent time-series components
- State estimation with intermittent measurements
- Reference solutions for validating approximate filters
Example
Loading code...Frequently Asked Questions
When is a Kalman Filter exact?
It gives the exact filtering mean and covariance when the initial state and noises are Gaussian, the transition and observation models are linear, and the stated independence and covariance assumptions hold. Other settings may retain only linear-estimator guarantees or become approximations.
What does the Kalman gain mean?
The gain maps the measurement innovation into a state correction. It depends on predicted state covariance, the observation model, and measurement covariance, so it balances uncertainty by direction rather than acting as one arbitrary scalar smoothing factor.
How should Q and R be chosen?
Derive them from process and sensor error models, calibration data, sampling intervals, and units, then validate with held-out trajectories and innovation statistics. Tuning solely for a visually smooth output can make covariance estimates inconsistent.
What happens when a measurement is missing?
The filter can execute only the prediction step, carrying the predicted mean forward while covariance usually grows through the dynamics and process noise. The implementation should distinguish missing data from a zero-valued measurement.
How is a Kalman Filter different from an RTS Smoother?
Filtering estimates the current state from observations available through the current time. An RTS Smoother first runs that filter and then uses future observations in a backward pass, so it is a fixed-interval retrospective estimator rather than an online replacement.