Kalman Filter: Tracking Through Noise
Track a moving target through noisy measurements. Watch the predict step grow uncertainty and the update step shrink it, and drag the noise sliders to see the covariance ellipse breathe.
Kalman Filter: Tracking Through Noise
A target moves along the dashed green path. A sensor reports only its position, and every reading is corrupted by noise. The filter keeps a belief about position and velocity, then alternates two moves: predict where the target should be, and correct that guess against each new reading. The result, in terracotta, stays close to the truth even though it never sees it directly.
The shaded terracotta ellipse is the filter's 1-sigma position uncertainty, drawn from the eigenvectors of the 2x2 position block of the covariance P. Each update pulls it tighter. Turn on "drop measurements" and the ellipse swells with every predict-only step, because nothing is left to correct the growing drift.
R says how much you distrust the sensor; Q says how much you distrust the constant-velocity assumption. Raise R and the filter leans on its own prediction, so the estimate is smooth but slow to react when the target turns. Raise Q and the filter trusts each fresh reading, so it tracks turns quickly but jitters with the noise. The Kalman gain K is exactly the lever between them: it lands wherever the ratio of these two uncertainties puts it.
Where should it be next?
P = F P Fᵀ + Q
F moves position by velocity times dt and leaves velocity alone. Projecting P through F and adding Q always grows the uncertainty: prediction alone can only lose information, which is why the ellipse breathes outward during a measurement gap.
Correct against the reading
x = x + K (z − H x)
P = (I − K H) P
H pulls position out of the state. The gain K weighs the surprise z minus H x by how much the filter trusts the reading versus its own belief. Folding that correction in always shrinks P, which is the ellipse snapping tighter on every update.
Estimate error versus raw error
Press Play or Step to gather readings. With measurements dropped, there is nothing to score against.