Evaluating Estimators, Fusion and Robots

Two filters track one drone with the same 0.50 m error. Filter A claims ±0.50 m. Filter B claims ±0.05 m, and the truth escapes its 95% band at most steps. RMSE calls it a tie.

Drag Filter B's claimed error. Watch the red escapes vanish as its claim grows honest. Then we build, piece by piece, the tools that grade an estimator: bias and variance, error over a run, NEES, NIS, the Cramér–Rao floor, campaigns, trajectory metrics and honest success rates.

You need the Kalman filter (what P is) and a confidence interval. We build the rest from zero.

Part of the Evaluation and Analytics family, after The Statistics of Evaluation. The consistency tests follow Bar-Shalom, Li and Kirubarajan (2001); the deep debugging companion is Sensor Fusion 21: Debugging and Consistency.

Catch the filter that lies

0.05 m

Illustrative: one 200-step flight; the lateral error is smooth random noise scaled so its RMSE is exactly 0.50 m. Both lanes show the same error. The purple band is ±1.96 times the claimed error, where 95% of an honest filter's errors fall.

Chapter 0

Two Filters, One Lie

See why an error number alone cannot pick the safe filter

You benchmark two Kalman filters on a week of drone flights. Both score a position RMSE (root mean square error, the typical distance from the truth) of 0.50 m. The table says tie. Which one do you ship?

A filter outputs two things. The estimate is where it thinks the drone is. The covariance P is its claim about how big its own error is. Filter A claims ±0.50 m. Filter B claims ±0.05 m. Same errors, but B claims ten times more certainty.

The claim drives other code. A planner keeps a margin of 3 claimed standard deviations around the drone, because 99.7% of honest errors fall inside it. A asks for 1.5 m. B asks for 0.15 m, while its real errors are 0.5 m.

Size the planner's margin

The teal curve is the drone's true lateral error, spread 0.5 m. The green zone is the margin the planner keeps. Drag the filter's claim.

0.05 m

Exact Gaussian arithmetic: true error spread 0.5 m, margin 3 times the claimed spread. The 3-sigma rule is a common choice, used here as an example.

Put one number on the lie. Both filters make an error of e = 0.5 m at some step. Divide its square by the variance each filter claims. For A: 0.25 / 0.25 = 1, one standard deviation, an ordinary error. For B: 0.25 / 0.0025 = 100, ten standard deviations. An honest filter makes a ten-sigma error with probability 1.5 × 10−23.

So an estimator has two separate grades. Accuracy is how far the estimate is from the truth. Consistency is whether the claimed covariance matches the real errors. A filter can pass one and fail the other.

FailureP against the real errorWhat breaks
Overconfidenttoo smallmargins shrink, gates reject good readings, the filter drifts while it reports all is well
Underconfidenttoo largewide gates admit clutter, the planner over-buffers, convergence is slow

The failure: shipping on RMSE alone. Symptom: tight, smooth tracks, then a crash on the first outlier. Measure: compare the claim with the errors (Chapters 3 and 4). Fix: demand a consistency number next to every RMSE.

The road

  1. Bias, variance and MSE: the three numbers of one estimator.
  2. Error over a run: RMSE, per axis, and the terminal trap.
  3. NEES: test the claim against the truth (the hero's red marks).
  4. NIS: test the claim with no truth, on the robot.
  5. The Cramér–Rao floor: how good any estimator could be.
  6. Monte Carlo campaigns: many runs, paired seeds.
  7. ATE and RPE: grade a whole trajectory.
  8. Honest success rates: Wilson intervals and SPL.
  9. The consistency lab: break a filter both ways.
  10. The field guide: numbers, code and links.
Two filters have the same RMSE. Filter B claims a covariance 100 times smaller than its real squared error. What breaks downstream?

Chapter 1

Bias, Variance and MSE

Split an estimator's error into a steady offset and a spread

You measure a battery voltage ten times. The true value is 5 V, and each reading has noise with a spread of 2 V. You turn the ten readings into one number. That rule is an estimator, and its output is an estimate.

Repeat the whole experiment many times and you get many estimates. Two things describe them. The bias is how far their average sits from the truth. The variance is how much they scatter around their own average.

Repeat the experiment 400 times

Each dot is the estimate from one experiment. The dashed line is the true 5 V. Pick an estimator; for the shrunk mean, drag the weight.

0.80

Illustrative: true value 5 V, reading noise 2 V, 10 readings. The shrunk mean is c times the mean plus (1 − c) times a prior guess of 4 V. The read-out uses the exact formulas; the dots are a seeded sample.

What single number grades an estimator? Call the true value θ (theta) and the estimate θ̂ (theta-hat). The mean squared error (MSE) is the average of the squared miss over many repeats. It splits into the two parts above.

Say it aloud

The MSE of theta-hat equals the bias of theta-hat squared, plus the variance of theta-hat.

MSE(θ̂)
M-S-E of theta-hat the average of (theta-hat minus theta) squared over many repeats, in V².
Bias(θ̂)2
bias squared the average estimate minus the true theta, then squared. A steady offset.
Var(θ̂)
variance of theta-hat the average squared distance of each estimate from the average estimate. The scatter.
In plain words

Find the average estimate. Its distance from theta is the bias; square it. Add the scatter of the estimates around their average. The sum is the MSE.

With numbers

With made-up numbers: the mean of 10 readings has bias 0 and variance 2²/10 = 0.4, so MSE 0.4 V². The shrunk mean with c = 0.8 toward a guess of 4 V has bias 0.2 × (4 − 5) = −0.2 and variance 0.8² × 0.4 = 0.256. MSE = 0.04 + 0.256 = 0.296 V².

The shrunk mean is biased, yet it wins: 0.296 against 0.4. It trades a small offset for less scatter. The trade only pays while the prior guess is close. With a guess of 1 V, the same estimator scores 0.896.

EstimatorBias (V)Variance (V²)MSE (V²)
Mean of 1000.4000.400
Mean of first 500.8000.800
Shrunk, c = 0.8, guess 4 V−0.2000.2560.296
Shrunk, c = 0.8, guess 1 V−0.8000.2560.896

The failure: grading by one lucky run. Symptom: an estimator wins on Tuesday and loses on Wednesday. Measure: repeat the experiment and compute bias and variance separately. Fix: report both, so a reader sees which part to attack.

An estimator has bias −0.2 V and variance 0.256 V². What is its MSE?

Chapter 2

Error Over a Run

Turn an error that changes every step into numbers that keep its story

Your car's release note says "RMSE: 0.41 m." A safety reviewer asks: sideways or along the road? Steady, or spiking in turns? One number answers neither.

A filter's error changes every step. Call the true position minus the estimate at step t the error et, and the number of steps T. RMSE squares each error, averages, and takes the square root.

Say it aloud

RMSE equals the square root of one over T, times the sum over t of e-t squared.

RMSE
R-M-S-E root mean square error, in metres.
1/T
one over T divide by the number of steps T, which makes a mean.
Σt
the sum over t add one term for each step of the run.
et2
e-t squared the error at step t, squared. For a 2-D position, the squared distance.
In plain words

Square the error e-t at every step. Add the squares and divide by T. Take the square root. Squaring makes one big miss count more than many small ones.

With numbers

With made-up numbers, five steps: x errors 0.3, −0.4, 0.5, 0.2, −0.1 m and y errors 0.1, 0.2, −0.3, 0.4, 0 m. Squared distances 0.10, 0.20, 0.34, 0.20, 0.01 sum to 0.85. RMSE = √(0.85/5) = √0.17 = 0.412 m.

Slice it. RMSE in x alone is √0.11 = 0.332 m, in y √0.06 = 0.245 m, and 0.11 + 0.06 = 0.17. For a car, 0.4 m along the road is a small stop error; 0.4 m sideways is a lane departure. Never add metres and radians into one score.

Now the trap. The last step's error is √(0.1² + 0²) = 0.1 m. A report that quotes only the terminal error claims 0.1 m. The run's RMSE is 0.412 m, 4.1 times worse, and the worst step, 0.583 m at step 3, vanishes.

Read the error's shape

The teal curve is the error at each step. The lines are three summaries of it. Pick a failure and see which summary goes blind.

Illustrative error curves, 300 steps. The shapes match common causes: drift from a slow bias, spikes from model mismatch in turns, a loop closure that snaps the estimate back at the end.

Across runs the same care applies. Ten missions score 0.30, 0.32, 0.28, 0.35, 0.31, 0.29, 0.33, 0.30, 0.34 and 4.10 m. The mean is 0.692 m; the median is 0.315 m. The mean blames every run; the median hides the crash. The honest line is: median 0.315 m, mean 0.692 m, max 4.10 m, 1 failure in 10.

The failure: one scalar for a safety system. Symptom: a good number and an angry reviewer. Measure: plot the error over time, per axis. Fix: report RMSE per axis, the max, the curve, and the failure count. Summarizing Distributions builds the box plot and the ECDF for those ten runs.

A run reports terminal error 0.1 m but RMSE 0.41 m. What most likely happened?

Chapter 3

NEES: Test the Claim Against the Truth

Measure each error in units of the covariance the filter claims

Chapter 0 divided one squared error by one claimed variance. Now do it for a whole state, with correlations, and get a test with a known answer.

Call the true state minus the estimate the error vector e. Call the filter's claimed covariance P. The normalized estimation error squared (NEES), written η (eta), measures e in units of P.

Say it aloud

Eta equals e-transpose times P-inverse times e.

η
eta the NEES at one step: one number, no unit.
eT
e-transpose the error laid on its side, so the product is one number.
P−1
P-inverse divide by the claimed covariance in every direction, correlations included.
e
e the true state minus the estimate, n numbers. It needs the truth.
In plain words

Measure the error e in units of the claimed spread P, in every direction, and square it. In one dimension, eta is e squared over the claimed variance.

With numbers

With made-up numbers: e = (0.3, −0.4) m and P = diag(0.09, 0.04) m². η = 0.09/0.09 + 0.16/0.04 = 1 + 4 = 5.0.

If the filter is honest, η is the sum of n squared standard normal numbers. That is a chi-square distribution with n degrees of freedom, and its average is n. A 2-D position filter averages NEES 2.

Correlation matters. Claim P = [[0.09, 0.02], [0.02, 0.04]], which says x and y errors move together. Its determinant is 0.0032, so P−1 = [[12.5, −6.25], [−6.25, 28.125]]. The same error, with opposite signs, now scores η = 7.125, not 5.0.

Probe the claimed ellipse

Teal dots are real errors from 200 runs. Purple rings are the claimed 1, 2 and 3 sigma ellipses. The bar is the average NEES of 50 runs against its green band.

×0.50
0.00

Illustrative: true error spreads 0.3 m in x and 0.2 m in y. Expected NEES is the trace of P−1 times the true covariance. Red dots have NEES above 7.38.

One sample is weak evidence: for n = 2, 95% of honest values fall between 0.051 and 7.38. Average N runs instead. The sum is chi-square with N·n degrees of freedom, so the band for the average is the chi-square points divided by N. For 50 runs and n = 2, it is 1.484 to 2.591.

Average NEESVerdictUsual cause
above the bandoverconfidentQ or R too small, or a bias
inside the bandconsistenterrors match P
below the bandunderconfidentQ or R too large

The failure: an alarm on one sample. Symptom: a team "fixes" a healthy filter after one NEES of 8. Measure: the average over runs, against the band for that N. Fix: act only on a persistent average outside the band. NEES needs the true state, so it runs in simulation or against motion capture.

A 2-state filter's average NEES over 50 runs is 0.9. The band is 1.48 to 2.59. What is the verdict?

Chapter 4

NIS: Test the Claim With No Truth

Grade each reading's surprise against the filter's own forecast

Your robot runs in a customer's warehouse. There is no motion capture, so NEES is off the table. But before each reading arrives, the filter forecasts it. Reality grades that forecast many times a second.

The innovation ν (nu) is the reading minus the forecast reading. The filter also forecasts how big ν should be: the innovation covariance S, its state doubt pushed into reading units plus the sensor noise. The normalized innovation squared (NIS), written ε (epsilon), measures ν in units of S.

Say it aloud

Epsilon equals nu-transpose times S-inverse times nu.

ε
epsilon the NIS of one reading, no unit.
νT
nu-transpose the innovation laid on its side.
S−1
S-inverse divide by the forecast spread of the innovation.
ν
nu the reading minus the forecast reading, m numbers.
In plain words

Take the surprise nu in this reading. Measure it in units of the spread S the filter forecast for it, and square it. Every input is already inside the filter.

With numbers

With made-up numbers: ν = (1.2, −0.8) and S = [[4, 1], [1, 2]]. det S = 7, so S−1ν = (3.2/7, −4.4/7) = (0.457, −0.629). ε = 1.2 × 0.457 + 0.8 × 0.629 = 1.051.

If the filter is honest, ε is chi-square with m degrees of freedom, where m is the size of one reading, not the state. A 6-state filter with 2-D position readings has NEES 6 and NIS 2. Copying the wrong one is a classic bug.

The same number is the validation gate: skip a reading whose NIS exceeds the 99% point, 9.21 for m = 2. Now watch an overconfident filter. The true S is 4, but the filter thinks 0.25. An ordinary ν = 2 has true NIS 4/4 = 1, but the filter computes 4/0.25 = 16, past its 1-D gate of 6.63. It throws the good reading away, drifts, and throws the next one away too.

Monitor a robot's filter

Pink dots are NIS per reading. The line is the mean of the last K. A fault starts at reading 200. Pick a fault, then drag K.

50

Illustrative: 1-D readings, honest innovations drawn with S = 1. Bias adds one standard deviation; R doubles makes the true spread 1.6; the broken model makes the innovations larger and correlated. The band is the 95% chi-square band for the mean of K values.

The window is a trade. For K = 100 and m = 2 the band is 1.627 to 2.411; a short window reacts fast but false-alarms more. NIS also has a blind spot. A state no sensor sees, such as yaw with position-only readings, can drift while every innovation looks perfect.

The failure: trusting NIS alone. Symptom: the monitor stays green while the map warps. Measure: NEES in simulation for the whole state. Fix: NEES on the bench, NIS on the robot. Sensor Fusion 21 adds the whiteness test and a tuning runbook.

Why can a deployed robot compute NIS but not NEES?

Chapter 5

The Cramér–Rao Floor

Compute the best variance any unbiased estimator can reach

You tuned Q and R for three days, and the variance stopped falling. Is the tuning bad, or is there no more to get from these sensors? The data hold a fixed amount of information, and you can count it.

Fisher information measures how sharply the likelihood peaks around the true value. A sharp peak pins the value down; a flat one cannot. For a constant a measured N times with Gaussian noise of spread σ (sigma), each reading adds 1/σ² of information. Independent readings add, so the total is I = N/σ².

Say it aloud

The variance of a-hat is at least one over I, where I equals N over sigma squared.

Var(â)
variance of a-hat the scatter of any unbiased estimate of a, in V².
1/I
one over I the Cramér–Rao lower bound (CRLB), the floor.
I
I the Fisher information in all the readings.
N
N the number of independent readings.
σ2
sigma squared the noise variance of one reading.
In plain words

Each reading carries one over sigma squared of information. Add it over the N readings to get I. No unbiased estimator scatters less than one over I.

With numbers

With made-up numbers: N = 25, σ = 2 V. I = 25/4 = 6.25, so the floor is 1/6.25 = 0.16 V², a spread of √0.16 = 0.4 V.

An estimator's efficiency is the floor divided by its variance. The mean of all 25 has variance 4/25 = 0.16: efficiency 1.0, it uses every bit. The mean of the first 10 has variance 0.4: efficiency 0.4. The median of Gaussian data reaches about 2/π = 0.64 as N grows.

Race three estimators to the floor

The yellow line is the floor σ²/N. Teal is the mean, warm the first 10, blue the median. Drag N and σ.

25
2.0 V

Exact for the two means. The median curve uses the large-N formula πσ²/(2N); a seeded simulation gives efficiency 0.65 at N = 25 and 0.72 at N = 10.

Use it to decide between work and money. If your filter's Monte Carlo variance is 0.4 against a floor of 0.16, the gap is the algorithm's. If it is 0.17, stop tuning: only better sensors lower the floor. Halving σ cuts it to 0.04.

Sensors must be independent to add. Two receivers with σ = 2 each give variance 2.0, so the spread falls from 2.0 to 1.41, a 29% gain, not 50%. If their errors correlate at 0.8, the best mix has variance 4 × 1.8/2 = 3.6: a 5% gain. Diversity adds information; duplicates do not.

The failure: tuning against a wall. Symptom: weeks of tuning, no gain. Measure: plot Monte Carlo variance against the floor. Fix: stop when the gap is small. For a linear model with Gaussian noise, the Kalman filter's P equals the bound; for a nonlinear filter, the gap measures what linearization costs (see the EKF).

The requirement is a spread below 0.3 m. The Cramér–Rao floor for your sensors is 0.4 m. What follows?

Chapter 6

Monte Carlo Campaigns

Run many seeded trials and pair them to see a small difference

Your new filter beat the old one on one run: 0.45 m against 0.50 m. You change the noise seed, and it loses. One run of a random system is an anecdote.

A Monte Carlo campaign runs M trials. Fix the scenario. Randomize what nature randomizes: noise seeds, start errors, gusts. Log the full error and covariance traces, not only summaries.

How sure is the campaign's number? Fifty runs give a mean squared error of 0.25 m² with a spread of 0.10 m² across runs. The standard error is 0.10/√50 = 0.0141. The 95% interval is 0.222 to 0.278 m², so RMSE is 0.471 to 0.527 m. The one-run gap of 0.05 m sits inside that noise. Halving the interval costs 4 times the runs.

The campaign also checks the claim, axis by axis. At one time, the errors across runs have variance 0.36 m² in x while P claims 0.09. The ratio is 4, so the real spread is √4 = 2 times the claimed one on that axis.

Now compare two filters. Call filter A's error on one run A, filter B's B, and their difference D = A − B. If both filters see the same seed, a hard gust hurts both, so A and B rise together.

Say it aloud

The variance of D equals the variance of A plus the variance of B, minus two times the covariance of A and B.

Var(D)
variance of D how much the difference A minus B scatters from run to run.
Var(A)
variance of A the run-to-run scatter of filter A's RMSE.
Var(B)
variance of B the same for filter B.
2 Cov(A, B)
two covariance of A and B how much A and B move together. It is zero if the runs use different seeds.
In plain words

Add the scatter of A and the scatter of B. If both filters share each seed, subtract twice their shared movement. The shared luck cancels in the difference D.

With numbers

With made-up numbers: Var(A) = Var(B) = 0.01 and correlation 0.9, so Cov = 0.009. Unpaired: Var(D) = 0.02. Paired: 0.02 − 0.018 = 0.002, ten times smaller, so about ten times fewer runs.

Build a campaign

Each dot is one run's difference A − B in RMSE. The band is the 95% interval on the mean difference. Add runs, then switch pairing.

Illustrative: each filter's RMSE has run-to-run variance 0.01 m²; a shared seed gives correlation 0.9; B is truly 0.03 m better. Seeded draws.

The failure: more runs of one scenario. Symptom: 10,000 runs of a straight line, then a crash in a turn. Measure: list the scenario families the campaign covers. Fix: spread runs across families first, then pair seeds within each. Never draw start errors from the filter's own P: that assumes the consistency you test.

Filter A scores 0.45 m and filter B 0.50 m, each from one run with a different seed. The 50-run interval on RMSE is about ±0.03 m. What do you conclude?

Chapter 7

ATE and RPE: Grade a Trajectory

Separate global drift from local jitter in a SLAM or odometry run

Two mapping robots drive one warehouse loop. Robot 1's path is jagged but ends where it started. Robot 2's path is smooth but ends 2 m off. Which is better? They fail in different metrics.

A SLAM estimate lives in its own frame, with its own origin. So trajectory metrics start with alignment: find one rotation and translation that best lays the estimate on the truth (the Umeyama method, from an SVD). Any error that one global move can explain is forgiven.

The absolute trajectory error (ATE) is the RMSE of Chapter 2 over the aligned positions. It sees global shape: drift, warp, a failed loop closure. The relative pose error (RPE) compares motions instead. Call the estimated position at step t p̂t, the true one pt, and the step gap Δ (delta).

Say it aloud

RPE equals the square root of the mean over t of the squared length of: p-hat at t plus delta minus p-hat at t, minus p at t plus delta minus p at t.

RPE
R-P-E relative pose error, in metres per gap of Δ steps.
meant
the mean over t average over every start step that has a step t plus delta.
p̂t+Δ − p̂t
p-hat at t plus delta minus p-hat at t the motion the estimate made over the gap.
pt+Δ − pt
p at t plus delta minus p at t the true motion over the gap.
In plain words

For each step t, take the estimated motion over delta steps and subtract the true motion. Square the length of the miss, average, and take the root. A global offset cancels, so RPE needs no alignment.

With numbers

With made-up numbers: truth (0,0), (1,0) … (4,0); a zigzag estimate with y = 0, 0.2, −0.2, 0.2, −0.2; Δ = 1. Motion misses in y: 0.2, −0.4, 0.4, −0.4. RPE = √(0.52/4) = 0.361 m.

Now a drift estimate on the same truth: y = 0, 0.1, 0.2, 0.3, 0.4. Anchor both estimates at the first pose and compare.

EstimateATE, first-pose anchorRPE, Δ = 1ATE, full alignment
Zigzag0.179 m0.361 m0.170 m
Drift0.245 m0.100 m0.007 m

Rank by ATE and the jittery estimate wins; rank by RPE and the drifting one wins. Report both. The last column shows a protocol trap: this drift is a 5.7° heading error, one global rotation, so full alignment forgives almost all of it. The terminal error is 0.4 m over 4 m, a drift rate of 10% of distance; real visual-inertial odometry is far smaller.

X-ray a trajectory

The dashed grey loop is the truth; teal is the estimate. Pick a failure and its size. Align it and see what alignment forgives.

0.50

Illustrative 2-D loop of 80 poses, 1 m apart. Drift is a small heading error added at every step; zigzag is alternating sideways noise. Alignment is a least-squares rotation and translation, no scale.

The failure: a number without its protocol. Symptom: one paper aligns with scale (Sim(3)) and another without (SE(3)). Measure: read the alignment, the pose set and Δ. Fix: pin them in a shared tool such as evo. For the mapping side see Classical SLAM and Modern SLAM.

A monocular SLAM paper aligns with a fitted scale (Sim(3)). A stereo rival aligns without scale (SE(3)). Why is the ATE comparison unfair?

Chapter 8

Honest Success Rates

Put an interval on a small number of robot trials, and weight success by path

A paper says "85% success" from 20 trials. Another says "75%" from 200. Which robot is better? With these numbers, you cannot tell.

Real trials cost setup time and hardware, so 10 to 50 trials is common. A robot that truly succeeds 75% of the time, run 20 times, gives 11 to 18 successes in 95% of campaigns: 55% to 90%. The textbook interval p ± 1.96√(p(1−p)/n) fails here: at 20 of 20 it says 100% to 100%.

The Wilson score interval stays inside 0 to 1 and covers well at small n. Call the observed rate p̂ (p-hat), the trial count n, and the normal point for 95% z = 1.96.

Say it aloud

The center is p-hat plus z squared over 2 n, all over 1 plus z squared over n. The half-width is z times the root of p-hat times 1 minus p-hat over n, plus z squared over 4 n squared, all over the same 1 plus z squared over n.

center
the center the middle of the interval, pulled from p-hat toward 50%.
p̂
p-hat successes divided by trials.
z2
z squared 1.96 squared, 3.8416, for a 95% interval.
n
n the number of trials.
half-width
the half-width how far the interval reaches each side of the center.
In plain words

Pull p-hat toward one half by an amount that grows as n shrinks. That is the center. Add and subtract the half-width, which also grows as n shrinks.

With numbers

17 of 20: p̂ = 0.85, z²/n = 0.192. Center = 0.946/1.192 = 0.794. Half-width = 1.96 × √0.008776 / 1.192 = 0.154. Interval: 64.0% to 94.8%, thirty points wide.

The interval leans down: 21 points below 85%, 10 above. The 75% robot at 150 of 200 gives 68.6% to 80.5%, inside the first interval. The data cannot rank them.

Run honest trials

Green ticks succeed, red crosses fail. The bar is the observed rate with its Wilson interval. Run trials, then try paper mode.

hidden

Illustrative seeded trials. Paper mode reruns batches of 20 until one reaches 90% or more, the winner's curse; for a true 75% robot, the best of 5 batches does that 38% of the time.

Success alone rewards a robot that wanders until it arrives. SPL (success weighted by path length) counts each success as shortest path over the longer of shortest and actual path. Five episodes, (shortest, actual) = (10, 12), (8, 8), a failure, (5, 20), a failure: (0.833 + 1 + 0 + 0.25 + 0)/5 = 0.417. Success says 60%; SPL says 41.7%.

The failure: the winner's curse. Symptom: a checkpoint chosen on the same trials it reports, which then does worse. Measure: count how many batches or checkpoints you tried. Fix: choose on one set and report on a held-out set.

Robot A: 17 of 20. Robot B: 150 of 200. What can you conclude?

Chapter 9

The Consistency Lab

Mistune a filter in both directions and watch NEES and NIS catch it

Here every test runs on one filter. A Kalman filter tracks a target that moves along a line and sometimes speeds up. The world has a true sensor noise Rtrue and a true motion noise Qtrue. The filter is told Rf and Qf. Consistency asks what happens when they differ.

First, the arithmetic of one update. The filter's prior variance is P−. It thinks the sensor variance is Rf, so it sets the gain K = P−/(P− + Rf) and claims a variance of (1 − K)P−. But the reading's real variance is Rtrue. The real error variance after the update is:

Say it aloud

Sigma squared actual equals one minus K, squared, times P-minus, plus K squared times R-true.

σ2actual
sigma squared actual the real variance of the error after the update.
(1 − K)2
one minus K, squared how much of the prior error survives, squared.
P−
P-minus the prior variance, before the reading.
K2
K squared the gain squared. K comes from the told R-f, not the true one.
Rtrue
R-true the reading's real noise variance.
In plain words

The update keeps a share of the old error and adds a share of the reading's noise. Square each share and weight it by its real variance. Compare the sum with the filter's claim, one minus K times P-minus.

With numbers

With made-up numbers: P− = 1, Rf = 1, Rtrue = 4. K = 0.5. Claim: 0.5. Actual: 0.25 × 1 + 0.25 × 4 = 1.25. Expected NEES = 1.25/0.5 = 2.5, against an honest 1.

One step at 2.5 is inside the 1-D band, 0.001 to 5.02. The 50-run average band is 0.647 to 1.428, and 2.5 is far above it. Told the truth, Rf = 4, the gain is 0.2 and the actual variance is 0.64 + 0.16 = 0.80. The honest filter claims more doubt and has less error: the lie also broke the fusion.

Break the filter both ways

Top: the estimate's error with its claimed band. Below: windowed NEES (purple) and NIS (pink) against green bands. Load a preset or drag the dials.

×1
×1

Illustrative: a constant-velocity filter (position and velocity, so NEES has 2 degrees of freedom; NIS has 1), 400 steps, sensor error 2 m, with two speed-ups. Bands are for the mean of the last 50 steps. Hide truth blanks NEES, as on a deployed robot.

PresetWhat the dials sayWhat the lanes show
OverconfidentR told ÷4both above the band; RMSE barely moves
UnderconfidentR told ×4both below the band; RMSE rises, because the wrong gain wastes readings
Q too smallQ told ÷100P collapses; NEES and NIS shoot far above the band, and RMSE more than triples
CompensatingQ and R both ×4same gain and same RMSE, but NEES and NIS fall to a quarter

The last row is the trap. The gain depends on Q and R only through their balance, so scaling both leaves the estimates and the RMSE unchanged. Only the consistency tests see the absolute scale, and the absolute scale is what every consumer of P reads.

The failure: tuning Q and R to minimize RMSE. Symptom: a great RMSE and a P off by any factor. Measure: windowed NIS on logs, NEES in simulation. Fix: fix bias first, set the Q to R balance, then scale both until NIS sits in its band, and gate it in CI with regression testing.

You double both the told Q and the told R. RMSE stays the same but the average NEES halves. Why?

Chapter 10

The Field Guide

Keep the tests, their numbers and the core code on one page

An estimator makes a claim, and you grade it twice: how far it is from the truth, and whether its claim matches its errors. Grade accuracy per axis and over time. Test the claim with NEES on the bench and NIS on the robot. Compare against the floor. Run campaigns with paired seeds. Report trajectories with ATE and RPE, and trials with intervals.

The numbers

ToolEquationWorked numbers
MSEBias² + Var0.04 + 0.256 = 0.296 V²
RMSE√(1/T · Σ et²)√(0.85/5) = 0.412 m
NEESη = eTP−1e, honest mean n5.0 diagonal, 7.125 correlated
Band, average of Nχ² points of N·n, over Nn 2, N 50: 1.484 to 2.591
NISε = νTS−1ν, honest mean m1.051; gate 9.21 at m 2
CRLBVar ≥ 1/I, I = N/σ²N 25, σ 2: 0.16 V²
Paired differenceVar A + Var B − 2 Cov0.02 to 0.002
RPERMSE of motion misseszigzag 0.361 m, drift 0.100 m
Wilsoncenter ± half-width17 of 20: 64.0% to 94.8%
SPLmean of success × shortest/max(shortest, actual)0.417 vs success 60%
Mistuned update(1−K)²P− + K²Rtrue1.25 actual vs 0.5 claimed

The terms

TermMeaning
BiasThe average estimate minus the truth.
ConsistentErrors average zero and their spread matches the claimed P.
NEESThe true error squared in units of P; needs the truth.
NISThe innovation squared in units of S; needs no truth.
EfficiencyThe Cramér–Rao floor divided by the estimator's variance.
ATERMSE of aligned positions: global shape.
RPERMSE of motion over a gap: local accuracy.
SPLSuccess weighted by path efficiency.

The checklist

  1. Report RMSE per axis and per state block, with the max and the error curve.
  2. Next to every RMSE, report a consistency number: average NEES or NIS with its band.
  3. Compute the band from your own N and degrees of freedom.
  4. Plot Monte Carlo variance against the Cramér–Rao floor before more tuning.
  5. Pair seeds; cover scenario families before adding runs.
  6. For trajectories, report ATE and RPE and state the alignment.
  7. For trials, report the Wilson interval, and select on a separate set.

The core as code

pythonimport numpy as np
from scipy.stats import chi2

def nees(e, P):  return float(e @ np.linalg.solve(P, e))   # solve is stabler than inv
def nis(nu, S):  return float(nu @ np.linalg.solve(S, nu))

def band(dof, N, conf=0.95):                 # band for the mean of N values
    a = (1 - conf) / 2
    return chi2.ppf(a, N * dof) / N, chi2.ppf(1 - a, N * dof) / N

def rmse(err):  return np.sqrt((err ** 2).sum(axis=-1).mean())   # err: (T, d)

def rpe(gt, est, d=1):                         # positions (T, 2)
    return rmse((est[d:] - est[:-d]) - (gt[d:] - gt[:-d]))

def wilson(k, n, z=1.959964):
    p = k / n; den = 1 + z * z / n
    c = (p + z * z / (2 * n)) / den
    h = z * np.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / den
    return c - h, c + h

band(2, 50)        # (1.484, 2.591)
wilson(17, 20)    # (0.640, 0.948)

Keep going

The takeaway. Before you ship an estimator, write three things: what it claims (P), what it achieves (its errors), and who reads the claim (gates, planners, people).
Which question carries over to any system that reports uncertainty, from a VIO filter to a depth network with predicted variance?

Now press Present or Teach and explain, from memory, why two filters with one RMSE can differ in safety, and how NEES and NIS catch the liar. Then go back to the hero and drag Filter B's claim until its red marks stop.

Sources

  1. Y. Bar-Shalom, X.-R. Li and T. Kirubarajan, Estimation with Applications to Tracking and Navigation, Wiley, 2001: NEES, NIS and the chi-square tests. Wiley
  2. H. Cramér, Mathematical Methods of Statistics, 1946, and C. R. Rao, "Information and the accuracy attainable in the estimation of statistical parameters," 1945: the lower bound.
  3. S. Umeyama, "Least-squares estimation of transformation parameters between two point patterns," IEEE TPAMI 13(4), 1991. doi
  4. J. Sturm, N. Engelhard, F. Endres, W. Burgard and D. Cremers, "A Benchmark for the Evaluation of RGB-D SLAM Systems," IROS 2012: ATE and RPE.
  5. E. B. Wilson, "Probable inference, the law of succession, and statistical inference," JASA 22, 1927.
  6. P. Anderson et al., "On Evaluation of Embodied Navigation Agents," 2018: SPL. arXiv
Evaluating Estimators, Fusion and Robots
The Statistics of Evaluation · Debugging and Consistency · Back to Gleams