Bayesian Filtering and Belief States › Worked Example: One Step by Hand

Michael BrenndoerferJune 8, 20263 min read
World Models HandbookAll chapters
Part 2 of 12Inference, Decisions, and Control
Chapter 8Bayesian Filtering and Belief States › Worked Example: One Step by Hand
Reading section 7 of 11 · Worked Example: One Step by Hand · 3 minSection 7 of 11 · 3 min

Book contents

Section 7 of 11 · 3 min read

Bayesian Filtering and Belief States › Worked Example: One Step by HandOne section · Sections in this chapter7 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Nothing builds trust in the recursion like computing one cycle with numbers small enough to check mentally. Consider a scalar system with identity transition and observation matrices, process variance Q=0.25Q = 0.25, and measurement variance R=1R = 1. Suppose our current belief is N(2.0, 1.0)\mathcal{N}(2.0,\, 1.0) and we receive the measurement o=3.0o = 3.0.

Predict. With A=1A = 1 and no input, the predicted belief is unchanged in mean and inflated in variance:

x^t∣t−1=2.0,Pt∣t−1=1.0+0.25=1.25.\hat{x}_{t|t-1} = 2.0, \qquad P_{t|t-1} = 1.0 + 0.25 = 1.25.

Correct. The gain blends the two sources of information:

K=1.251.25+1=1.252.25≈0.556.K = \frac{1.25}{1.25 + 1} = \frac{1.25}{2.25} \approx 0.556.

The posterior mean moves from 2.0 toward the measurement 3.0, covering about 56% of the gap:

x^t=2.0+0.556×(3.0−2.0)≈2.556,\hat{x}_t = 2.0 + 0.556 \times (3.0 - 2.0) \approx 2.556,

and the posterior variance contracts:

Pt=(1−0.556)×1.25≈0.556.P_t = (1 - 0.556) \times 1.25 \approx 0.556.

Notice the bookkeeping of information in this correction. Before the measurement the predicted belief carried 1/1.251/1.25 units of precision; the sensor contributed one more unit; the posterior variance 0.556=1/(1/1.25+1/1.0)0.556 = 1/(1/1.25 + 1/1.0) is the reciprocal of the summed precisions. Repeated conditionally independent readings add information, while each prediction step can add process uncertainty. Now let us scale this up to systems where hand computation fails.

Out[6]:
Visualization
Density curves of the predicted belief, measurement likelihood, and posterior for the scalar worked example.
The hand-computed scalar update from the worked example. The predicted belief N(2.0, 1.25) meets the likelihood of the measurement o = 3.0, and the corrected posterior N(2.556, 0.556) sits between them, closer to the more precise source.

The three vertical guides mark the predicted mean, the measurement, and the posterior mean. Because the predicted variance (1.25) slightly exceeds the measurement variance (1.0), the posterior lands just past the midpoint of the gap, at 56% of the way to the measurement, exactly as the hand computation predicts. The posterior curve is visibly taller and narrower than both inputs, the graphical signature of precision addition.