Kalman Filters
Tracking a hidden number by blending what motion predicts with what the sensor says, trusting each exactly as much as its uncertainty earns.
Why Does This Exist?
A robot never sees its position. It sees wheel odometry that drifts and GPS fixes that jitter, and it must turn both into one best guess that updates as it moves. Averaging them with fixed weights fails the moment conditions change: in a tunnel the GPS deserves no vote, on open road it deserves a large one. What is needed is a blend whose weights breathe with the uncertainties.
The Kalman filter is that blend for the linear-Gaussian world, and it is optimal there: no other estimator has smaller mean squared error. Motion and sensing are both linear with additive Gaussian noise, the belief stays Gaussian forever, and each step is two closed-form moves: predict forward through motion, then correct with the observation. When the world goes nonlinear or the noise goes multimodal, this page is still the right prerequisite, because every successor (particle filters, extended and unscented variants) is best understood as what you reach for when one Kalman assumption breaks. The Gaussian machinery underneath is in multivariate Gaussians, and the time structure is a Markov chain.
The one idea you need first
A Gaussian stays Gaussian through linear maps and conditioning. So if the state starts Gaussian and every transition and observation is linear plus Gaussian noise, the posterior after any number of steps is still Gaussian, fully described by a mean and a covariance. The filter just tracks those two.
Think of It Like This
A navigator blending dead reckoning with landmarks
A sailor dead-reckons: from the last fix, speed and heading say where you should be, but errors accumulate with every mile. Then a lighthouse bearing arrives: it says where you are, but the bearing itself has error.
The sailor does not pick one. On a foggy night with a sharp log, the reckoning gets most of the vote. After a long run with no fixes followed by a crisp noon sight, the sight dominates. The blend ratio is set by the two uncertainties, and after fusing, the sailor is more confident than either source alone.
Where the analogy stops: the filter also tracks how that confidence evolves, growing it during blind motion and shrinking it at each sighting, by exact arithmetic rather than judgement.
How It Actually Works
State evolves and observation arrives by
where is the motion matrix, maps state to sensor, has covariance (motion noise), and has covariance (sensor noise). The belief is (mean) with (covariance).
Predict. Push through motion: , . Uncertainty always grows here: motion adds .
Update. Compute the Kalman gain , then and . In plain words: is prediction-uncertainty divided by total uncertainty, so a precise sensor ( small) pulls hard toward the reading and a vague one barely nudges.
Worked example
Scalar tracking, static state (, ). Prior with , motion noise , reading with .
Predict: unchanged, .
Gain: . The sensor earns a 69 percent vote because against is the more precise of the two.
Update: . Covariance: , below both and : fusing beats either source alone.
Watch Out For
Running a linear filter on a nonlinear world
Apply the standard equations to a radar that measures range and bearing, or a pendulum near horizontal, and the linearization point drifts while and pretend the world is flat. The covariance shrinks exactly as if the linear model were true, so the filter grows confident around a wrong estimate and starts rejecting the very readings that could save it.
Symptom: normalized residuals (innovations divided by their predicted spread) drift far above 1 while the reported stays small. Fix: use an extended or unscented variant for mild nonlinearity, and move to particle filters when posteriors go multimodal.
Letting the covariance go asymmetric or negative
must stay symmetric positive definite, but the update subtracts two nearly equal matrices in finite precision. After thousands of steps can develop a tiny asymmetry or a negative eigenvalue, and then the next gain is garbage: uncertainty that should shrink explodes instead.
Symptom: filter diverges after long healthy runs, with showing asymmetry beyond or negative diagonal entries. Fix: use the Joseph form , symmetrize each step with , and never invert the innovation covariance without checking its conditioning.
The Quick Version
- A Kalman filter tracks a Gaussian belief through linear motion and linear sensing, alternating predict and update.
- The Kalman gain weights the reading by prediction-uncertainty over total uncertainty.
- In the worked pass, prior 2.0 and reading 2.5 fuse to 2.34 with variance 0.34, better than either source.
- Prediction always grows uncertainty; update always shrinks it.
- Nonlinear or non-Gaussian worlds need extended, unscented, or particle variants.
- Guard the covariance update numerically or long runs diverge.