control//state estimation//Kalman filter

There are two ways of knowing where something is, how hot it is or how fast it goes. The first is inference: take what you knew before, apply physics and calculate. A second ago I was doing 10 m/s at the 100 m mark, so now I am at 110. Call this voice the Physics. The second is asking the world with a sensor, chemistry on silicon that turns something physical into a number: a GPS, a thermometer, an accelerometer. Call this voice the Sensor.


There are two ways of knowing where something is, how hot it is or how fast it goes. The first is inference: take what you knew before, apply physics and calculate. A second ago I was doing 10 m/s at the 100 m mark, so now I am at 110. Call this voice the Physics. The second is asking the world with a sensor, chemistry on silicon that turns something physical into a number: a GPS, a thermometer, an accelerometer. Call this voice the Sensor.

And neither is perfect. Perfection does not exist. The model ignores the wind, the bump and the driver who brakes; the sensor has thermal noise, signals bouncing off buildings and a converter with fewer bits than you would like. Since they are not QUANTUM ENTANGLED with reality (nor with each other), each one hands you a different number: inference says 110, the GPS says 114, and with a BUNCH of sensors each one says its own thing, all at once. How do we get from that disagreement to a measurement? By combining them according to how uncertain each one is. That convention, done with mathematical rigour, is called a Kalman filter: at every step it weighs a prediction against a measurement by their uncertainties, and it keeps count of how much uncertainty is left. Anyone can average; knowing how much you know after averaging, and using that to decide how to average next time, is the idea that took people to the Moon.

K0.09 σ filter0.45 °C σ thermometer1.50 °C q0.02 °C² A 1D Kalman filter tracking a room temperature from a noisy thermometer. At steady state it trusts each new reading with gain K 0.09 and ends 3.3 times more precise than the thermometer.

A cheap thermometer and the filter following the room. Slide the thermometer's noise up and the filter listens to it less.

What goes in. Once: a model of how the system moves and how much to trust it, and a first guess with its doubt. At every tick: the readings of the sensors, each with how noisy it is.

What comes out. At every tick: the best estimate of the state, including quantities no sensor measures (a velocity from positions alone, a sensor's own bias), and how sure the filter is about it. That second output is what a controller or a safety check uses to decide how far to trust the first.

Where it runs. Every phone and car fusing GPS with an inertial unit, every drone's autopilot, radar and camera trackers following a target, any control loop that needs a clean signal from a noisy sensor, and econometric models of hidden trends.

How one is set up. Choose the state; write how it evolves and what each sensor sees of it (state-space model); measure each sensor's noise on the bench (measurement noise); start with a rough model doubt and tune it (process noise); start with a large uncertainty (initial covariance); then check that its surprises are the size it expects (innovation).

How it works inside is a loop, predict, measure, compare, correct according to confidence, repeat (predict-update cycle), and where it breaks is where its assumptions break (correlated measurements, colored noise, Gaussian assumption).

?QuestionWho sets each number, and how?

Three are yours, two are the filter's.

RRR, the variance of the sensor's noise: you, measuring, with a calibration in the lab or the datasheet (measurement noise). It is a property of the sensor; the sensor knows nothing about your PPP.

QQQ, the variance of your physical model's error: you, tuning, from the physics of the system plus trial and error (process noise).

P0P_0P0​, the starting uncertainty: you, once, as a bootstrap (initial covariance).

P−P^-P− and PPP, the uncertainty of your estimate before and after measuring: the filter. It is not measured, it is propagated, growing with QQQ and shrinking with each reading (estimate covariance).

KKK, how much to listen to the sensor: the filter, as K=P−/(P−+R)K=P^-/(P^-+R)K=P−/(P−+R) (Kalman gain).