3.5.25Guidance, Navigation & Control (GNC)

Unscented Kalman Filter (UKF) — sigma points, better for nonlinear

2,095 words10 min readdifficulty · medium2 backlinks

WHY does the UKF exist?

The engine behind this is the Unscented Transform (UT).


The Unscented Transform (derivation from scratch)

WHAT we want: a discrete set of weighted points {Xi,Wi}\{\mathcal{X}_i, W_i\} that reproduce the mean and covariance of xx exactly, so that after transforming them we get a good estimate of yy's statistics.

HOW we build the sigma points — first principles.

We need points whose weighted mean equals xˉ\bar x and whose weighted spread equals PP: iWiXi=xˉ,iWi(Xixˉ)(Xixˉ)=P.\sum_i W_i \,\mathcal{X}_i = \bar x, \qquad \sum_i W_i (\mathcal{X}_i-\bar x)(\mathcal{X}_i-\bar x)^\top = P.

Why this constraint? Because if the point cloud has the correct mean and covariance, its low-order statistics match a Gaussian to second order — and matching two moments is exactly what a Kalman filter cares about.

To spread points along the "shape" of PP, we need its matrix square root SS where SS=PSS^\top = P. We use P\sqrt{P} (usually the Cholesky factor). We place:

X0=xˉXi=xˉ+((n+λ)P)i,i=1,,nXi+n=xˉ((n+λ)P)i,i=1,,n\boxed{ \begin{aligned} \mathcal{X}_0 &= \bar x \\ \mathcal{X}_i &= \bar x + \left(\sqrt{(n+\lambda)P}\right)_i, & i=1,\dots,n\\ \mathcal{X}_{i+n} &= \bar x - \left(\sqrt{(n+\lambda)P}\right)_i, & i=1,\dots,n \end{aligned}}

So we get ==2n+1====2n+1== sigma points: one at the center, and one on each side along every principal axis of PP. The factor (n+λ)(n+\lambda) scales how far out the points sit.

HOW we choose the weights. We need two moment conditions (mean, covariance), so we allow two weight sets:

W0(m)=λn+λ,W0(c)=λn+λ+(1α2+β)W_0^{(m)} = \frac{\lambda}{n+\lambda}, \qquad W_0^{(c)} = \frac{\lambda}{n+\lambda} + (1-\alpha^2+\beta) Wi(m)=Wi(c)=12(n+λ),i=1,,2nW_i^{(m)} = W_i^{(c)} = \frac{1}{2(n+\lambda)}, \quad i=1,\dots,2n

Why two weight sets? The mean weight W(m)W^{(m)} and covariance weight W(c)W^{(c)} differ only at the center point, so we can inject the Gaussian-tuning term (1α2+β)(1-\alpha^2+\beta) into the covariance without disturbing the mean. Clever bookkeeping, nothing more.

Why do the outer weights sum correctly? Check: W0(m)+i=12nWi(m)=λn+λ+2n12(n+λ)=λ+nn+λ=1.W_0^{(m)}+\sum_{i=1}^{2n}W_i^{(m)} = \frac{\lambda}{n+\lambda} + 2n\cdot\frac{1}{2(n+\lambda)} = \frac{\lambda + n}{n+\lambda}=1. ✔ (unbiased mean).

Push through the nonlinearity, then recover statistics:

Yi=f(Xi)\mathcal{Y}_i = f(\mathcal{X}_i) yˉ=i=02nWi(m)Yi,Py=i=02nWi(c)(Yiyˉ)(Yiyˉ)\bar y = \sum_{i=0}^{2n} W_i^{(m)}\,\mathcal{Y}_i, \qquad P_y = \sum_{i=0}^{2n} W_i^{(c)}\,(\mathcal{Y}_i-\bar y)(\mathcal{Y}_i-\bar y)^\top

This captures the mean and covariance accurate to 3rd order for Gaussian inputs (vs. 1st order for the EKF). That is the whole payoff.

Figure — Unscented Kalman Filter (UKF) — sigma points, better for nonlinear

The full UKF cycle

Given nonlinear dynamics xk=f(xk1)+wx_k = f(x_{k-1}) + w (process noise cov QQ) and measurement zk=h(xk)+vz_k = h(x_k) + v (noise cov RR):

1. Predict — generate sigma points from (x^k1,Pk1)(\hat x_{k-1}, P_{k-1}), propagate through ff:

Xi=f(Xi),x^k=iWi(m)Xi,Pk=iWi(c)(Xix^k)()+Q\mathcal{X}^-_i = f(\mathcal{X}_i),\quad \hat x_k^- = \sum_i W_i^{(m)}\mathcal{X}^-_i,\quad P_k^- = \sum_i W_i^{(c)}(\mathcal{X}^-_i-\hat x_k^-)(\cdots)^\top + Q

2. Measurement update — push predicted sigma points through hh:

Zi=h(Xi),z^k=iWi(m)Zi\mathcal{Z}_i = h(\mathcal{X}^-_i),\quad \hat z_k = \sum_i W_i^{(m)}\mathcal{Z}_i Pzz=iWi(c)(Ziz^k)()+R,Pxz=iWi(c)(Xix^k)(Ziz^k)P_{zz} = \sum_i W_i^{(c)}(\mathcal{Z}_i-\hat z_k)(\cdots)^\top + R,\quad P_{xz} = \sum_i W_i^{(c)}(\mathcal{X}^-_i-\hat x_k^-)(\mathcal{Z}_i-\hat z_k)^\top

3. Kalman gain & correction:

K=PxzPzz1,x^k=x^k+K(zkz^k),Pk=PkKPzzKK = P_{xz}P_{zz}^{-1},\quad \hat x_k = \hat x_k^- + K(z_k-\hat z_k),\quad P_k = P_k^- - K P_{zz} K^\top

Worked Examples


Common Mistakes (Steel-manned)


Active Recall

Recall Test yourself before revealing
  • How many sigma points for an nn-dim state? Why 2n+12n+1?
  • What two statistics must the sigma set reproduce exactly?
  • Where does the Gaussian-tuning β=2\beta=2 enter?
  • Why does the UKF beat the EKF for y=x2y=x^2 at x=0x=0?
  • What replaces the Jacobian HH in the gain?
Why does the UKF avoid Jacobians?
It propagates deterministic sigma points through the true nonlinear function and estimates statistics from them, so no linearization/derivative is needed.
How many sigma points for an n-dimensional state?
2n+12n+1 — one center point plus two per dimension (±) along the principal axes of PP.
What two moment conditions define the sigma points?
Their weighted mean equals xˉ\bar x and their weighted covariance equals PP exactly.
Give the sigma point formula.
X0=xˉ\mathcal{X}_0=\bar x, Xi=xˉ±((n+λ)P)i\mathcal{X}_i=\bar x\pm(\sqrt{(n+\lambda)P})_i, with λ=α2(n+κ)n\lambda=\alpha^2(n+\kappa)-n.
What is the mean weight W0(m)W_0^{(m)}?
W0(m)=λ/(n+λ)W_0^{(m)}=\lambda/(n+\lambda); the rest are 1/[2(n+λ)]1/[2(n+\lambda)].
How does W0(c)W_0^{(c)} differ from W0(m)W_0^{(m)}?
W0(c)=W0(m)+(1α2+β)W_0^{(c)}=W_0^{(m)}+(1-\alpha^2+\beta); only the center covariance weight carries the Gaussian tuning term.
What is β\beta and its optimal Gaussian value?
A parameter encoding prior distribution knowledge; β=2\beta=2 is optimal for Gaussian priors.
What replaces the linear Kalman gain's PHPH^\top?
The sigma-point cross-covariance PxzP_{xz}; gain K=PxzPzz1K=P_{xz}P_{zz}^{-1}.
To what order is the UT accurate for Gaussians vs the EKF?
UT: 3rd order; EKF: 1st order.
For xN(0,σ2)x\sim N(0,\sigma^2) and y=x2y=x^2, what mean does UKF give?
Exactly σ2\sigma^2 (EKF wrongly gives 0 because the Jacobian is 0 at the origin).
Where are QQ and RR added in the additive UKF?
QQ into predicted covariance PkP_k^-; RR into innovation covariance PzzP_{zz}.

Recall Feynman: explain to a 12-year-old

Imagine you have a blurry cloud of dots showing where a rocket might be. You need to know where it'll be after a curvy, twisty motion. The old trick (EKF) pretends the twisty path is a straight line — cheap but wrong on sharp turns. The UKF trick: pick just a few "scout" dots — one in the middle and a couple on each side — send each scout through the real twisty path, and see where they land. From where the scouts end up, you redraw the new cloud. Because you used the real path (not a straight-line guess), your new cloud is much more accurate — and you only had to move a handful of scouts, not a million.


Connections

  • Extended Kalman Filter (EKF) — the linearization approach the UKF improves upon.
  • Kalman Filter (linear) — the parent algorithm; UKF reuses its gain/update structure.
  • Particle Filter — uses many random samples; UKF uses few deterministic ones.
  • Cholesky Decomposition — computes P\sqrt{P} for sigma-point placement.
  • Taylor Series Expansion — the tool the EKF relies on and the UKF sidesteps.
  • State Estimation in GNC — where UKF is deployed (attitude, orbit determination).
  • Nonlinear Systems — the regime where UKF's advantage appears.

Concept Map

linearizes via

discards

can cause

motivates

built on

approximates

sampled by

placed using

match

pushed through

yields

control spread of

Extended Kalman Filter

Taylor expansion Jacobian

Curvature error

Wrong mean and covariance

Unscented Kalman Filter

Unscented Transform

Probability distribution

Sigma points 2n+1

Matrix square root of P

Mean and covariance exactly

True nonlinear f

Estimated mean and Py

Scaling alpha kappa beta lambda

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, problem yeh hai: humein pata hai rocket kahan hai (mean) aur kitni uncertainty hai (covariance PP), lekin uska motion ya sensor equation nonlinear hai. Purana EKF wala tareeka bolta hai — chalo is curvy function ko ek straight line se replace kar dete hain (Jacobian nikaal ke). Lekin agar function tez mudta hai, toh yeh straight-line approximation galat answer degi, aur filter diverge kar sakta hai.

UKF ka jugaad zabardast hai: function ko approximate mat karo, distribution ko approximate karo. Yaani $2

Go deeper — visual, from zero

Test yourself — Guidance, Navigation & Control (GNC)

Connections