Hyoungseo Son
Probability & Information Theory
Contents · Probability & Information Theory

Part 0 · Expectation & Monte Carlo

Part 1 · Entropy & Divergence

Part 2 · Score-Function Gradient

Part 3 · Bayesian Estimation

  • Bayesian Inference and the Kalman Filter

Part 3 · Bayesian Estimation

Bayesian Inference and the Kalman Filter

A robot never sees its state. It sees noisy sensors and knows a rough model of how it moves. State estimation is the problem of turning that stream into a probability distribution over the hidden state xx, updated every time a new measurement arrives.

Recursive Bayesian estimation

Keep a belief p(xkz1:k)p(x_k \mid z_{1:k}), the posterior over the state given all measurements so far. Each step does two things. First predict: push the belief through the dynamics with the Chapman-Kolmogorov integral,

p(xkz1:k1)=p(xkxk1)p(xk1z1:k1)dxk1.p(x_k \mid z_{1:k-1}) = \int p(x_k \mid x_{k-1})\, p(x_{k-1} \mid z_{1:k-1})\, dx_{k-1}.

Then update: multiply the predicted belief (now the prior) by the likelihood of the new measurement and renormalize,

p(xkz1:k)    p(zkxk)likelihood  p(xkz1:k1)prior.p(x_k \mid z_{1:k}) \;\propto\; \underbrace{p(z_k \mid x_k)}_{\text{likelihood}}\; \underbrace{p(x_k \mid z_{1:k-1})}_{\text{prior}}.

That is Bayes' rule applied once per timestep. Posterior becomes the next prior, forever. The integral is intractable in general, but for one family it closes in a few matrix operations.1

The linear-Gaussian case is the Kalman filter

Assume linear dynamics and a linear measurement with Gaussian noise,

xk=Fxk1+w,wN(0,Q),zk=Hxk+v,vN(0,R).x_k = F x_{k-1} + w,\quad w \sim \mathcal{N}(0, Q), \qquad z_k = H x_k + v,\quad v \sim \mathcal{N}(0, R).

A Gaussian pushed through a linear map and multiplied by another Gaussian stays Gaussian, so the belief is fully described by its mean x^\hat{x} and covariance PP. Tracking those two through predict and update gives the Kalman filter.

Predict:

x^k=Fx^k1,Pk=FPk1F+Q.\hat{x}_k^- = F\,\hat{x}_{k-1}, \qquad P_k^- = F P_{k-1} F^\top + Q.

Update with innovation yky_k, innovation covariance SkS_k, and gain KkK_k:

yk=zkHx^k,Sk=HPkH+R,Kk=PkHSk1,y_k = z_k - H\hat{x}_k^-, \qquad S_k = H P_k^- H^\top + R, \qquad K_k = P_k^- H^\top S_k^{-1}, x^k=x^k+Kkyk,Pk=(IKkH)Pk.\hat{x}_k = \hat{x}_k^- + K_k\, y_k, \qquad P_k = (I - K_k H)\, P_k^-.

The gain KkK_k is the whole story. It is the ratio of what the model does not know, PkHP_k^- H^\top, to the total uncertainty, Sk=HPkH+RS_k = H P_k^- H^\top + R. When the sensor is noisy (RR large) the gain shrinks and the estimate leans on the model. When the model is uncertain (QQ large, so PkP_k^- large) the gain grows and the estimate leans on the measurement.2

A one-step worked example

Take the simplest case: a scalar constant position, F=H=1F = H = 1, no process noise. Start with prior mean x^=0\hat{x}^- = 0 and variance P=1P^- = 1, sensor variance R=1R = 1. A measurement z=10z = 10 arrives.

S=HPH+R=1+1=2,K=PHS1=12=0.5.S = H P^- H^\top + R = 1 + 1 = 2, \qquad K = P^- H^\top S^{-1} = \frac{1}{2} = 0.5. x^=0+0.5(100)=5,P=(10.5)1=0.5.\hat{x} = 0 + 0.5\,(10 - 0) = 5, \qquad P = (1 - 0.5)\cdot 1 = 0.5.

Equal trust in model and sensor puts the estimate exactly halfway, at 55, and halves the variance from 11 to 0.50.5 (σ\sigma from 11 to 0.7070.707). Two measurements with equal weight, one combined answer with less uncertainty than either alone.

Fusing a moving target

Now a 1D target with position and velocity, x=[p,v]x = [p, v]^\top, constant-velocity model F=[1Δt01]F = \begin{bmatrix} 1 & \Delta t \\ 0 & 1 \end{bmatrix}, measuring position only, H=[1  0]H = [1\ \ 0]. The true track below is a slow sinusoid, so the constant-velocity model is deliberately wrong at the turns and QQ has to absorb the mismatch. Drop RR and the estimate chases the noisy dots; raise it and the band widens as the filter smooths. Starve QQ and the filter grows overconfident and lags the curve; feed it and the estimate stays nimble.

Kalman filter tracking a noisy 1D targetinteractive
+1-1
true position
measurement z
estimate ± √P₀₀
gain K₀
1.000
σ = √P₀₀
1.000
True position (muted), noisy measurements (yellow dots), and the filter estimate (blue) with its ±√P₀₀ band. R sets sensor noise, q sets the constant-velocity model's process noise. Watch the gain K₀ rise toward 1 as the filter trusts measurements and fall toward 0 as it trusts the model.

This is the core of how a robot fuses an IMU, wheel odometry, and GPS into one physical state estimate: each sensor is a linear-Gaussian measurement, and the filter weighs every one by its variance. When the dynamics or measurements turn nonlinear, the same predict-update skeleton runs on a local linearization (the extended Kalman filter) or on sampled sigma points (the unscented filter), but the Bayesian recursion underneath does not change.1

Footnotes

  1. Thrun, Burgard, Fox, Probabilistic Robotics (2005). 2

  2. Kalman, A New Approach to Linear Filtering and Prediction Problems (1960).