Introduction

Every measurement is wrong. Your GPS says you are 4 metres from where you really are. The accelerometer in your phone vibrates with random jitter. The radar on a spacecraft drifts with thermal noise. Noise is not an exception — it is the default condition of any sensor in the real world.

Yet GPS routes you with metre-scale accuracy. Apollo 11 hit the Moon with 100-metre precision. Self-driving cars hold a lane to within centimetres. How?

The answer is the Kalman filter, invented by Rudolf E. Kálmán in 1960. It is a recursive algorithm that fuses two imperfect sources of information — a mathematical model of how the system moves and noisy sensor readings — to produce the statistically optimal estimate of the true state at every moment. Not approximately optimal. Provably, mathematically optimal, given the assumptions.

The key insight is elegant: instead of trying to remove noise after the fact, the filter models both the system uncertainty and the measurement noise, and uses that model to decide exactly how much to trust each source at each instant. The result is an estimate that tracks the truth far better than either the model or the sensors alone.

Try It

The chart below shows a simulated object moving along a sinusoidal path (the gray line — the hidden truth). The red dots are noisy sensor readings. The blue line is what the Kalman filter estimates in real time from those readings alone.

<div class="controls">
  <label>{{lbl_meas_noise}} <span id="rLabel">2.0</span>
    <input type="range" id="rSlider" min="0.1" max="10" step="0.1" value="2">
  </label>
  <label>{{lbl_proc_noise}} <span id="qLabel">0.05</span>
    <input type="range" id="qSlider" min="0.01" max="2" step="0.01" value="0.05">
  </label>
  <div class="btns">
    <button id="runBtn" type="button">{{btn_run}}</button>
    <button id="stepBtn" type="button" class="ghost">{{btn_step}}</button>
  </div>
</div>
<canvas id="chart" width="560" height="260"></canvas>
<div class="legend">
  <span class="dot gray"></span> {{legend_true}} &nbsp;
  <span class="dot red"></span> {{legend_sensor}} &nbsp;
  <span class="dot blue"></span> {{legend_kalman}}
</div>
<div class="info" id="info">{{info_press_run}}</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; color: #222; }
.controls { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: flex-end; margin-bottom: .6rem; }
label { display: flex; flex-direction: column; font-size: .82rem; color: #444; gap: .15rem; }
label span { font-weight: 700; color: #1d3557; }
input[type=range] { width: 160px; accent-color: #1d3557; }
.btns { display: flex; gap: .5rem; align-items: center; }
button { font: 600 13px system-ui; padding: .38rem .8rem; border: 1px solid #1d3557;
         background: #1d3557; color: #fff; border-radius: 7px; cursor: pointer; }
button.ghost { background: #fff; color: #1d3557; }
canvas { display: block; width: 100%; max-width: 560px; border: 1px solid #dde3ea; border-radius: 10px; background: #f7f9fb; }
.legend { font-size: .78rem; color: #555; margin: .35rem 0; display: flex; gap: .6rem; align-items: center; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.gray { background: #aab; }
.dot.red { background: #e63946; }
.dot.blue { background: #1d6fa4; }
.info { font-size: .82rem; color: #555; min-height: 1.2em; }
// Code not found

Use the sliders to increase or decrease measurement noise (how much the sensor jitters) and process noise (how unpredictably the object moves). Notice how the blue estimate hugs the gray truth even when the red dots scatter wildly — and how raising process noise makes the filter react faster to sudden changes.

How It Works

The filter runs a tight loop of two steps, every time a new measurement arrives.

Predict. Using the system's motion model, project the current state estimate forward in time. Also project the uncertainty (the covariance matrix) forward — if the model is uncertain, the prediction becomes fuzzier.

Update. When a sensor reading arrives, compare it with the prediction. The difference is the innovation. Multiply the innovation by the Kalman gain — a carefully computed weight that balances model uncertainty against sensor noise. A high gain says "trust the sensor"; a low gain says "trust the model."

The Kalman gain is the filter's heart:

K=PH(HPH+R)1K = P H^\top (H P H^\top + R)^{-1}

where P is the predicted covariance (model uncertainty), H maps state to measurement, and R is the measurement noise covariance. The gain automatically slides between 0 (ignore the sensor) and 1 (trust the sensor completely) depending on which source is more reliable at each instant.

Why is it optimal? Rudolf Kálmán proved in 1960 that for linear systems with Gaussian noise, this two-step loop minimises the mean-squared error of the estimate — no other algorithm can do better. This is a proven result, not a heuristic.

For non-linear systems (rockets curving through the atmosphere, a car turning a corner) engineers use the Extended Kalman Filter (EKF), which linearises the model at each step, or the Unscented Kalman Filter (UKF), which propagates carefully chosen sample points instead. Neither is globally optimal, but both inherit most of the filter's power.

Compare this with Monte Carlo integration: both methods manage uncertainty by combining a model with random samples, but the Kalman filter derives its weights analytically rather than by sampling.

Where It Matters

Sixty years after Kálmán's paper, his filter is embedded in virtually every system that must track a moving quantity from noisy data:

  • GPS and navigation: every GPS receiver runs a Kalman filter that fuses satellite time signals, clock drift models, and (in phones) accelerometer readings to give you a stable position fix.
  • Aerospace: the Apollo Guidance Computer used a Kalman filter to navigate to the Moon. Every modern spacecraft, satellite, and inertial navigation system does the same.
  • Robotics: a robot localising itself with a laser rangefinder fuses sensor sweeps with wheel-odometry predictions via a Kalman filter — the foundation of the SLAM (Simultaneous Localisation and Mapping) algorithms behind autonomous vehicles.
  • Finance: the filter tracks hidden economic states (volatility, trends) from noisy market prices in time-series models.
  • Medical imaging: MRI reconstruction and ECG signal processing use Kalman-like smoothers to separate signal from biological and electronic noise.
  • Climate science: data assimilation — merging sparse weather-station readings with atmospheric models — is a massive Kalman filter running on supercomputers.

The Bayesian inference framing unites all these cases: the filter is simply Bayes' theorem applied recursively in time, with Gaussian distributions doing the heavy lifting.

Conclusion

The Kalman filter is one of those rare algorithms that is both provably optimal and computationally cheap. Its two-step predict–update loop runs in O(n3)O(n^{3}) per step (dominated by the matrix inversion for the Kalman gain), needs no stored history, and adapts automatically to changing noise levels.

Kálmán's 1960 paper is one of the most cited engineering papers of the 20th century — not because the mathematics is exotic, but because the insight is universal: combine what you know about how the world moves with what your sensors tell you, weight each by how much you trust it, and you get the best estimate reality allows.

That principle scales from a toy spring-mass model to a Mars rover navigating a boulder field. The next time your phone locks onto a GPS signal in seconds, or a spacecraft slips into orbit without drifting, a version of Kálmán's elegant recursion is running silently underneath.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/kalman-filter/Content licensed under CC BY-NC 4.0.