2D Kalman Filter

Probability
Sampling Methods
Kalman Filter
Recursive Filters
Parametric Curves
Author

Apurva Nakade

Published

August 8, 2026

A particle moves along a parametric curve \((x(t), y(t))\), observed only through noisy measurements. A constant-velocity 2D Kalman filter tracks it live, one sample at a time, estimating both position and velocity. Reset (Signal & Sampling tab) restarts the run; \(R\)/\(Q\) (Filter Parameters tab) update the running filter immediately, with no restart.

Covariance matrices

\[ F = \begin{pmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}, \qquad H = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix} \]

\[ \hat{\mathbf x}_k^- = F \hat{\mathbf x}_{k-1}, \qquad P_k^- = F P_{k-1} F^\top + \mathbf{Q} \]

\[ S_k = H P_k^- H^\top + \mathbf{R}, \qquad K_k = P_k^- H^\top S_k^{-1} \]

\[ \hat{\mathbf x}_k = \hat{\mathbf x}_k^- + K_k\left(\mathbf z_k - H \hat{\mathbf x}_k^-\right), \qquad P_k = (I - K_k H)\, P_k^- \]

\[ \mathbf{R} = \begin{pmatrix} R & 0 \\ 0 & R \end{pmatrix}, \qquad \mathbf{Q} = Q \begin{pmatrix} 1/4 & 0 & 1/2 & 0 \\ 0 & 1/4 & 0 & 1/2 \\ 1/2 & 0 & 1 & 0 \\ 0 & 1/2 & 0 & 1 \end{pmatrix} \]

State order \((x, y, v_x, v_y)\), one time step per sample (\(\Delta t = 1\)).

Examples

Same measurements, good vs. bad \(R\)/\(Q\), across three trajectories with different acceleration profiles. Click a card, then press Play.

References

Staszewski, Kuba. “Recursive Filters.” Blog post. https://www.staszewski.xyz/blog/recursive-filters/