Sensor Fusion: Classical to Modern · Lesson 3 of 22

Combining Two Measurements — The Seed of All Fusion

Two sensors measure the same thing and disagree. Which do you believe? The answer — trust each one in exact proportion to its precision — is a single short formula that turns out to be the entire Kalman filter in miniature, and the deepest idea in the whole field.

Prerequisites: basic arithmetic + the idea of a bell curve. That's it.
11
Chapters
6
Simulations
0
Assumed Knowledge

Chapter 0: Two Measurements, One Truth, and a Disagreement

You are standing in your kitchen holding two thermometers, both pointed at the same pot of water. One reads 20.0 °C. The other reads 22.0 °C. The water has exactly one temperature — there is a single truth — yet your two instruments disagree by two degrees. You have to write one number on the cooking sheet. Which number do you write?

This sounds almost too small to be worth a lesson. It is, in fact, the single most important question in all of sensor fusion. Every Kalman filter, every GPS receiver, every self-driving car's perception stack, every weighted poll average — all of them, at their core, are answering exactly this question over and over: I have two (or more) noisy measurements of the same quantity; what is my single best estimate? Get this one right and the rest of the field is just bookkeeping. Get it wrong and no amount of clever architecture saves you.

Lesson 1 of this series gave you the taxonomy of fusion — complementary, competitive, cooperative. Lesson 2 gave you the architectures — where the fusion math lives. This lesson gives you the atom: the smallest, most fundamental fusion operation there is. Two numbers measuring one quantity, combined into one. We will derive the right answer from scratch, with real arithmetic, and you will see it is not the obvious answer.

Common first guess (and why it's not quite right). "Just average them: (20 + 22) / 2 = 21 °C, done." That is the answer you'd give if you knew nothing about the two thermometers. But you usually do know something — one is a cheap dollar-store probe, the other a lab-grade instrument. If the lab thermometer is far more trustworthy, splitting the difference down the middle throws away that knowledge. The plain average secretly assumes both sensors are equally reliable. They almost never are. The right answer leans toward the one you trust more — and the whole lesson is about computing exactly how much to lean.

So here is the setup we'll carry through the entire lesson. We have two measurements of one true quantity:

Both are unbiased — meaning that if you measured many times, each sensor's average reading would land on the true value; neither systematically reads high or low (we'll see in Chapter 9 what happens when that assumption breaks). And, for now, their errors are independent — A reading high tells you nothing about whether B reads high (Chapter 9 again covers the danger when they're correlated). Our job: produce one fused estimate (x-hat) and its uncertainty.

Those two assumptions — unbiased and independent — are not fine print; they are the load-bearing beams of everything that follows, and it's worth knowing why up front. Unbiased means a sensor's errors are honest scatter around the truth, not a systematic lean — so the truth really does sit somewhere among the readings, and averaging them homes in on it. Independent means the two sensors don't share a hidden error source — so the second one genuinely adds new information rather than echoing the first's mistake. When both hold, the rule we derive is provably optimal. When either breaks, the rule still runs, but it produces a confident wrong answer — which is why Chapter 9 is dedicated entirely to spotting those broken assumptions in the field. Hold them in mind as the conditions under which the magic works.

Below, two sensors take live noisy readings of the same hidden truth. Watch them disagree, tick after tick. Adjust how noisy each one is. The big question hovering over the sim — the question this whole lesson answers — is printed under it: given these two disagreeing numbers, what single value should you report?

Two sensors, one truth — they disagree every tick

The dashed line is the hidden true value. Sensor A and Sensor B each take a noisy reading every tick. Use the sliders to set how noisy each sensor is (a wider noise = a less trustworthy sensor). Press Run and watch them scatter around the truth — rarely agreeing, never both exactly right.

A noise σA 1.0 B noise σB 2.0
which single number should you report?

Notice something in the sim already: the sensor with the smaller noise hugs the dashed truth line tightly, while the noisier one flings its readings far and wide. Your eye instinctively trusts the tight one more. That instinct — trust the tighter sensor more — is exactly correct, and the entire lesson is about turning that instinct into a precise number.

Why this tiny problem is the seed of everything

It is worth pausing to feel how far this one operation reaches, because it justifies spending a whole lesson on "combine two numbers." Here is the same atom, wearing different costumes across the field:

Where you've seen itThe two (or more) measurementsThe one fused quantity
A Kalman filter, every tickthe prediction & the new sensor readingthe updated state estimate
GPS with several satellites/constellationsposition fixes from GPS + GLONASS + Galileoone fused position
Two redundant industrial pressure gaugestwo gauge readings of the same pipeone trusted pressure
A weighted average of opinion pollseach poll's estimate + its margin of errorone poll-of-polls number
Combining two lab measurements of a constanttwo experiments' values + their error barsone best estimate of the constant

Every row is the same arithmetic. The Kalman filter (Lesson 5, and the dedicated Kalman Filter lesson) looks intimidating with its matrices and its "gain," but strip away the dynamics and one update step is the two-measurement combination you're about to learn — we'll prove that exactly in Chapter 5. Master this chapter and you've quietly mastered the engine inside the most famous estimator in engineering.

The one-sentence preview

Here is where we're headed, stated once so the destination is clear: the optimal fused estimate is a weighted average of the two measurements, where each measurement's weight is proportional to its precision — and precision is one over the variance. The trustworthy (low-variance) sensor gets a big weight; the sloppy (high-variance) sensor gets a small one. And the beautiful kicker: the fused estimate is always more precise than either sensor alone. Two flawed measurements, combined the right way, beat the better of the two. We'll derive all of this by hand, no faith required.

The thesis of this lesson. When two unbiased, independent sensors measure the same quantity, do not split the difference. Weight each one by its precision (one over its variance), and the resulting estimate is the best you can do — and it is sharper than either input. This single rule, the inverse-variance weighted average, is the seed from which the Kalman filter, GPS, and most of modern estimation grow.
Two thermometers measure the same pot of water: a cheap one reads 20 °C and a lab-grade one reads 22 °C. Why might reporting the plain average (21 °C) be a mistake?

Chapter 1: The Wrong Answer — Why the Plain Average Throws Away Knowledge

Before we build the right answer, let's stare hard at the wrong one, because understanding exactly why it's wrong is what makes the right one obvious. The wrong answer is the one almost everyone reaches for first: the plain average, also called the unweighted or arithmetic mean.

plain = (xA + xB) / 2

For our thermometers, x̂plain = (20 + 22) / 2 = 21 °C. It sits exactly halfway between the two readings. And here is the precise statement of what it assumes: the plain average treats both measurements as equally reliable. It gives each one a weight of one-half, no matter what. It cannot tell a lab-grade thermometer from a dollar-store probe. Whatever you know about how trustworthy each sensor is, the plain average ignores it.

A concrete case where this hurts

Make the asymmetry extreme and the damage becomes visible. Suppose Sensor A is your phone's GPS, accurate to about a meter, reporting your position as xA = 100 m. Sensor B is a frayed, half-broken receiver that's accurate only to about ten meters, reporting xB = 130 m. The truth is near 100 m (the good sensor is close). What does the plain average say?

plain = (100 + 130) / 2 = 115 m

The plain average drags your estimate 15 meters away from the truth — halfway toward the bad sensor's wild guess. You knew Sensor B was ten times sloppier, and the plain average forced you to give its garbage equal billing. That's the failure: it spent half its trust on a sensor that didn't deserve it.

The plain average is a special case, not a universal rule. It is the correct answer in exactly one situation: when the two sensors are equally reliable (same variance). The moment their reliabilities differ — which is almost always — the plain average is throwing away information you possess about which sensor to trust. It is not "neutral" or "safe"; it is an active, often wrong, assumption that σA² = σB². Naming that hidden assumption is the first step to fixing it.

Watching the damage grow as the sensors diverge in quality

To feel exactly how much the plain average can cost, hold the readings fixed and vary only how unequal the sensors are. Keep xA = 100 m (good sensor, near truth) and xB = 130 m (bad sensor, far from truth), with the truth sitting at 100 m. The plain average doesn't care about quality at all — it always reports 115 m, off by 15. But a sensible estimate should move toward the good sensor as the gap in quality widens:

How much better is A?Plain average (ignores quality)Sensible estimate (leans to A)Plain-average error
equal quality115 m115 m (correctly central)15 m
A is 4× better115 m~106 m15 m — unchanged!
A is 16× better115 m~102 m15 m — still 15 m
A is 100× better115 m~100 m15 m — still 15 m

The plain-average column never budges. No matter how dramatically better Sensor A becomes — even when it's a hundred times more reliable and you'd be a fool to give the bad sensor any weight — the plain average stubbornly splits the difference and reports 115 m. The "sensible estimate" column, which we'll learn to compute in Chapter 3, slides smoothly toward the truth as A's advantage grows. That whole right-hand column is the value the plain average leaves on the table.

The lesson burned in here: the plain average's error doesn't shrink when you upgrade a sensor, because it never listens to which sensor is better. You can spend a fortune on a precision instrument, pair it with a junk sensor, and the plain average will faithfully drag your estimate halfway back to the junk. The fix isn't a better sensor — it's a better way to combine them.

The generalization: a weighted average

If the plain average's sin is using a fixed weight of one-half, the fix writes itself: let the weight be adjustable. Introduce a number w — the weight on Sensor A — that we are free to choose between 0 and 1:

x̂ = w · xA + (1 − w) · xB

Read it carefully. The weight on A is w; the weight on B is (1 − w), so the two weights always sum to 1 (this is what keeps it an average and not just a sum — if both sensors read the same value, the fused estimate equals that value, for any w). Three checkpoints make the dial intuitive:

Choice of wx̂ becomesMeaning
w = 1xAtrust Sensor A completely, ignore B
w = 0xBtrust Sensor B completely, ignore A
w = ½(xA + xB) / 2the plain average — equal trust

So the plain average is just the weighted average with the dial stuck at one-half. The weighted average is strictly more general: it can become the plain average when that's right, but it can also lean toward whichever sensor deserves more trust. The entire rest of this lesson is the answer to one question: what value of w should we pick?

Below, you control the dial w by hand and watch the fused estimate slide between the two sensors. The two sensors have different reliabilities (shown by their error bars). Try to position the fused dot as close to the truth as you can — you'll feel that the best w is not one-half, and that it depends on which sensor has the tighter error bar.

Drag the trust dial w by hand — where does the fused estimate land?

Sensor A (tight error bar — reliable) and Sensor B (wide error bar — sloppy) report values shown as dots with error bars. Slide w (the weight on A) and watch the fused estimate move. Notice: the plain average (w = 0.5) is not the best spot — the truth (dashed) sits nearer the reliable sensor.

weight on A  w 0.50
The mental model: a tug-of-war rope. Picture the fused estimate as a knot on a rope, with Sensor A pulling from one end and Sensor B from the other. The weight w is how hard each side pulls. The plain average gives both sides equal strength — the knot sits in the middle. But if one sensor is far more reliable, it should pull harder, dragging the knot toward its reading. The question "what is w?" is really "how hard should each sensor be allowed to pull?" The next chapter answers it: each sensor pulls in proportion to its precision.
In the weighted average x̂ = w·xA + (1−w)·xB, what does setting w = 0.5 give you, and why is that often not the best choice?

Chapter 2: Precision — The Right Way to Measure Trust

The weighted average needs a w, and we've decided w should reflect "how much to trust each sensor." But "trust" is vague. To compute anything we need to make it a number. This chapter introduces the exact number: precision. It is the single most important quantity in this lesson, and once you have it, the formula for w drops out almost for free.

Variance: the spread of a sensor's errors

First we need a way to say "how noisy is this sensor." The standard measure is variance, written σ². Informally, variance is the typical squared distance between a sensor's reading and the truth. A sensor whose readings cluster tightly around the truth has a small variance; a sensor whose readings scatter wildly has a large variance. (Its square root, σ, the standard deviation, is the typical error in the original units — meters, degrees — which is why error bars are usually drawn at ±σ.)

Two thermometers make it concrete. The lab-grade one has errors that rarely exceed half a degree, say σA = 0.5 °C, so σA² = 0.25. The cheap one wanders by a couple of degrees, σB = 2 °C, so σB² = 4. The cheap one's variance is sixteen times larger. Variance is our hard number for "noisy."

Why squared, not just the error? Variance squares the errors before averaging them. This does two useful things: it makes all contributions positive (an error of +2 and an error of −2 both count as "bad," not canceling out), and it penalizes large errors disproportionately (an error of 4 contributes 16, while an error of 2 contributes only 4 — so a sensor that occasionally blows up is rated much worse than one with steady small errors). For now, just hold the picture: variance is the typical squared error; small = tight = good.

Precision: just flip the variance over

Here is the key move, and it is almost embarrassingly simple. We want a number that is big when a sensor is trustworthy and small when it's sloppy — the opposite of variance (which is small for good sensors). So we just turn variance upside down. The precision, which we'll write P, is one over the variance:

P = 1 / σ²    (precision = one over variance)

That's the whole definition. A sensor with tiny variance has huge precision (it's very sure); a sensor with huge variance has tiny precision (it barely knows anything). Compute it for our thermometers:

Sensorσ (std dev)σ² (variance)P = 1/σ² (precision)Reading
A — lab-grade0.5 °C0.254.0 — very sure22.0 °C
B — cheap probe2.0 °C4.00.25 — barely sure20.0 °C

The lab thermometer has precision 4.0; the cheap one has precision 0.25. The lab thermometer is sixteen times more precise (4.0 / 0.25 = 16). That ratio — sixteen to one — is exactly how much harder the lab thermometer should pull on the tug-of-war rope. Precision is trust, quantified.

Precision is "vote strength." Think of precision as how loudly a sensor gets to vote. A laser rangefinder accurate to a millimeter has enormous precision — it shouts. A guess scrawled on a napkin has near-zero precision — it whispers. When we combine sensors, we'll let each one vote with a loudness equal to its precision. The careful, sure sensor dominates; the vague one barely registers. This is the entire intuition behind the formula in the next chapter.

Below, watch precision and variance move in opposite directions. Drag a sensor's standard deviation and see its error bar widen while its precision number shrinks — and vice versa. The bar height visualizes precision; the spread visualizes variance. They are two views of the same thing, flipped.

Variance vs precision — two views, flipped

Drag each sensor's σ (standard deviation). The shaded bell shows how its readings spread (variance — wider = noisier). The solid bar shows precision P = 1/σ² (taller = more trustworthy). Watch them move opposite: as you widen the bell, the precision bar collapses.

A  σA 0.5 B  σB 2.0

Why precision — and not standard deviation — is the quantity that adds

You might ask: why flip the variance rather than work with the standard deviation σ directly, since σ is the one in the same units as the measurement? The answer is a preview of the punchline, and it's worth seeing now. It turns out that when you combine independent measurements, the quantity that cleanly adds is precision — not variance, not standard deviation. Two sensors each of precision P combine to a fused precision of 2P (we'll prove this in Chapter 4). Standard deviations do not add (combining two σ=1 sensors does not give σ=2 — it gives a smaller σ), and variances don't add in the way you'd want either. Precision is the natural "currency" of information: each independent measurement deposits its precision into a shared account, and the balance is the total precision. That single fact — information adds as precision — is why this lesson is built around 1/σ² rather than σ.

Precision generalizes effortlessly to many sensors

Although this lesson is about two sensors, notice that precision makes the extension to three, ten, or a thousand sensors trivial: each one just contributes its precision to the pile. Suppose you had a third thermometer, C, with σC = 1 °C, so σC² = 1 and PC = 1. Now the three precisions are 4.0, 0.25, and 1.0; the total is 5.25; and each sensor's share of the trust is its precision over 5.25 (the lab thermometer still dominates with 4.0/5.25 = 76%). The two-sensor formula you're about to derive is just the n = 2 case of "weight each by its precision, normalize by the total" — and that pattern works for any number of sensors. Master two and you've mastered all of them.

Now we have everything we need. We have two measurements (xA, xB), and we have a hard number for how much to trust each (their precisions PA = 1/σA² and PB = 1/σB²). In the next chapter we turn the dial w until the fused estimate is as good as it can possibly be — and out will pop the rule: weight each sensor by its precision.

Sensor A has variance σA² = 0.25 and Sensor B has variance σB² = 4. What are their precisions, and which sensor is more trustworthy?

Chapter 3: The Inverse-Variance Weighted Average — Derived From Scratch

This is the heart of the lesson. We will derive the best weight w — not guess it, not assert it, but compute it from a single, unarguable goal: make the fused estimate as precise as possible (equivalently, make its variance as small as possible). When you set up that goal honestly and turn the dial to the bottom of the bowl, one specific value of w falls out, and it is the famous rule. We'll do it with calculus-light reasoning and then with pure arithmetic, so you never have to take it on faith.

Step 1 — write the variance of the fused estimate as a function of w

Our fused estimate is x̂ = w·xA + (1−w)·xB. Since A and B have independent errors, there is a clean rule for how variances combine when you scale and add independent quantities: scaling a quantity by a constant c multiplies its variance by c², and the variance of a sum of independent quantities is the sum of their variances. Apply that to our weighted sum:

σ²fused(w) = w² · σA² + (1−w)² · σB²

Stare at this for a moment, because it is the whole game. It says: the fused variance is a function of the dial w. The term w²·σA² is how much of A's noise leaks through (scaled by w²); the term (1−w)²·σB² is how much of B's noise leaks through. Crank w toward 1 and you take on all of A's noise; crank it toward 0 and you take on all of B's. Somewhere in between is a sweet spot where the total leaked noise is smallest. That sweet spot is the optimal w.

Why minimize variance? Because variance is the expected squared error, and "smallest expected squared error" is the cleanest, most universally-agreed definition of "best estimate." It's the same criterion behind least-squares fitting, behind the Kalman filter's optimality, behind the statistician's "minimum-variance unbiased estimator." We're not choosing this goal arbitrarily — minimizing variance is what "optimal" means for an unbiased estimate. So: find the w at the bottom of the bowl, and you've found the optimal fusion.

Step 2 — find the bottom of the bowl

The function σ²fused(w) is a parabola in w — an upward-opening bowl (you can see it has a w² term with a positive coefficient). The bottom of the bowl is where the slope is zero. We find it by taking the derivative with respect to w and setting it to zero. Differentiate term by term:

d/dw [ w²σA² + (1−w)²σB² ] = 2w·σA² − 2(1−w)·σB²

(The second term used the chain rule: the derivative of (1−w)² is 2(1−w) times the derivative of (1−w), which is −1, giving −2(1−w).) Set this slope to zero and solve for w:

2w·σA² − 2(1−w)·σB² = 0
w·σA² = (1−w)·σB²
w·σA² + w·σB² = σB²
w = σB² / (σA² + σB²)

There it is. The optimal weight on Sensor A is w = σB² / (σA² + σB²). Notice the variance of B appears in A's weight — that's not a typo. A gets a big weight when B is noisy (large σB²), which makes sense: if B is garbage, lean on A.

Step 3 — rewrite it in terms of precision (the famous form)

The formula above is correct but a little awkward. Divide the top and bottom by (σA²·σB²) and it transforms into something gorgeous. Let's do that division explicitly so nothing is left to faith. Start from w = σB² / (σA² + σB²) and divide every term by (σA²·σB²):

numerator: σB² / (σA²σB²) = 1/σA²
denominator: (σA² + σB²) / (σA²σB²) = 1/σB² + 1/σA²

The σB² in the numerator cancels one σB² below, leaving 1/σA² on top; the two terms in the denominator each cancel one variance, flipping into 1/σA² and 1/σB². So w becomes:

w = (1/σA²) / (1/σA² + 1/σB²) = PA / (PA + PB)

Read that out loud: the weight on Sensor A is its precision divided by the total precision. Each sensor's share of the trust is exactly its share of the total precision. This is the inverse-variance weighted average, and it is the single most important formula in classical sensor fusion. Plug both weights into the estimate and it reads:

x̂ = (PA·xA + PB·xB) / (PA + PB)    where P = 1/σ²

Each measurement is weighted by its precision, then normalized by the total precision. The careful sensor dominates; the vague one barely registers. Exactly the "vote strength" intuition from Chapter 2, now proven to be optimal.

Worked numbers — the two thermometers, by hand

Let's grind the whole thing out with our thermometers, every intermediate step. Sensor A (lab-grade): xA = 22.0 °C, σA² = 0.25. Sensor B (cheap): xB = 20.0 °C, σB² = 4.0.

(1) Precisions.

PA = 1/0.25 = 4.0,    PB = 1/4.0 = 0.25

(2) Total precision.

PA + PB = 4.0 + 0.25 = 4.25

(3) Weights.

wA = 4.0 / 4.25 = 0.941,    wB = 0.25 / 4.25 = 0.059

(4) Fused estimate.

x̂ = 0.941 × 22.0 + 0.059 × 20.0 = 20.71 + 1.18 = 21.88 °C

The fused estimate, 21.88 °C, sits right next to the lab thermometer's 22.0 — it leaned 94% of the way toward the sensor it trusts and barely acknowledged the cheap one. Compare that to the plain average's 21.0 °C, which split the difference and let the cheap probe drag the answer a full degree toward its sloppy reading. The inverse-variance average used the knowledge you had about reliability; the plain average ignored it.

A second worked example — two GPS receivers, very different quality

Let's run the whole procedure again on a different scenario, to prove the formula isn't a one-off trick. You have two GPS receivers on a survey rig. The expensive survey-grade unit reports position xA = 100.0 m with σA = 0.5 m, so σA² = 0.25 m². The cheap consumer chip reports xB = 109.0 m with σB = 3.0 m, so σB² = 9.0 m². Walk the four steps:

(1) Precisions. PA = 1/0.25 = 4.0; PB = 1/9.0 = 0.111.

(2) Total precision. PA + PB = 4.0 + 0.111 = 4.111.

(3) Weights. wA = 4.0/4.111 = 0.973; wB = 0.111/4.111 = 0.027.

x̂ = 0.973 × 100.0 + 0.027 × 109.0 = 97.3 + 2.94 = 100.24 m

The fused estimate is 100.24 m — barely a quarter-meter off the survey-grade reading, because the cheap chip earned only 2.7% of the trust. The plain average would have reported (100 + 109)/2 = 104.5 m, dragging you four and a half meters toward the unreliable chip — an error that could put you on the wrong side of a property line. Same formula, completely different numbers, and again it leaned hard toward the sensor that deserved it. That is the formula working as designed: the trust split automatically tracks the precision ratio.

Sanity-check the extremes. The formula behaves exactly as intuition demands at the edges. If the two sensors are equally reliable (σA² = σB²), then PA = PB, so wA = 0.5 — it gracefully becomes the plain average, which is correct when you have no reason to prefer either. And if one sensor is hopeless (σB² → ∞, so PB → 0), then wA → 1 — you ignore the dead sensor entirely, automatically, with no special-case code. A good formula passes its own boundary tests.

The whole thing in code — three forms

Here is the fusion in increasingly compact forms, so the formula stops being abstract. First the explicit precision form, then the one-liner.

python
def fuse(x_a, var_a, x_b, var_b):
    # inverse-variance (precision) weighted average
    p_a = 1.0 / var_a              # precision = "vote strength" of A
    p_b = 1.0 / var_b              # precision of B
    x_fused   = (p_a * x_a + p_b * x_b) / (p_a + p_b)
    var_fused = 1.0 / (p_a + p_b)    # precisions ADD (next chapter)
    return x_fused, var_fused

# two thermometers: lab-grade A (var 0.25) vs cheap B (var 4)
fuse(22.0, 0.25, 20.0, 4.0)   # -> (21.88, 0.235)  leans to A, sharper than A!

# equal reliability -> recovers the plain average
fuse(22.0, 1.0, 20.0, 1.0)    # -> (21.0, 0.5)

# B is hopeless (huge variance) -> weight slides entirely to A
fuse(22.0, 0.25, 20.0, 1e9)   # -> (~22.0, ~0.25)

One function, no if statements, and yet it does the right thing in every regime: leans toward the precise sensor, recovers the plain average when reliabilities match, and ignores a dead sensor when its variance explodes. The precision arithmetic does all the switching for you. That last line is a preview of complementary fusion's "a dead sensor just gets variance → ∞" trick from Lesson 1 — the same machinery.

Below, set each sensor's reading and variance and watch the optimal weights and fused estimate recompute live. Drag B's variance up and watch the fused dot slide toward A; make them equal and watch it snap to the midpoint.

Inverse-variance fusion — live weights and estimate

Set the two readings and their variances. The bar shows how the trust splits: A's share is PA/(PA+PB). The fused estimate is plotted against both sensors. Watch it lean toward the lower-variance (more precise) sensor — and snap to the middle when the variances match.

xA 70 σA² 1 xB 30 σB² 4
The signature formula of this lesson. For two unbiased, independent measurements, the optimal fused estimate is x̂ = (PAxA + PBxB) / (PA + PB), with P = 1/σ². Weight by precision. It minimizes the variance of the result, recovers the plain average when reliabilities are equal, and ignores dead sensors automatically. Statisticians call it the Best Linear Unbiased Estimator (BLUE); engineers call it inverse-variance weighting; it is the same thing, and it is the seed of the Kalman filter.
We derived the optimal weight by setting the derivative of the fused variance to zero. What goal does that procedure achieve, and what value of w results when both sensors have equal variance?

Chapter 4: The Fused Uncertainty Always Shrinks — Fusion Never Hurts

We have the best estimate. But an estimate is only half the story — you also want to know how sure you are of it, its variance. And here lies the most delightful result in the lesson, the one that makes fusion worth the trouble even when both sensors are healthy: the fused estimate is always more precise than either sensor alone. Two flawed measurements, combined optimally, beat the better of the two. Let's prove it and feel it.

The precisions simply add

Recall from Chapter 3's code that the fused variance came out as var_fused = 1/(PA + PB). Flip that over and you get the cleanest statement in all of estimation:

Pfused = PA + PB    i.e.   1/σ²fused = 1/σA² + 1/σB²

Read it slowly: the precision of the fused estimate is the sum of the two precisions. Information adds. Each sensor contributes its full vote-strength to the total, and the total is bigger than either part. This is not a coincidence or an approximation — it falls straight out of the same minimization we did in Chapter 3 (plug the optimal w back into σ²fused(w) and the algebra collapses to exactly this).

Why must the fused variance shrink? Because precision can only add — PA + PB is strictly larger than either PA or PB alone (both precisions are positive). And since variance is one over precision, a bigger total precision means a smaller fused variance. So σ²fused is always less than the smaller of σA² and σB². Fusion never hurts (for independent unbiased sensors); it can only sharpen.

Worked numbers — the thermometers again

Continue our thermometer example. PA = 4.0, PB = 0.25.

Pfused = 4.0 + 0.25 = 4.25
σ²fused = 1 / 4.25 = 0.235

The fused variance, 0.235, is smaller than even the lab thermometer's 0.25 — the best single sensor we had. In standard-deviation terms, σfused = √0.235 ≈ 0.485 °C, beating the lab thermometer's 0.5 °C. We took our best instrument and made it better by adding a worse one. That feels almost like cheating — but it's real, and it's why you fuse even mediocre sensors: each one, however humble, donates a little precision to the pile.

The deep payoff: even a bad sensor helps a little. The cheap thermometer contributed only 0.25 of precision against the lab one's 4.0 — a small donation, but a positive one. The fused estimate is sharper than the lab thermometer alone because of that small contribution. This is the engine behind averaging many noisy readings to beat noise: each reading is a low-precision measurement, but their precisions pile up. Average n equally-precise readings and the fused variance drops by a factor of n — the classic "√n" improvement — which is just this rule applied n times.

Where the shrinking comes from — plug the optimal w back in

The "precisions add" result isn't an extra assumption; it falls straight out of the variance we minimized in Chapter 3. Recall the fused variance as a function of the dial: σ²fused(w) = w²σA² + (1−w)²σB². We found the optimal w = σB²/(σA²+σB²), and so 1−w = σA²/(σA²+σB²). Substitute both back in. Writing S = σA²+σB² to keep it tidy:

σ²fused = (σB²/S)²·σA² + (σA²/S)²·σB²
= (σA²σB²/S²)·(σB² + σA²) = σA²σB²·S / S² = σA²σB² / (σA²+σB²)

So σ²fused = σA²σB²/(σA²+σB²) — the "product over sum" form. Flip it over (take its reciprocal) and watch the precisions appear: 1/σ²fused = (σA²+σB²)/(σA²σB²) = 1/σB² + 1/σA² = PA + PB. The "precisions add" rule is just the reciprocal of the product-over-sum variance. Verify it on the thermometers: σA²σB²/(σA²+σB²) = (0.25×4)/(0.25+4) = 1.0/4.25 = 0.235 — the same 0.235 we got the other way. Two routes, one number.

The √n law, worked out

The "average many readings" trick is worth doing explicitly, because it's the most common use of this rule in all of science. Suppose you take n readings of the same fixed quantity from one sensor, each with variance σ². Treat them as n independent measurements and fuse them. Since they're equally precise, each contributes precision 1/σ², and the total precision is n/σ². So the fused variance is:

σ²fused = 1/(n/σ²) = σ²/n    ⇒    σfused = σ/√n

The fused standard deviation shrinks as one over the square root of n. Take 4 readings and your error halves; take 100 readings and it drops by a factor of 10. This is the reason scientists repeat measurements: averaging is inverse-variance fusion of identical sensors, and the √n law is this chapter's "precisions add" applied n times. (Note the diminishing returns — going from 1 to 4 readings halves the error, but going from 100 to 400 only halves it again. Precision adds linearly; the standard-deviation payoff is square-rooted.)

The second derivation — multiplying two bell curves

Everything above came from minimizing variance. There's a completely different route to the exact same formulas that is worth seeing, because it reveals why the rule is not just convenient but probabilistically optimal. It comes from treating each measurement as a bell curve (a Gaussian) of belief over where the truth might be.

A measurement isn't really a single number; it's a statement of belief: "the truth is probably near xA, with a spread of σA." That's a bell curve centered at xA with width σA. Sensor B gives another bell curve, centered at xB with width σB. To combine two independent pieces of evidence about the same truth, probability theory says you multiply the two bell curves point by point and renormalize. (Multiplying is how you combine independent evidence — the truth must be consistent with both sensors, so where both curves are high, the combined belief is very high.)

The remarkable fact about Gaussians. When you multiply two bell curves together, the result is another bell curve. Bell curves are closed under multiplication. (Most curve families aren't this lucky — multiply two triangles and you don't get a triangle.) This single property is the reason Gaussians dominate estimation: combine Gaussian beliefs and you stay Gaussian, so the math never gets more complicated as evidence accumulates. The Kalman filter rides entirely on this fact.

And here's the punchline: when you do the multiplication and read off the center and width of the product bell curve, you get exactly the inverse-variance formulas. The product's center is the precision-weighted average x̂ = (PAxA + PBxB)/(PA+PB), and the product's precision is PA + PB. The variance-minimization route and the multiply-the-bell-curves route arrive at the identical answer. That agreement is the signal that this rule is not arbitrary — it is the genuinely optimal way to combine two Gaussian measurements.

Look at the product curve and you see both results at once: it's taller and narrower than either parent (precision added → variance shrank), and its peak sits between the two parents, pulled toward the narrower one (precision-weighted center). Below, drag the two bell curves and watch the green product form — always tighter, always leaning toward the more confident sensor.

Multiply two bell curves — the product is always tighter

The blue and orange bells are the two sensors' beliefs. The green bell is their normalized product — the fused belief. Drag the means and widths: the product is always taller and narrower than either parent (precision adds, variance shrinks), and its peak leans toward the more confident (narrower) sensor.

mean A -1.5 σA 0.7 mean B 1.5 σB 1.4
Two roads, one destination. Minimize the fused variance and you get x̂ = precision-weighted average, Pfused = PA + PB. Multiply the two Gaussian beliefs and you get the exact same thing. The first road proves it's the minimum-variance estimate; the second proves it's the most-probable estimate under Gaussian assumptions. They agree, and that agreement is why this rule sits at the foundation of estimation. The fused belief is always tighter than either input — fusion adds information, and information can only sharpen.
You fuse a lab thermometer (variance 0.25) with a cheap one (variance 4). What is the fused variance, and how does it compare to the best single sensor?

Chapter 5: This Is the Kalman Update in Disguise — The Bridge

Now for the reveal that makes this lesson the linchpin of the whole series. The inverse-variance weighted average you just derived is not like the Kalman filter's measurement update — it is the Kalman filter's measurement update, for a single scalar quantity. The Kalman filter (Lesson 5, and the standalone Kalman Filter lesson) looks formidable with its "gain," its "innovation," its matrices. But strip it down to one number being measured, and every piece of it is something you already computed in Chapter 3.

Renaming, not re-deriving

The Kalman filter combines a prior belief (its prediction of where the quantity is) with a new measurement. Map our two sensors onto those roles:

The Kalman filter fuses these two exactly the way we fused our two thermometers: precision-weighted average, with the fused precision being the sum. The only thing the filter does differently is write it in a rearranged algebraic form using a quantity it calls the Kalman gain K. Let's show that K is just our weight w under a new name.

From our formula to the Kalman form, step by step

Start from our fused estimate, with A as the prior (xA, σA²) and B as the measurement (xB, σB²):

x̂ = w·xA + (1−w)·xB,    w = σB² / (σA² + σB²)

The Kalman filter prefers to express the update as "start from the prior, then nudge toward the measurement by some fraction of the disagreement." Algebraically rearrange our formula by adding and subtracting xA:

x̂ = xA + (1−w)·(xB − xA)

Define the Kalman gain as that nudge fraction, K = (1−w). Substituting w gives:

K = 1 − w = 1 − σB²/(σA²+σB²) = σA² / (σA² + σB²)

And the update becomes the textbook scalar Kalman measurement update:

x̂ = xA + K·(xB − xA)

In the filter's own notation, with xA = the prior x̂, xB = the measurement z, σA² = P, σB² = R:

K = P / (P + R),    x̂ = x̂ + K·(z − x̂)

That is the Kalman update. You just derived it — it's the inverse-variance weighted average, rearranged. The term (z − x̂), the gap between what you measured and what you predicted, even has a famous name: the innovation (or residual). K is the trust slider that decides how much of that surprise to absorb.

The Kalman gain is a trust slider — read it off the formula

K = P/(P+R) is a number between 0 and 1, and you can read its behavior straight from the variances:

SituationWhat happens to KBehavior
Measurement is very noisy (R large)K → 0barely move from the prediction — don't trust the noisy reading
Prediction is very uncertain (P large)K → 1jump almost entirely to the measurement — the prediction was worthless
Prediction and measurement equally trustedK = 0.5split the difference — the plain average, again

It's the same precision logic, one more time: trust the more precise source. When R is huge, the measurement whispers and K shuts it out; when P is huge, the prediction is hopeless and K throws it away. The "trust slider" framing you may have heard for the Kalman gain is literally the weight w from this lesson.

And the variance update matches too

Our fused precision was Pfused = PA + PB, i.e. σ²fused = 1/(1/σA² + 1/σB²). The Kalman filter writes the same thing as P = (1 − K)·P. Let's confirm they're identical. From Chapter 4's product-over-sum form, with A as prior (variance P) and B as measurement (variance R):

σ²fused = P·R / (P + R)

Now expand the Kalman form (1−K)P using K = P/(P+R):

(1 − K)P = (1 − P/(P+R))·P = (R/(P+R))·P = PR/(P+R)

Identical — the posterior variance shrinks by the factor (1−K), exactly the "fused uncertainty always shrinks" result from Chapter 4. The filter's covariance update is Chapter 4 in disguise, just as its state update is Chapter 3 in disguise.

One full tick, by hand

Let's run a single scalar Kalman measurement update with real numbers, so you can see the renaming pay off. The filter's prior says the quantity is at x̂ = 60 with variance P = 4. A new measurement arrives: z = 40 with noise R = 1 (a fairly precise measurement). Compute the gain, the update, and the new variance:

(1) Kalman gain. K = P/(P+R) = 4/(4+1) = 4/5 = 0.8.

(2) Innovation (the surprise): z − x̂ = 40 − 60 = −20.

(3) State update. x̂ = x̂ + K·(innovation) = 60 + 0.8×(−20) = 60 − 16 = 44.

(4) Variance update. P = (1−K)P = (1−0.8)×4 = 0.2×4 = 0.8.

The filter moved from 60 most of the way (80%) toward the measurement's 40, landing at 44, because the measurement (R=1) was four times more precise than the prior (P=4) — so it deserved the bigger pull. And the variance dropped from 4 to 0.8, tighter than either input (the measurement's 1 included). Cross-check against the precision-weighted average: Pprior=1/4=0.25, Pmeas=1/1=1.0; x̂ = (0.25×60 + 1.0×40)/(0.25+1.0) = (15+40)/1.25 = 55/1.25 = 44 — the identical 44. Fused variance = 1/1.25 = 0.8 — the identical 0.8. The Kalman update and the inverse-variance average are not similar; they are the same arithmetic.

The same code, twice — proving the equivalence

Here are the two update styles side by side in code. They take the same inputs and return the same outputs — because they're the same equation rearranged. Run them and the assertion passes:

python
def fuse_weighted(x_prior, P_prior, z, R):
    # view 1: inverse-variance weighted average
    pa, pb = 1.0/P_prior, 1.0/R
    x = (pa*x_prior + pb*z) / (pa + pb)
    P = 1.0 / (pa + pb)
    return x, P

def kalman_update(x_prior, P_prior, z, R):
    # view 2: the textbook scalar Kalman measurement update
    K = P_prior / (P_prior + R)          # gain = weight, renamed
    x = x_prior + K * (z - x_prior)       # nudge by K toward the surprise
    P = (1 - K) * P_prior              # variance shrinks by (1-K)
    return x, P

fuse_weighted(60, 4, 40, 1)   # -> (44.0, 0.8)
kalman_update(60, 4, 40, 1)   # -> (44.0, 0.8)   IDENTICAL

Two functions, one answer, every time. The only difference is which algebraic skin you wear — "weight by precision" or "nudge by gain." The Kalman filter chose the second skin because the prediction step makes the prior grow each tick, and writing the update as "start from the prior and correct" composes cleanly with that. But under the skin it's this lesson's atom.

The whole bridge in one sentence. A Kalman filter is just this lesson's two-measurement fusion, run once per time step, where one of the two "measurements" is the filter's own prediction of where the quantity should be. Everything else the filter adds — the prediction step, the matrices for tracking many quantities at once — is machinery around this core update. The update itself is the inverse-variance weighted average you derived by hand. If you understand this chapter, you understand the beating heart of the Kalman filter.

Below, see the equivalence directly. The same two-sensor scenario, shown both as "precision-weighted average of A and B" and as "Kalman update: start at the prior, nudge by K toward the measurement." Drag the variances and watch both descriptions produce the identical fused value — because they are the same equation.

Same fusion, two names — weighted average ≡ Kalman update

Left view: the prior and the measurement with the fused estimate as a precision-weighted average. Right view: the same result as a Kalman update — start at the prior and slide a fraction K toward the measurement. Adjust the variances; the green dot lands in the same place both ways.

prior var P 4 meas var R 1
The scalar Kalman gain is K = P/(P+R). If the new measurement is extremely noisy (R very large), what is K and what does the filter do?

Chapter 6: Showcase — The Two-Gaussian Fuser, and How to Break It

Time for the payoff. Everything in this lesson — the weighted average, the precision weighting, the shrinking variance, the Gaussian product, the Kalman link — lives in one interactive fuser below. No new theory; just every idea made visible, draggable, and breakable in a single sim. Drag the two sensors' means, dial their variances, and watch the fused Gaussian form in real time: tighter than either input, pulled toward the more precise one.

And then — the most instructive part — you can flip on a bias toggle that secretly poisons one sensor (makes it read systematically high), violating the "unbiased" assumption our whole derivation rested on. Watch the fused estimate confidently march toward a wrong answer, and see why the formula has no defense against a liar. That failure is the entire subject of Chapter 9; here you get to cause it with a button.

This is the whole lesson in one sim. The blue and orange bells are the two sensors. The green bell is the inverse-variance fused belief — always narrower (precision added), always leaning toward the more confident sensor (precision weighted). The dashed line is the hidden truth. Make one sensor very precise and watch the fusion crowd toward it. Then flip on bias and watch the formula get fooled.
The two-Gaussian fuser — drag, dial, and break it

Drag each sensor's mean and variance. The green fused bell updates live: precision-weighted center, summed precision (so it's tighter than both). The dashed line is the hidden truth. Toggle Bias sensor B to make B read systematically high — the fused estimate will drift toward the lie, because inverse-variance fusion assumes both sensors are unbiased.

mean A 55 σA² 20 mean B 45 σB² 80

Play with it for a minute and the lesson's claims announce themselves visually:

A guided experiment — reproduce every claim in five steps

Don't just watch; falsify. Run this sequence and confirm each prediction with your own eyes:

  1. Set both variances equal (say both 50). The green peak lands exactly halfway between the two means — the plain average. Confirms Chapter 3's "equal variances → w = 0.5."
  2. Drop σA² to its minimum, raise σB² to its maximum. The green peak slams against sensor A and the readout shows wA near 0.99 — the precise sensor dominates. Confirms precision weighting.
  3. Watch the fused σ² readout in every configuration. It is always below the smaller of the two input variances. Confirms Chapter 4's "fusion never hurts."
  4. Put both means on the truth line, variances moderate. The green bell towers over both parents — two agreeing sensors give a very confident fused estimate. Information piled up.
  5. Now flip on Bias sensor B. B's bell slides off the truth, the green peak follows it part-way, and the readout flags "fused estimate is biased." The formula was fooled because it trusted B's stated precision while B was lying. This is exactly the failure Chapter 9 teaches you to detect.
You just watched the whole lesson run live. Inverse-variance fusion is not a black box — it's a tug-of-war between two bell curves, won by the one with more precision, producing a child curve tighter than either parent. And its one fatal weakness, visible the moment you flip the bias toggle, is that it trusts each sensor's claimed precision blindly: a sensor that lies confidently poisons the result. Keep that image — the green peak marching toward a wrong answer while staying narrow — it's the picture behind every "overconfident fusion" bug in the field.

Chapter 7: Use Cases & Real Products — The Atom In the Wild

Every lesson in this series ends with the same four chapters — Use Cases, Practical Application, Debugging, Connections — because a formula you can't point at in a shipped product is a formula you don't really own. So before any more theory, let's find the inverse-variance weighted average running inside hardware you can buy and software you've used.

The payoff of learning this atom: once you can spot "combine two estimates of the same thing," you can spot this exact formula running, and predict how it'll behave. It is everywhere, usually unnamed. Here's the tour.

Inside every Kalman filter, every tick. This is the headline use case, proven in Chapter 5. GPS receivers, drone autopilots, spacecraft navigation, the orientation filter in your phone, robot localization — all run Kalman (or extended/unscented) filters whose measurement-update step is this fusion. When your phone's compass smoothly settles after you wave it in a figure-eight, that's the inverse-variance average blending the magnetometer reading against the gyro-predicted heading, weighted by their precisions. Billions of devices, one formula.

Redundant industrial sensors voting on one quantity. A chemical plant measures a critical tank pressure with two or three independent transducers. Rather than a crude median, modern distributed control systems often fuse them by precision: a recently-calibrated transducer (tight variance) dominates a drifting older one (loose variance). The fused pressure is sharper than any single gauge — Chapter 4's free precision — and the weighting adapts as sensors age and their variances grow.

GPS multi-constellation fusion. Your phone doesn't just listen to American GPS satellites — it fuses fixes from GPS, Russia's GLONASS, Europe's Galileo, and China's BeiDou. Each constellation gives a position estimate with its own uncertainty (which depends on how many of its satellites are visible and their geometry). The receiver combines them by precision-weighting, so a constellation with great satellite geometry right now contributes more than one with satellites bunched low on the horizon. More constellations → more precision piled up → a tighter fix, exactly Chapter 4.

Poll-of-polls and meta-analysis. Election forecasters and medical researchers face the identical problem: many studies/polls each estimate the same quantity with its own margin of error. The principled combination — the "fixed-effect meta-analysis" — is precisely the inverse-variance weighted average. A poll of 3000 people (small variance) outweighs one of 300 (large variance). The same formula that fuses two thermometers fuses a thousand polls.

The pattern across products

Notice the recurring shape: several estimates of one quantity, each with a known-ish uncertainty, combined by precision.

SystemThe "sensors"The quantity fusedWhat precision-weighting buys
Kalman filter (any)prior prediction + new measurementthe state estimateoptimal blend; smooth, confident tracking
Phone orientationgyro prediction + accel/mag readingheading & tiltfast and drift-free, the complementary trick
GPS multi-GNSSGPS + GLONASS + Galileo fixespositiontighter fix as constellations add precision
Industrial redundant gauges2–3 transducerspressure / temperature / flowsharper than any gauge; ages gracefully
Poll-of-polls / meta-analysismany polls or studiesthe effect / vote sharebig studies dominate; tightest combined estimate

The deep case: why your phone's "smooth blue dot" relies on it

Open a maps app and the blue dot glides smoothly even as raw GPS fixes arrive jumpy and sparse. Under the hood, a filter is fusing two estimates of your position every fraction of a second: a prediction (where you should be, propagated from your last position and motion) and a measurement (the latest GPS or Wi-Fi fix). Each carries a variance — the prediction's variance grows between fixes (you might have turned), the GPS fix's variance reflects signal quality. The fused position is the inverse-variance weighted average of the two, recomputed continuously.

When you walk into a building and GPS degrades, the fix's variance balloons, its precision collapses, and the fusion automatically leans almost entirely on the prediction — the dot keeps moving smoothly instead of teleporting to a bad fix. When you step back outside and a crisp fix returns (small variance, high precision), the fusion snaps the dot back to truth. That graceful "lean toward whatever is more precise right now" behavior is not special-cased; it falls straight out of the formula you derived in Chapter 3, with the variances doing all the steering.

How to spot this formula on a spec sheet

You can now reverse-engineer when a product is running inverse-variance fusion. Three tells:

A worked product case — the poll-of-polls, fused by hand

To prove the formula is the same one running far outside robotics, fuse two real-shaped opinion polls of the same race. Poll A surveyed 2400 people and found candidate support at 52%, with a margin of error of about ±2 points (so σA ≈ 1, σA² ≈ 1). Poll B surveyed only 600 people and found 47%, with a wider margin of about ±4 points (σB ≈ 2, σB² ≈ 4). A naive average would say (52+47)/2 = 49.5%. But the big poll is four times more precise, and the inverse-variance rule knows it: PA = 1, PB = 0.25, so wA = 1/1.25 = 0.8. Fused = 0.8×52 + 0.2×47 = 41.6 + 9.4 = 51.0%, leaning toward the larger, tighter poll. And the fused margin shrinks: σ²fused = 1/(1+0.25) = 0.8, so σfused ≈ 0.9 — tighter than even the big poll. This is exactly how forecasters build a "poll-of-polls," and it is the identical formula that fuses two thermometers or two GPS fixes. The atom does not care what the quantity is.

The deployable insight. Wherever a system combines several estimates of one quantity and cares about doing it optimally, the inverse-variance weighted average is the right tool — and it's almost always what's actually running, named or not. It is the most-used formula in estimation precisely because it's the simplest thing that's also provably optimal. When you see "fuses measurements" anywhere, your first guess should be: precision-weighted average.
A phone fuses GPS, GLONASS, and Galileo position fixes, each with its own uncertainty, and combines them weighting each by its precision. Which lesson concept is this, and what does adding more constellations buy?

Chapter 8: Practical Application — Where Do the Variances Come From?

The formula is trivial to apply — multiply, add, divide. The hard part, the part that separates a working fuser from a broken one, is the input you need before you can apply it: each sensor's variance. The whole method weights by precision, and precision is 1/σ², so if your variances are wrong, your fusion is wrong — no matter how perfect the arithmetic. This recurring "now build it" chapter is about getting those variances right, and deciding when to fuse at all.

There is no formula that gives you a sensor's variance; you have to estimate it. Here are the four standard ways, from quickest-and-roughest to most-rigorous, plus the judgment call of when to reject a measurement instead of fusing it.

Method 1 — read it off the datasheet

The fastest source: the manufacturer's spec sheet. A datasheet line like "accuracy ±0.5 °C (1σ)" or "RMS error 2 m" is handing you σ directly — square it to get the variance. A thermometer rated ±0.5 °C at one sigma has σ = 0.5, so σ² = 0.25 (exactly our lab thermometer). Watch the fine print: specs are often quoted at "2σ" (95%) or as a max error rather than a standard deviation, and they assume the sensor is calibrated and operating in spec. Datasheet variances are a good starting guess, rarely the final word.

Datasheet specs are optimistic. They're measured in a lab, on a fresh unit, at room temperature, with a clean signal. Your sensor is dusty, aging, vibrating, and hot. Real-world variance is usually larger than the datasheet number — sometimes several times larger. Starting from the datasheet and then inflating it based on residuals (Method 4) is the practical recipe. Trusting the datasheet variance literally is a classic cause of the overconfidence bug in Chapter 9.

Method 2 — measure it against a known truth

If you can put the sensor against a reference whose true value you know, you can compute its variance empirically. Take many readings of the known quantity, find each error (reading minus truth), and the variance is the average of the squared errors. Worked example: a rangefinder measures a wall you've placed at exactly 5.00 m, and over ten readings you get errors (in cm) of +2, −1, +3, 0, −2, +1, +2, −3, +1, −3. Square them: 4, 1, 9, 0, 4, 1, 4, 9, 1, 9. Sum = 42. Divide by 10: variance ≈ 4.2 cm², so σ ≈ 2.05 cm. Now you have a real, measured variance to feed the fuser.

Method 3 — Allan variance, for drifting sensors

Some sensors — especially IMUs and oscillators — have noise that changes character with how long you average. Average briefly and you fight fast white noise; average too long and slow drift (bias instability) takes over. The Allan variance is a standard plot (variance vs averaging time) that separates these regimes, letting you read off the white-noise level, the bias instability, and the optimal averaging window. It is the tool of choice for characterizing the σ² you should feed a filter for a gyroscope or accelerometer. You don't need its math here — just know that for time-correlated, drifting sensors, a single number won't do, and Allan variance is how the pros pin down the variance to use.

Method 4 — estimate it online from the residuals (the pro move)

The most robust approach doesn't trust any fixed number — it watches the sensor's own disagreements and infers the variance from them. The residual (or innovation, the Kalman name from Chapter 5) is the gap between what a sensor reported and what the fused estimate (or prediction) expected. If a sensor's residuals are consistently large, its real variance is large; if they're tiny, it's precise. By tracking the running average of squared residuals, a filter can adapt each sensor's variance to its actual recent behavior — catching a sensor that has started to degrade and down-weighting it automatically.

live variance estimate ≈ average of (recent residuals)²

This is how good systems stay honest: the variance you fuse with isn't a constant from a datasheet, it's a measured property of how the sensor is behaving right now. Adaptive filtering, covariance estimation, and "innovation-based" tuning are all elaborations of this one idea.

When to fuse vs when to reject

Sometimes the right move is not to fuse a measurement at all, but to throw it out. The decision uses the same residual: if a measurement disagrees with your current fused estimate by far more than its claimed variance can explain, it's probably a fault, not noise, and fusing it in would poison the estimate. The standard test compares the squared residual to the variance — if a reading lands many standard deviations away from where it should, you gate it out (reject it) rather than fuse it.

if (residual)² > (gate)² × (expected variance)  →  reject this measurement

A common choice is a "3-sigma gate": reject anything more than three standard deviations from the prediction. This is the bridge between this lesson (fuse optimally when the assumptions hold) and competitive/fault-tolerant fusion (decide whether the assumptions hold). Inverse-variance fusion handles honest noise beautifully; gating is the guard that keeps a liar from ever reaching it.

A decision flow for getting the variances right

Putting the four methods in order gives you a procedure you can run on any sensor before trusting it in a fuser:

Start: do you have a datasheet?
Yes → take the ±1σ spec, square it for an initial σ². No → go straight to measuring it.
Can you put it against a known reference?
Yes → collect readings, average the squared errors for a real σ² (Method 2). Drifting sensor (IMU/clock)? → use Allan variance (Method 3).
In operation, watch the residuals
Inflate σ² when the sensor disagrees more than expected (Method 4); gate out wild outliers as faults.
↻ re-estimate continuously

The golden rule running through the whole flow: never let a variance be a constant you set once and forget. A datasheet number is a starting hypothesis; a reference measurement validates it; live residuals keep it honest as the sensor ages, heats up, and degrades. The fusion arithmetic is identical whether the variance is 1 or 100 — what makes the difference between a trustworthy system and a dangerous one is whether that number reflects reality right now.

The reusable procedure

How to actually deploy two-sensor fusion. (1) Get a starting variance for each sensor from its datasheet (square the ±1σ spec). (2) Validate and refine it against a known reference if you can (Method 2), or with Allan variance for drifting sensors (Method 3). (3) In operation, track each sensor's squared residuals and inflate its variance when it starts disagreeing more than expected (Method 4) — never trust a fixed datasheet number forever. (4) Gate out any measurement whose residual is wildly larger than its variance can explain (a fault). Then, and only then, apply the inverse-variance weighted average. The arithmetic is the easy 10%; getting the variances honest is the hard, valuable 90%.

A worked end-to-end mini-example

You're fusing two altimeters on a drone. The barometer datasheet says ±1 m (1σ) → σ² = 1. The GPS-vertical is spec'd at ±3 m → σ² = 9. Readings: baro = 50.0 m, GPS = 53.0 m. Precisions: Pbaro = 1/1 = 1, Pgps = 1/9 = 0.111. Fused estimate = (1×50 + 0.111×53)/(1.111) = (50 + 5.89)/1.111 = 50.3 m — leaning hard toward the trusted barometer. Fused variance = 1/1.111 = 0.9 m² (σ ≈ 0.95 m), tighter than the barometer alone. But — if the GPS residual (53 − 50.3 = 2.7 m) keeps growing tick after tick, Method 4 says inflate its variance (it's drifting), and a 3σ gate against the barometer would eventually reject it entirely. The formula is the same; the variances do the thinking.

Your fusion is mathematically perfect but produces overconfident, slightly-off estimates in the field. The most likely culprit and fix?

Chapter 9: Debugging & Failure Modes — Three Ways the Formula Lies to You

The inverse-variance weighted average is optimal — but only when its assumptions hold. The assumptions are exactly three: the sensors are unbiased, their errors are independent, and their variances are correct. Break any one and the formula keeps producing a confident answer that is silently wrong. The danger isn't a crash — it's a number that looks trustworthy (narrow fused variance) while being off the truth. This recurring chapter catalogs the three failures, the symptom each shows in the field, and the test that exposes it.

If you remember nothing else: the formula trusts what you tell it. Tell it a sensor is precise when it isn't, tell it two sensors are independent when they aren't, or feed it a biased sensor, and it will faithfully compute the optimal fusion of those wrong assumptions. The bugs all live in the gap between what you assumed and what's true.

Trap 1 — Wrong (optimistic) variances: overconfident fusion

The most common failure, straight out of Chapter 8. You hard-code a sensor's variance too small — usually by trusting an optimistic datasheet — so the formula gives that sensor too much weight and reports a fused variance that's far tighter than reality. You've built a fuser that is confidently wrong: its error bars say ±0.5 m while it's actually off by 3 m.

Symptom & detection. Symptom: the fused estimate's actual errors are much larger than its reported variance predicts — the system claims more confidence than it earns, and a downstream controller (trusting that confidence) makes bad decisions. Detection: the consistency test. Over many fusions, the squared (residual / claimed-σ) should average to about 1 if the variances are honest. If it's consistently much bigger than 1, your variances are too small. (Filter engineers call the formalized version the NEES / NIS test.) Fix: measure real variances (Chapter 8, Method 2–4) and inflate the optimistic ones.

A concrete instance: if you set one sensor's variance to near-zero (you trust it absolutely), its precision blows up and its weight pins at 1 — you've built a single-sensor system wearing a fusion costume. The other sensor contributes nothing, and you've thrown away the free precision (Chapter 4) that fusion was supposed to buy. Verify that the weights actually split the trust, rather than one sensor silently winning everything.

Trap 2 — Correlated sensors: double-counting evidence

Our entire derivation assumed the two sensors' errors are independent. The "precisions add" result (Chapter 4) is true only under independence. If the two sensors are correlated — they share an error source — then fusing them as if independent double-counts the shared information, and you end up more confident than you should be (an even sneakier overconfidence than Trap 1).

The classic case: two "independent" GPS receivers on the same vehicle both suffer the same atmospheric delay and the same multipath off the same building. Their errors move together. Fuse them with the independent formula and the fused variance looks tiny — but both sensors were wrong in the same direction, so the fused estimate is wrong too, while claiming high confidence. You added a second sensor and got almost no real information, because it was telling you the same lie as the first.

Symptom & detection. Symptom: adding a second sensor barely improved real accuracy despite the formula promising a big variance reduction — and the fused estimate is overconfident in a way that doesn't go away no matter how carefully you tune individual variances. Detection: ask "do these sensors share an error source?" — same physical mount, same power, same environment, same atmospheric path, same firmware. Any shared cause creates correlation. Fix: either model the correlation (covariance grows beyond the diagonal — the subject of covariance intersection, Lesson 11 of this series) or use genuinely dissimilar sensors. This is the assumption that breaks most often in real multi-sensor systems.

Make the danger concrete with numbers. Two GPS receivers each have variance σ² = 4 m². If they were truly independent, fusing them would give a fused variance of 4×4/(4+4) = 2 m² — a real improvement, the formula's promise. But suppose their errors are perfectly correlated (they share the exact same atmospheric delay, so they always err together). Then the second receiver tells you nothing new — it's a carbon copy of the first — and the honest fused variance is still 4 m², not 2. Yet the independent formula reports 2 m²: it thinks you halved your uncertainty when you actually halved nothing. You've convinced yourself you're twice as confident as the truth warrants. In a controller that trusts those error bars, that phantom confidence is exactly how a system drives into a wall while its dashboard reads "all clear."

Trap 3 — A biased sensor poisons the average

We assumed each sensor is unbiased — its errors average to zero. A biased sensor reads systematically high (or low): a thermometer that always reads 2 °C hot, a pressure gauge with a zero-offset, a GPS with an uncorrected datum shift. Inverse-variance fusion has no defense against bias. Worse: if the biased sensor has a small variance (it's biased but consistent), the formula trusts it heavily and drags the fused estimate hard toward the bias. A precise liar is far more dangerous than an imprecise one.

You saw this in the Chapter 6 showcase: flip the bias toggle and the fused estimate marches toward the lie while its variance stays narrow — confidently wrong. The formula did its job perfectly; it optimally fused a measurement that was lying about its center while telling the truth about its spread.

Symptom & detection. Symptom: the fused estimate has a persistent, consistent offset from truth — not noisy scatter, but a steady lean in one direction. Detection: residual monitoring. A biased sensor's residuals (its disagreement with the fused estimate or a reference) don't average to zero — they sit consistently positive or consistently negative. An honest sensor's residuals straddle zero; a biased one's don't. Watch the mean of each sensor's residuals over time, not just their spread. Fix: calibrate out the bias (subtract the measured offset), or gate/reject the sensor once its residual mean drifts past a threshold.

The two diagnostic tests, side by side

Two simple residual checks catch nearly every failure in this chapter:

TestWhat you watchHealthy looks likeCatches
Residual meanaverage of (sensor − fused) over time≈ 0 (straddles zero)Trap 3 (bias) — a nonzero mean = a biased sensor
Consistency (NEES/NIS)average of (residual / claimed-σ)²≈ 1Trap 1 (optimistic variance) & Trap 2 (correlation) — values >> 1 = overconfidence

Run both continuously on any fusion system. The residual mean tells you where (is a sensor lying about its value?); the consistency statistic tells you how confident you're allowed to be (are your variances honest?). Together they convert "the fusion feels off" into a specific, fixable diagnosis.

The two tests in code

Both diagnostics are a few lines each — you should bolt them onto any fuser you ship:

python
def monitor(residuals, claimed_sigma):
    # residuals = list of (sensor_reading - fused_estimate) over time
    n = len(residuals)
    mean_resid = sum(residuals) / n                       # Test 1: should be ~0
    nis = sum((r/claimed_sigma)**2 for r in residuals) / n  # Test 2: should be ~1
    bias_flag = abs(mean_resid) > 2 * claimed_sigma / n**0.5     # nonzero mean -> biased
    overconf_flag = nis > 2.0                            # NIS >> 1 -> variances too small
    return dict(mean=mean_resid, nis=nis, biased=bias_flag, overconfident=overconf_flag)

# a biased sensor: residuals all positive, clustered near +2
monitor([1.8, 2.1, 1.9, 2.0, 2.2, 1.7], claimed_sigma=1.0)
# -> mean ~1.95 (BIASED flagged), nis ~3.8 (also overconfident)

The biased sensor lights up both flags: its nonzero residual mean (~1.95) trips the bias detector, and because those residuals are far larger than its claimed σ=1, the consistency statistic (~3.8, well above 1) also trips the overconfidence detector. The two tests are complementary — the mean catches a steady lean, the NIS catches dishonest spread — and together they cover all three traps.

A worked detection — spotting the biased sensor

Suppose over many ticks, Sensor B's residuals (B's reading minus the fused estimate) are: +1.8, +2.1, +1.9, +2.0, +2.2, +1.7. Notice they're all positive and cluster around +2. An honest sensor's residuals would be roughly half positive and half negative, averaging near zero. B's average residual is about +1.95 — a glaring nonzero mean. Verdict: Sensor B has a bias of about +2. The fix is immediate: subtract 2 from every B reading before fusing (calibration), and the residuals snap back to straddling zero. No fancy statistics needed — just watching the sign of the residuals over time exposed the bias the variance-based tests would have missed (a consistent bias doesn't inflate variance, so it hides from consistency checks but glares in the residual mean).

The meta-lesson. Inverse-variance fusion is optimal given its assumptions — unbiased, independent, correctly-known variances. Every bug in this chapter is a violated assumption that the formula can't see. The cure is never to distrust the formula; it's to verify the assumptions with residual monitoring. Watch the residual mean (catches bias) and the consistency statistic (catches bad/correlated variances), and the formula's confident answers become trustworthy ones.
A fused estimate shows a steady offset from truth — not random scatter, but a consistent lean in one direction — even though the math is correct. Which trap is this, and how do you detect it?

Chapter 10: Connections, References & Cheat-Sheet

You now hold the atom of sensor fusion: the optimal way to combine two noisy measurements of one quantity. Every probabilistic estimator in this series is built from this operation. Before we point to what's next, here's everything in one place — the cheat-sheet to screenshot, the motto, the real sources, and the cross-links.

Combining two measurements — cheat-sheet

The problem: two unbiased, independent measurements of one quantity — xA with variance σA², xB with variance σB². Find the single best estimate.

The wrong answer: the plain average (xA+xB)/2 — correct only when the sensors are equally reliable; otherwise it ignores what you know about trust.

Precision: P = 1/σ². Big when a sensor is sure, small when it's sloppy. Precision = "vote strength."

The right answer (inverse-variance weighted average):
· estimate: x̂ = (PAxA + PBxB) / (PA + PB) — weight each by its precision.
· weight on A: wA = PA/(PA+PB) = σB²/(σA²+σB²).
· fused precision: Pfused = PA + PB — precisions ADD.

Fusion never hurts: σ²fused is always smaller than the smaller input variance — the fused estimate beats the better of the two sensors.

Two derivations, one answer: minimize the fused variance → this. Multiply two Gaussian beliefs → this. Both agree, so it's the minimum-variance AND most-probable estimate (the BLUE).

The Kalman bridge: rename A → prior, B → measurement. Then K = P/(P+R), x̂ = x̂ + K(z − x̂). The scalar Kalman update IS this formula.

Three traps: optimistic variances (overconfident — consistency test) · correlated sensors (double-counting — check shared error sources) · biased sensor (poisons the average — watch the residual mean).

The motto

"What I cannot create, I cannot understand." — Richard Feynman.
You can now create the optimal two-sensor fuser from scratch — and the same hand-derived formula is the engine inside every Kalman filter you'll meet for the rest of this series.

The whole lesson in one quick-reference table

Screenshot this. It is the entire lesson collapsed into a single lookup:

QuantityFormulaIn words
PrecisionP = 1/σ²flip the variance — trustworthiness
Weight on AwA = PA/(PA+PB)A's share of the total precision
Fused estimatex̂ = wAxA + wBxBprecision-weighted average
Fused precisionPfused = PA+PBprecisions add — always sharper
Kalman gainK = P/(P+R)the weight w, renamed

Where this lesson sits in the series

This was Lesson 3 of 22 — the smallest fusion operation, the atom the rest of the series is built from. The recurring chapter structure you just walked (Why → concepts → showcase → Use Cases, Practical Application, Debugging, Connections) repeats in every lesson. Here's the road ahead, and how this formula grows into a full toolbox:

LessonsArcHow this atom shows up
1–3Foundationsthe fusion problem; fusion architectures; combining two measurements (here) — the atom
4–8Classical estimationthe Bayes filter (this fusion as belief update); the Kalman filter (this formula + a prediction step); EKF & UKF (this formula when sensors are nonlinear); particle filters
9–13Spatial fusionoccupancy grids; SLAM; visual-inertial odometry; multi-target tracking & data association; correlated estimates & covariance intersection (when independence breaks, Trap 2)
14–18Robust & distributedfault detection (the gating from Chapter 8, formalized); consensus over sensor networks; out-of-sequence measurements
19–22Modern / learneddeep multimodal fusion; transformer-based fusion; learned uncertainty (networks that predict their own variance to feed exactly this formula); the Sensor Fusion Atlas

Next up, Lesson 4: The Bayes Filter — the principled generalization of everything here. The Bayes filter treats your belief about a quantity as a full probability distribution and updates it with each new measurement using Bayes' rule. The "multiply two beliefs" move from Chapter 4 is exactly the Bayes-filter measurement update; the "precisions add" result is what it looks like when those beliefs are Gaussian. You'll see this lesson's two-measurement fusion become a single step in a filter that runs forever, fusing a new measurement into an accumulating belief at every tick.

Related lessons on Engineermaxxing

These existing lessons go deeper on the machinery we touched:

References

  1. Simon, D. Optimal State Estimation: Kalman, H∞, and Nonlinear Approaches. John Wiley & Sons, 2006. The modern standard reference; its treatment of recursive least squares and the Kalman update derives exactly the inverse-variance combination of this lesson. doi:10.1002/0470045345
  2. Maybeck, P. S. Stochastic Models, Estimation, and Control, Volume 1. Academic Press, 1979. The classic, beautifully clear derivation of combining measurements by inverse-variance weighting and the Gaussian-product view; Chapter 1 motivates the entire field with the two-measurement problem. Mathematics in Science and Engineering, vol. 141
  3. Gelb, A. (ed.) Applied Optimal Estimation. MIT Press, 1974. The compact engineer's bible; its weighted-least-squares treatment is the inverse-variance combination in matrix form.
  4. Kay, S. M. Fundamentals of Statistical Signal Processing, Volume 1: Estimation Theory. Prentice Hall, 1993. Develops the Best Linear Unbiased Estimator (BLUE) — the formal name for the inverse-variance weighted average derived in Chapter 3.
A colleague says "I'll just average my two sensor readings — it's simplest." When is that actually optimal, and what should they do otherwise?