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.
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.
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̂ (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?
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.
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.
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 it | The two (or more) measurements | The one fused quantity |
|---|---|---|
| A Kalman filter, every tick | the prediction & the new sensor reading | the updated state estimate |
| GPS with several satellites/constellations | position fixes from GPS + GLONASS + Galileo | one fused position |
| Two redundant industrial pressure gauges | two gauge readings of the same pipe | one trusted pressure |
| A weighted average of opinion polls | each poll's estimate + its margin of error | one poll-of-polls number |
| Combining two lab measurements of a constant | two experiments' values + their error bars | one 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.
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.
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.
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.
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?
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.
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 quality | 115 m | 115 m (correctly central) | 15 m |
| A is 4× better | 115 m | ~106 m | 15 m — unchanged! |
| A is 16× better | 115 m | ~102 m | 15 m — still 15 m |
| A is 100× better | 115 m | ~100 m | 15 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.
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:
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 w | x̂ becomes | Meaning |
|---|---|---|
| w = 1 | xA | trust Sensor A completely, ignore B |
| w = 0 | xB | trust Sensor B completely, ignore A |
| w = ½ | (xA + xB) / 2 | the 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.
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.
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.
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."
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:
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-grade | 0.5 °C | 0.25 | 4.0 — very sure | 22.0 °C |
| B — cheap probe | 2.0 °C | 4.0 | 0.25 — barely sure | 20.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.
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.
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.
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 σ.
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.
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.
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:
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.
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:
(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:
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.
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²):
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:
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:
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.
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.
(2) Total precision.
(3) Weights.
(4) Fused estimate.
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.
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.
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.
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.
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.
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.
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:
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.
Continue our thermometer example. PA = 4.0, PB = 0.25.
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 "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:
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 "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:
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.)
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.)
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.
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.
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.
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.
Start from our fused estimate, with A as the prior (xA, σA²) and B as the measurement (xB, σ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:
Define the Kalman gain as that nudge fraction, K = (1−w). Substituting w gives:
And the update becomes the textbook scalar Kalman measurement update:
In the filter's own notation, with xA = the prior x̂−, xB = the measurement z, σA² = P−, σB² = R:
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.
K = P−/(P−+R) is a number between 0 and 1, and you can read its behavior straight from the variances:
| Situation | What happens to K | Behavior |
|---|---|---|
| Measurement is very noisy (R large) | K → 0 | barely move from the prediction — don't trust the noisy reading |
| Prediction is very uncertain (P− large) | K → 1 | jump almost entirely to the measurement — the prediction was worthless |
| Prediction and measurement equally trusted | K = 0.5 | split 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.
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):
Now expand the Kalman form (1−K)P− using K = P−/(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.
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.
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.
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.
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.
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.
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.
Play with it for a minute and the lesson's claims announce themselves visually:
Don't just watch; falsify. Run this sequence and confirm each prediction with your own eyes:
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.
Notice the recurring shape: several estimates of one quantity, each with a known-ish uncertainty, combined by precision.
| System | The "sensors" | The quantity fused | What precision-weighting buys |
|---|---|---|---|
| Kalman filter (any) | prior prediction + new measurement | the state estimate | optimal blend; smooth, confident tracking |
| Phone orientation | gyro prediction + accel/mag reading | heading & tilt | fast and drift-free, the complementary trick |
| GPS multi-GNSS | GPS + GLONASS + Galileo fixes | position | tighter fix as constellations add precision |
| Industrial redundant gauges | 2–3 transducers | pressure / temperature / flow | sharper than any gauge; ages gracefully |
| Poll-of-polls / meta-analysis | many polls or studies | the effect / vote share | big studies dominate; tightest combined estimate |
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.
You can now reverse-engineer when a product is running inverse-variance fusion. Three tells:
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 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.
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.
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.
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.
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.
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.
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.
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.
Putting the four methods in order gives you a procedure you can run on any sensor before trusting it in a fuser:
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.
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.
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.
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.
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.
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.
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."
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.
Two simple residual checks catch nearly every failure in this chapter:
| Test | What you watch | Healthy looks like | Catches |
|---|---|---|---|
| Residual mean | average of (sensor − fused) over time | ≈ 0 (straddles zero) | Trap 3 (bias) — a nonzero mean = a biased sensor |
| Consistency (NEES/NIS) | average of (residual / claimed-σ)² | ≈ 1 | Trap 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.
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.
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).
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.
Screenshot this. It is the entire lesson collapsed into a single lookup:
| Quantity | Formula | In words |
|---|---|---|
| Precision | P = 1/σ² | flip the variance — trustworthiness |
| Weight on A | wA = PA/(PA+PB) | A's share of the total precision |
| Fused estimate | x̂ = wAxA + wBxB | precision-weighted average |
| Fused precision | Pfused = PA+PB | precisions add — always sharper |
| Kalman gain | K = P−/(P−+R) | the weight w, renamed |
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:
| Lessons | Arc | How this atom shows up |
|---|---|---|
| 1–3 | Foundations | the fusion problem; fusion architectures; combining two measurements (here) — the atom |
| 4–8 | Classical estimation | the 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–13 | Spatial fusion | occupancy grids; SLAM; visual-inertial odometry; multi-target tracking & data association; correlated estimates & covariance intersection (when independence breaks, Trap 2) |
| 14–18 | Robust & distributed | fault detection (the gating from Chapter 8, formalized); consensus over sensor networks; out-of-sequence measurements |
| 19–22 | Modern / learned | deep 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.
These existing lessons go deeper on the machinery we touched: