Robots and robotics

What is a Kalman filter, in plain English?

Its first known use was in NASA's navigation studies for Apollo, robots still use it to keep track of themselves, and the one-dimensional version fits on a napkin. You need two guesses, a number for how much you trust each, and one division.

By the Toorova team · Published November 6, 2026 · 10 min read · How we write these

Short answer

A Kalman filter is a method for estimating something you can't measure exactly, like a robot's position, by repeating two steps. First it predicts where things should be now, from its last estimate and how the system moves. Then it takes a noisy measurement and blends the two, weighting each by how uncertain it is. It also tracks its own uncertainty, so the blended estimate ends up more reliable than the prediction or the measurement alone.

What a Kalman filter does, shown with one robot

Picture a small robot rolling along a straight track. You want to know how far along it is. You've got two ways to find out, and both are a bit wrong.

The first is to predict. You told the motors to drive at 1 meter per second, so after one second the robot should be 1 meter further on. But wheels slip and motors never do exactly what they're told, so the prediction is off by a little. Keep predicting without checking and the error keeps piling up.

The second is to measure. A distance sensor on the front reads how far it is to the wall at the end of the track, and from that you can work out where the robot is. That reading doesn't build up error over time, but each one jumps around. Take two readings while the robot sits still and you'll get two different numbers.

A Kalman filter is a recipe for combining the two. It takes the prediction and the measurement and picks a point between them, closer to whichever one deserves more trust right now. Then it does the same thing when the next reading comes in, and the next. The thing it's estimating is called the state. Here that's just the robot's position, but on a real robot it's usually position, heading and speed together.

What makes it more than a weighted average is that the filter keeps score of its own uncertainty. It carries a number for how wrong its current estimate might be, makes that number bigger every time it predicts and smaller every time it measures, and uses it to set the weighting next time. Greg Welch and Gary Bishop's tutorial at the University of North Carolina describes the filter as an efficient computational (recursive) means to estimate the state of a process, in a way that minimizes the mean of the squared error. "Recursive" just means each new estimate is built from the previous estimate plus one new reading, with no need to look back at older ones.

The two steps every Kalman filter repeats: predict, then correct

Welch and Bishop split the filter's equations into two groups, which they also call predictor and corrector equations. They run in a loop, one after the other, for as long as the robot is switched on.

  1. Predict. Move the estimate forward using what you know about how the system moves. For the robot on the track, that's new position = old position + speed × time. Then make the uncertainty bigger, because the motion itself adds error you can't see.
  2. Correct. When a measurement arrives, compare it with the prediction. The gap between them is called the residual (you'll also see it called the innovation). Move the estimate part of the way across that gap, then make the uncertainty smaller, because you've just learned something.

The filter stores uncertainty as a variance. That's the square of the standard deviation, and the standard deviation is roughly the typical size of the error. For the bell-shaped errors the filter assumes, about two-thirds of a sensor's readings land within one standard deviation of the truth. So a sensor with a standard deviation of 0.63 m has a variance of 0.4 m². The math adds and multiplies variances, so that's what the filter carries. Standard deviations are easier to picture, so this article gives both.

Two numbers you choose set how the uncertainty moves. The process noise, written Q, is how much uncertainty each prediction adds. The measurement noise, written R, is how noisy each sensor reading is. The filter works out everything else from those.

Because each round only needs the last estimate and its uncertainty, the filter never has to store or reprocess old readings. Welch and Bishop call this recursive nature one of the filter's most appealing features, and contrast it with the older Wiener filter, which was designed to operate on all of the data directly for each estimate. That one-reading-at-a-time habit is exactly what caught NASA's attention in 1960, as the history section below explains.

How the Kalman gain decides which guess to trust

How far the correct step moves toward the measurement is set by the Kalman gain, a number between 0 and 1. A gain of 0 means "ignore the sensor and keep my prediction." A gain of 1 means "throw away my prediction and believe the sensor." When you're estimating a single number, the gain is:

gain = prediction variance ÷ (prediction variance + measurement variance)

and the update is:

new estimate = prediction + gain × (measurement − prediction)
new variance = (1 − gain) × prediction variance

These are the one-dimensional form of the equations in Welch and Bishop's tutorial, which works through this exact case: one number, measured over and over by a noisy sensor.

Read the gain formula and the behavior falls out of it. If the sensor were perfect, its variance would be 0, the gain would be 1, and the filter would believe the sensor completely. If the prediction were perfect, the gain would be 0 and the filter would ignore the sensor. Welch and Bishop say the same thing in words: as the measurement error shrinks, the actual measurement is trusted more and more, and as the prediction's error shrinks, the measurement is trusted less and less.

The same thing as a weighted average

There's a second way to read the formula that's easier to remember. The new estimate is a weighted average of the prediction and the measurement, where each one's weight is 1 divided by its variance. A source with half the variance gets twice the say. The uncertainties combine the same way:

1 ÷ new variance = 1 ÷ prediction variance + 1 ÷ measurement variance

That line is why the filter's estimate is always more certain than either input on its own. Each source adds to 1 ÷ variance, and a bigger 1 ÷ variance means a smaller variance. Even a poor sensor helps a little, as long as the filter knows how poor it is.

A worked Kalman filter example with real numbers

Back to the robot on the track. Here are its settings:

  • It's told to drive at 1.0 m/s, and the filter runs once a second.
  • Each second of driving adds a variance of 0.1 m² to the prediction (that's Q), a standard deviation of about 0.32 m, from wheel slip and motor error.
  • The distance sensor has a variance of 0.4 m² (that's R), a standard deviation of about 0.63 m.
  • The robot starts at 0 m. Nobody placed it perfectly, so the filter starts with a variance of 0.3 m² (about 0.55 m).

Second 1

Predict: position 0 + 1.0 = 1.0 m. Variance 0.3 + 0.1 = 0.4 m².

Correct: the sensor reads 1.4 m. The gain is 0.4 ÷ (0.4 + 0.4) = 0.5, so the filter moves halfway: 1.0 + 0.5 × (1.4 − 1.0) = 1.2 m. The new variance is (1 − 0.5) × 0.4 = 0.2 m², a standard deviation of 0.45 m.

The prediction and the sensor were equally uncertain, so the filter split the difference. And its answer, good to about 0.45 m, beats both inputs, which were each good to about 0.63 m.

Second 2

Predict: 1.2 + 1.0 = 2.2 m. Variance 0.2 + 0.1 = 0.3 m².

Correct: the sensor reads 2.0 m. This time the prediction is the more certain of the two, so it gets more weight: gain = 0.3 ÷ (0.3 + 0.4) = 0.43. The new estimate is 2.2 + 0.43 × (2.0 − 2.2) = 2.11 m, and the new variance is (1 − 0.43) × 0.3 = 0.17 m², or 0.41 m.

Two more seconds run the same way. Every number in this table comes from the formulas above:

SecondPredictionPrediction std. dev.Sensor readsGainNew estimateNew std. dev.
11.00 m0.63 m1.40 m0.501.20 m0.45 m
22.20 m0.55 m2.00 m0.432.11 m0.41 m
33.11 m0.52 m3.50 m0.403.27 m0.40 m
44.27 m0.51 m4.10 m0.404.20 m0.40 m

Watch the gain column. It starts at 0.5 and settles near 0.4 within a few steps. It stops changing because the uncertainty stops changing: each prediction adds 0.1 m², and each correction takes about the same amount back off. Welch and Bishop note that when Q and R are constant, the uncertainty and the Kalman gain will stabilize quickly and then remain constant. For these settings the gain levels off at 0.39, and the estimate's standard deviation at just under 0.40 m.

Line chart of position uncertainty over four seconds. Prediction alone rises from 0.55 meters to 0.84 meters. The sensor alone stays flat at 0.63 meters. The Kalman filter, combining both, drops from 0.55 meters to 0.45 meters after the first reading and settles at about 0.40 meters.uncertainty (standard deviation)1.0 m0.5 m0prediction alonesensor aloneKalman filterstart1 s2 s3 s4 s
Prediction alone gets steadily worse. The sensor alone never improves. The filter, using both, settles at about 0.40 m, better than either one.

If the robot trusted its wheels alone, the variance would just keep growing by 0.1 m² every second: 0.7 m² after four seconds (0.84 m), and 10.3 m² after 100 seconds (3.2 m). The sensor alone stays at 0.63 m forever, but every reading jumps around. The filter gets the smoothness of the prediction and the no-drift property of the sensor, and its uncertainty ends up smaller than either.

Where beginners go wrong with Kalman filters

  • "The gain is a setting I pick." You pick Q and R, the noise levels. The filter computes the gain from them. If the estimate is too jumpy or too sluggish, the fix is to change what you've told it about the noise. In the worked example, telling the filter the sensor is twice as noisy (R = 0.8 m²) drops the settled gain from 0.39 to 0.30, so each reading moves the estimate less.
  • "Getting R a bit wrong only changes the smoothing." It changes the whole balance between reacting fast and ignoring noise. In Welch and Bishop's example, the sensor's real noise variance was 0.01. When they told the filter it was 100 times bigger (R = 1), the filter was slower to believe the measurements and its estimate was smoother. When they told it 100 times smaller (R = 0.0001), it believed every noisy reading quickly and its estimate jittered right along with them.
  • "I know where the robot starts, so I'll set the starting uncertainty to zero." A starting variance of zero tells the filter its first guess is perfect, which gives it no reason to listen to the sensor. Welch and Bishop warn that in their example this would cause the filter to initially and always believe its starting value. Almost any nonzero start works, because the filter converges eventually.
  • "Q is as easy to measure as R." You can usually measure R directly: park the robot and log what the sensor says. Q is harder, because you can't watch the errors in your own motion. Welch and Bishop say finding Q is generally more difficult, and that in practice both numbers are often tuned until the filter behaves.
  • "One bad reading can't hurt much." The filter assumes bell-shaped errors, so it weights a wild reading the same as any other. With the settled gain of 0.39 from the example, a reading 5 m off (say, the sensor bouncing off a passing person) drags the estimate 0.39 × 5 = 1.95 m. A common fix is to check the residual first and skip readings that are far too large to be ordinary noise.
  • "A Kalman filter works on any system." The basic filter assumes the motion and the measurement are linear, meaning straight-line relationships, and that the errors are bell-shaped (Gaussian). A robot that turns breaks the first assumption, since how far it moves sideways depends on the sine and cosine of its heading. The usual workaround is the extended Kalman filter (EKF), which approximates the curve with a straight line around the current estimate. Welch and Bishop are blunt about the cost: the EKF is an ad hoc estimator that only approximates the optimality of Bayes' rule by linearization. It works well in many real systems, but it's no longer guaranteed to give the best possible estimate.

Where the Kalman filter came from, and where it's used now

Rudolf E. Kalman published the method in 1960, in a paper called A New Approach to Linear Filtering and Prediction Problems in the ASME's Journal of Basic Engineering. His abstract describes re-examining the classic filtering problem using the "state transition" method of analysis of dynamic systems: describing a system by its state and the rule that carries that state from one moment to the next, which is where the predict step comes from.

Its first known job was planning navigation for the Moon missions. In a NASA technical memorandum, Leonard McGee and Stanley Schmidt write that the first publicly known application was made at NASA Ames Research Center in the early 1960s, during feasibility studies for navigating the Apollo capsule around the Moon and back. Kalman visited Schmidt at Ames in the fall of 1960 and presented his paper to the team. They liked that it handled measurements one at a time, which eased the computing load on the IBM 704 they were using for simulation. But Kalman's theory was linear and their problem wasn't, and the reworking they did became what's now known as the extended Kalman filter. The same memo describes the first flight test of the filter running on an airborne computer, in 1972.

Robots use the same machinery to answer how a robot knows where it is. In ROS, the open-source robot software framework, the robot_localization package is described as a package of nonlinear state estimation nodes. The Nav2 navigation docs use it to combine an IMU (a rotation and acceleration sensor) with wheel odometry and produce a fused, locally accurate and smooth odometry estimate. The docs give the reason for pairing those two: IMUs drift over time while wheel encoders drift over distance traveled, so each covers a weakness of the other. When the robot has no map to correct against, the problem grows into SLAM, where the map and the position are estimated together.

If you want to build one yourself, Roger Labbe's free book Kalman and Bayesian Filters in Python works up from intuition in runnable notebooks and covers the extended and unscented variants too. It admits up front that Kalman filters have a reputation for difficulty. The one-dimensional version above is the part that makes the rest make sense.

Common questions

Why is it called a filter?

Because it filters noise out of a stream of measurements. Its estimate comes out noticeably smoother than the raw sensor readings, while still following real changes in the thing being measured.

Is a Kalman filter just a moving average?

Not quite. Once its gain settles, a simple one-dimensional Kalman filter behaves a lot like a fixed smoothing filter. The difference is that it works out the weighting from the uncertainties instead of you picking it, and it uses a model of how the thing moves to predict between readings.

Do I need matrices to use a Kalman filter?

Not for one number, like the robot on a track in this article. Real robots track several numbers at once, such as position, heading and speed, and those affect each other, so the same equations are written with matrices.

What's the difference between a Kalman filter, an EKF and a UKF?

The basic Kalman filter assumes straight-line (linear) motion and measurements. The extended Kalman filter (EKF) handles curved relationships by approximating them with straight lines around the current estimate. The unscented Kalman filter (UKF) handles them by pushing a small set of sample points through the real curve instead.

Learn it properly

Physical AI & Robotics Engineering has a lesson on state estimation and the Kalman filter, followed by lessons on sensor fusion and SLAM, alongside kinematics, control and motion planning. It's the advanced robotics path, so start with Robotics Foundations if you've never worked with a robot.

See Physical AI & Robotics Engineering in the Toorova catalog →

Sources

  1. An Introduction to the Kalman Filter (Welch & Bishop, TR 95-041) · University of North Carolina at Chapel Hill
  2. A New Approach to Linear Filtering and Prediction Problems (Kalman, 1960) · Transactions of the ASME, Journal of Basic Engineering (copy hosted by Yale University)
  3. Discovery of the Kalman Filter as a Practical Tool for Aerospace and Industry (McGee & Schmidt, NASA TM-86847, 1985) · NASA Ames Research Center
  4. robot_localization · ROS package repository (GitHub)
  5. Setting Up Odometry · Nav2 documentation
  6. Kalman and Bayesian Filters in Python (Labbe) · GitHub

Read next

  • How does a robot know where it is?

    Robots count wheel turns, read an IMU and check GPS or landmarks, then a filter weighs each one by how far it can be trusted. Here's how, with worked numbers.

  • What is a PID controller? P, I and D explained simply

    A PID controller sets its output from the error now, the error added up over time, and how fast the error is changing. Here's each part, with worked numbers.

  • What is SLAM in robotics?

    SLAM lets a robot build a map of a new place while working out where it is on that map. Here's how it works, why loop closure matters, and lidar vs visual SLAM.