Interactive Monograph · State Estimation
Every useful quantity in a vehicle, the charge in a pack, the speed of a rotor, the position of a car, is hidden behind noisy, incomplete sensors. A filter is the disciplined way to guess the hidden truth and to know how much to trust the guess. This monograph builds the Kalman filter and its nonlinear successors from scratch, each one running live in your browser.
Suppose you want to know exactly how full a battery is. You cannot measure charge directly; you measure voltage, which is noisy and only loosely related to charge. You also know something about how charge changes: current out means charge down. A filter fuses these two imperfect sources, a model of how the state evolves and a stream of noisy measurements, into a single best estimate, updated every instant.
The trick that makes filtering powerful is that it tracks not just a best guess but an uncertainty around it. When the model is trusted, the estimate leans on prediction; when a clean measurement arrives, it leans on that. The whole method is a rhythm of two steps repeated forever:
Predict: use the model to project the state forward; uncertainty grows. Update: fold in the new measurement; uncertainty shrinks. Repeat.
The Kalman filter is the exact, optimal version of this rhythm when everything is linear and the noise is Gaussian. Its extensions, covered later, keep the rhythm when the world is nonlinear or the uncertainty is not a tidy bell curve.
Picture your belief about the state as a bell curve: a center (best guess) and a width (uncertainty). The predict step slides the center along with the model and widens the curve, because projecting forward adds doubt. The update step meets the measurement and narrows the curve, snapping the center toward the reading by an amount set by the Kalman gain, the filter's trust in the measurement versus the model.
A hidden signal drifts along; you only see the noisy dots. The filter, knowing just that the signal moves slowly, produces the smooth estimate and the shaded uncertainty band. Turn up the measurement noise and the filter leans harder on its model; turn up the process noise and it chases the dots more eagerly.
With state estimate x and its variance P, model step and noise Q, measurement z with noise R, the cycle is five short lines. The gain K is the star: near 1 it trusts the sensor, near 0 it trusts the model.
In more than one dimension these become matrix versions, with the gain a matrix and P a covariance, but the meaning is identical. The quantity z minus the prediction, the innovation, is the surprise in each measurement; a filter that is working well produces small, patternless innovations, and a filter whose innovations suddenly grow is telling you something has changed, the seed of fault detection.
Give the filter a state of position and velocity and a model that says position advances by velocity, and it becomes a tracker. It sees only noisy positions, yet by estimating the unmeasured velocity it smooths the path and predicts through gaps. The uncertainty is now an ellipse, wide along directions the measurements constrain poorly.
The plain Kalman filter assumes straight-line relationships. Real sensors rarely oblige. A battery's open-circuit voltage is a curved function of charge; a range sensor sees distance, not coordinates. The extended Kalman filter handles this by linearizing on the fly: at each step it replaces the curve with its tangent line (a derivative) at the current best guess, then runs the ordinary Kalman update on that local approximation.
The unscented Kalman filter takes a different route: instead of a derivative, it pushes a small set of carefully chosen sample points through the true nonlinear function and reads off the resulting mean and spread. It is often more accurate and needs no hand-derived Jacobians, at a modest extra cost. Both keep the predict-update rhythm intact.
Here the extended filter estimates state of charge from a noisy voltage reading through the same curved voltage law used in the companion vehicle monograph. It starts from a deliberately wrong initial guess. Watch it lock onto the true charge within a few steps and then track it down through the discharge, its uncertainty band collapsing as the measurements do their work.
Linearizing works until the belief itself stops being a single hump. If a measurement is ambiguous, the truth could sit in two places at once, no bell curve can express that. The particle filter throws away the formula and represents the belief by a swarm of hundreds of candidate states, each a little hypothesis about the truth.
Below is the classic hard test: a signal whose measurement depends on its square, so a reading of four could mean plus or minus two. Watch the particle swarm split, hedge across both possibilities, and collapse onto the truth once the model breaks the tie, something no single bell curve could do.
State estimation is quietly everywhere in a modern vehicle. A few of the load-bearing uses:
This monograph completes a trio of very different answers to the same question, how to reason about what you cannot directly see:
They share a spine. The filter's innovation, the PINN's physics residual, and the diffusion model's denoising error are three flavors of the same idea: measure how far reality departs from expectation, and treat that gap as both the correction signal and the alarm.