← Tutorials

Tutorial Series · Part 7 of 27

Combining Measurements: The Simplest Sensor Fusion Demo

Derive weighted averaging as a first step toward Kalman filtering.

Series Context

Navigation from First Principles

This article is part of an ordered course. Use the previous and next links to stay in sequence.

Sensor fusion does not mean “average everything”. It means combining information according to how much each source should be trusted. This post introduces the idea with two sensors measuring the same one-dimensional position. It is a simple doorway into Kalman filtering.

Welch and Bishop describe the Kalman filter as a recursive computational solution related to least-squares estimation and state estimation under uncertainty.1 Before using matrices and prediction models, we can teach the core intuition with weighted averages.

The problem

Two sensors disagree:

z1=10.2m,z2=13.8mz_1 = 10.2\,m, \qquad z_2 = 13.8\,m

Which one is right? The answer depends on uncertainty. A high-quality sensor with σ=0.5m\sigma=0.5\,m should influence the fused result more than a poor sensor with σ=5m\sigma=5\,m.

The model

For two independent unbiased scalar measurements:

z1N(x,σ12)z_1 \sim \mathcal{N}(x,\sigma_1^2) z2N(x,σ22)z_2 \sim \mathcal{N}(x,\sigma_2^2)

The variance-weighted fused estimate is:

x^=z1σ12+z2σ221σ12+1σ22\hat{x} = \frac{\frac{z_1}{\sigma_1^2}+\frac{z_2}{\sigma_2^2}}{\frac{1}{\sigma_1^2}+\frac{1}{\sigma_2^2}}

The fused variance is:

σf2=(1σ12+1σ22)1\sigma_f^2 = \left(\frac{1}{\sigma_1^2}+\frac{1}{\sigma_2^2}\right)^{-1}

The smaller the variance, the larger the weight.

Interactive demo: weighted fusion playground

The number line below shows two simulated measurements and the fused estimate they produce. You can change each sensor’s uncertainty and bias, generate new samples, and compare the variance-weighted result with the simple arithmetic mean.

Interactive Demo

Weighted Fusion Playground

Lower variance means higher weight. The fused estimate moves toward the more trusted sensor, even when that sensor is biased.

true A B fused

Blue is sensor A, orange is sensor B, and green is the fused estimate with its one-sigma interval.

Controls

Draw a new pair of measurements, then tighten one sigma slider to see how the fusion weights shift.

Calculation

Sensor A reading-
Sensor B reading-
Weight A-
Weight B-
Fused estimate-
Fused sigma-

What to watch

  • When Sensor A has lower uncertainty, the fused estimate moves toward A.
  • When both sensors have equal uncertainty, the fused estimate sits near the arithmetic mean.
  • Adding bias shows that a confident but miscalibrated sensor can pull the fused result in the wrong direction.
  • The true position can stay hidden until you want to reveal whether the fused answer is actually better.

Try this

Set σ1=1\sigma_1=1 and σ2=10\sigma_2=10. Generate measurements. The fused result should sit close to Sensor A. Then deliberately bias Sensor A by 20m20\,m. The fused estimate becomes confidently wrong, which introduces the importance of calibration and outlier detection.

Where this breaks

This demo assumes independent, unbiased, one-dimensional measurements. Real navigation measurements may be correlated, nonlinear and biased. Kalman filters generalise this idea by adding prediction, covariance propagation and measurement models.

Footnotes

  1. Greg Welch and Gary Bishop, “An Introduction to the Kalman Filter”, TR 95-041. https://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/WELCH/kalman.html - Practical introduction to the discrete Kalman filter and EKF. Accessed 2026-06-11.