One loop, run forever
A robot never knows exactly where it is. It carries a belief — a probability spread over all the places it might be — and its whole job at each tick of the clock is to keep that belief honest. The Bayes filter is the recipe for doing exactly that, and it has only two moves that repeat forever: predict, then correct.
Picture walking through your home in the dark. You take a step toward where you think the doorway is — that is the prediction, based on the command your legs followed. Then your hand brushes a wall — that is a sensor reading, and it sharpens your sense of place. Predict, sense, repeat. The Bayes filter is just that habit written down precisely enough for a computer to run thousands of times a second.
Two models the filter leans on
Each move of the loop is powered by one of two models. The motion model (sometimes called the process model) answers: given where I believed I was and the command I just sent to my wheels, where should I expect to be now? It encodes how the state evolves over one time step.
The observation model (or measurement model) runs the other direction: if I really were at a given spot, what reading should my sensor produce? A wall-distance sensor, for example, would report a small number near a wall and a large number in open space. When a fresh reading arrives, the filter asks which candidate positions would have explained it, and favors those.
Neither model is perfect, and the filter knows it. Every command slips a little — wheels spin on dust, gears have play — and every sensor lies a little. That honest admission of imperfection is process and measurement noise, and getting those noise sizes roughly right matters more than almost anything else.
Watch the belief breathe: a 1D corridor
Strip everything down to a robot in a straight corridor, where the only thing it cares about is its position along the hallway. Its belief is now a simple curve: tall and narrow means "I'm fairly sure I'm here," low and wide means "I could be anywhere along this stretch." Watch what each of the two steps does to that curve.
- Predict. The robot commands "roll forward 1 metre." The whole belief curve slides one metre down the corridor — and it also spreads out, getting shorter and wider, because the wheels might have slipped. Moving on your own guess always makes you less certain.
- Sense. A door-detector fires, and the robot knows doors sit at three places along the corridor. The observation model lifts the belief near those three spots and flattens it elsewhere.
- Correct. The filter multiplies the predicted curve by the sensor's curve. Where both agree, the result is tall and narrow; where they disagree, it collapses to near zero. The spread-out belief sharpens into a confident peak.
- Repeat. The robot drives on, the curve spreads again on the next predict, and the next door sighting snaps it back. Over a few cycles, ambiguity between the three doors resolves into a single confident answer.
That breathing rhythm — widen on prediction, sharpen on sensing — is the heartbeat of every estimator. Prediction spends certainty to move forward in time; sensing buys certainty back with real evidence. A robot that only predicts (pure dead reckoning) watches its belief blur away into uselessness; a filter keeps it crisp.
loop forever each tick: # 1. PREDICT using motion model + command u belief = move(belief, u) # slides and widens # 2. CORRECT using observation model + reading z belief = belief * likelihood(z) # reweights belief = normalize(belief) # rescale to sum 1
The parent of the filters you'll meet next
The corridor version stored its belief as a list of buckets, which is fine for a hallway but hopeless for a robot roaming a 2D warehouse with thousands of cells. The famous filters you'll study next are simply clever shortcuts for representing and updating the same belief without that brute-force grid.
The Kalman filter makes one bold assumption — that the belief is always a single bell curve — and then predict and correct become a few lines of matrix algebra, fast enough for the tightest control loops. When the robot's motion or sensors are too curvy for a straight-line bell-curve story, the extended and unscented variants bend that assumption to fit.
The particle filter goes the other way: it keeps the corridor's honesty — a belief that can have several lumps at once, exactly what you need when three doors look identical — but represents it with a swarm of sampled guesses instead of a grid. Same predict-correct loop, different bookkeeping.