Optimal Fusion of Two Sensors#

This demo makes inverse-variance fusion concrete. Two scalar sensors (a precise radar altimeter and a noisier barometric altimeter) both measure the same true altitude. The demo shows the three resulting probability densities (radar, baro, fused) on a common axis and a variance-vs-weight curve underneath. The variance curve is the headline pedagogy: drag the fusion weight \(w_R\) around and the dot walks along a parabola whose minimum sits at exactly the inverse-variance optimum. Move away from that minimum in either direction and the fused variance climbs the parabola.

The math#

Two unbiased independent measurements with variances \(\sigma_R^2\) and \(\sigma_B^2\) combine as

\[ \hat{x} = w_R\, z_R + (1 - w_R)\, z_B, \qquad \mathrm{Var}(\hat{x}) = w_R^2\, \sigma_R^2 + (1 - w_R)^2\, \sigma_B^2. \]

Minimizing \(\mathrm{Var}(\hat{x})\) with respect to \(w_R\) gives the inverse-variance weights

\[ w_R^{\text{opt}} = \frac{1/\sigma_R^2}{1/\sigma_R^2 + 1/\sigma_B^2}, \qquad \sigma_{\text{opt}}^2 = \left( \frac{1}{\sigma_R^2} + \frac{1}{\sigma_B^2} \right)^{-1}. \]

Equivalently, in information form (\(I = 1/\sigma^2\)), \(I_{\text{opt}} = I_R + I_B\). Independent sensors add information; you cannot lose information by fusing in a second sensor, only by refusing to use it.

Interactive demo#

Open in full screen

Walkthrough#

The demo opens at the canonical Block 3 scenario: true altitude 100 m, \(\sigma_R = 2\) m, \(\sigma_B = 6\) m, no biases, fusion weight at the optimum \(w_R = 0.9\). Try the following:

  1. Read the headline metrics. \(\sigma_{\text{fused}} \approx 1.897\) m at the optimum, slightly tighter than the radar alone (\(\sigma_R = 2\) m). The information ratio \(I_R / I_B = 9 : 1\) is the reason: the radar carries 9× the information of the baro, so the optimum weight is the radar’s information share, \(9/10 = 0.9\). The information-budget bar shows the same split: the green radar segment is 90% of the total, and the orange baro segment adds 11.1% on top of the radar’s own information.

  2. Drag \(w_R\) down to 0.5. The navy fused PDF widens, and the dot on the variance-vs-weight plot walks up the parabola to \(\mathrm{Var} = 10\) m², so \(\sigma_{\text{fused}} = \sqrt{10} \approx 3.162\) m. That is worse than the radar alone, though still better than the baro alone: mis-weighting throws away most of the good sensor’s information, and the “your weight” bar shows you are using only 36% of the information available. The “Equal weights” chip is a fast way to land here. Watch where the parabola crosses the green dashed \(\sigma_R^2\) line (radar alone): at \(w_R = 0.8\). Any radar weight below 0.8 does worse than ignoring the baro entirely.

  3. Click “Snap to optimal.” The fused PDF tightens back to its minimum width; the dot returns to the parabola’s minimum, where the gray dashed optimum line marks \(d\mathrm{Var}/dw = 0\).

  4. Slide \(\sigma_B\) up to its slider max (50 m). Watch the gray dashed optimum line and the “opt” readout: as the barometer gets noisier, the optimum weight pushes toward 1.0 (\(w_{\text{opt}} \approx 0.998\)) and the optimal \(\sigma_{\text{fused}}\) approaches \(\sigma_R\) (about 1.998 m). The baro’s orange slice of the information bar all but vanishes (\(I_B = 0.0004\) m⁻²). Your weight is still 0.9, which now gives \(\sigma_{\text{fused}} \approx 5.31\) m, worse than the radar alone; click “Snap to optimal” to follow the optimum. In the limit \(\sigma_B \to \infty\), the fused estimate is just the radar: a useless sensor contributes no information.

  5. Set \(\sigma_R\) to 5 m, then click “Comparable sensors (\(\sigma_R = \sigma_B\)).” The chip copies \(\sigma_R\) into \(\sigma_B\) and moves the weight to the new optimum, \(w_R = 0.5\): the simple average is optimal in this case, and \(\sigma_{\text{fused}} = 5/\sqrt{2} \approx 3.536\) m. The variance-vs-weight parabola is now symmetric about \(w_R = 0.5\), and the two sensors fill equal halves of the information bar.

  6. Click “Reset to defaults,” then slide the radar bias up to +5 m. The radar PDF shifts right; the fused PDF inherits a weighted bias of \(w_R \cdot 5 = 0.9 \cdot 5 = 4.5\) m. The “Fused estimate vs truth” stat turns warning-color. Optimal fusion only minimizes variance, not bias. If your sensors disagree systematically, fusion will not save you; that is the entire motivation for fault detection in Block 8.

  7. Toggle “overlay Monte Carlo histograms.” 10,000 samples from each sensor and from the fused estimate are drawn as step outlines, in the same colors, over the smooth Gaussian PDFs. They should agree closely with the theoretical curves: at the default settings and seed, the Monte Carlo line under the plot reads σ = 2.03, 6.03 and 1.93 m against theory 2.00, 6.00 and 1.90 m. “Reseed” cycles to a new realization.

Key observations#

  • The variance-vs-weight parabola is the fundamental picture. A minimum exists; that minimum is the inverse-variance weighting; moving in either direction makes things strictly worse. This same picture is the mechanism behind the Kalman gain in Block 4, which trades off the prior variance \(P_k^-\) against the measurement variance \(R_k\) to land on an optimum every step.

  • You cannot lose information by adding an independent sensor. \(I_{\text{opt}} = I_R + I_B \geq I_R\) for any \(I_B \geq 0\). When fused optimally, the fused \(\sigma\) is always less than or equal to the smaller of the two input \(\sigma\)s. Even a sensor with \(\sigma_B = 50\) m still buys you a small but real precision improvement (1.998 m instead of 2 m).

  • Information is what’s additive, not variance. \(\sigma_{\text{opt}}^2 = (I_R + I_B)^{-1}\), not \(\sigma_R^2 + \sigma_B^2\). This is why information form (Kalman filter cousin: the information filter) is the natural framework when you have many sensors to fuse.

  • Bias propagates through fusion, variance shrinks. The fused mean is the weighted average of the sensor biases. The fused variance is exactly \(\mathrm{Var}(\hat{x}) = w_R^2\,\sigma_R^2 + (1 - w_R)^2\,\sigma_B^2\) for any weight; the inverse-variance weight minimizes it, and a mis-set weight can be worse than the better sensor alone (any \(w_R < 0.8\) at the defaults). The estimator only minimizes the second moment of the error, not the first.

From fusion to the Kalman filter#

The two-sensor fusion in this demo is the same operation a Kalman filter performs at every measurement update, but with one of the “sensors” replaced by the prior estimate \(\hat{x}_k^-\) propagated forward from the last step. The Kalman gain \(K_k = P_k^- / (P_k^- + R_k)\) is just the inverse-variance weight on the measurement. Block 4 derives this rigorously and adds the covariance update; the fusion math here is the building block.

Source#

MATLAB bundle · demos/OptimalFusionDemo.m↓