Filter catalog
Seven filter kinds; pick by what your model can promise.
| Filter | Use when |
|---|---|
LinearKalmanFilter |
x_{t+1} = F x_t + w, z_t = H x_t + v. Closed-form Gaussian. |
AdaptiveKalmanFilter |
Linear, but R is unknown and drifts. |
ExtendedKalmanFilter |
Nonlinear f(x) / h(x), you can supply Jacobians. |
IteratedExtendedKalmanFilter |
EKF, but the measurement is nonlinear enough that one linearization underfits. |
UnscentedKalmanFilter |
Nonlinear and you don't want to write Jacobians, or moderate state dim where deterministic sigma points are tractable. |
EnsembleKalmanFilter |
Nonlinear, very high state dim where sigma points are too expensive — but the binding only exposes ensemble_size=8 right now. |
LinearKalmanFilterBank |
K independent linear filters with shared dynamics — basket of symbols, multi-channel detector, per-pixel tracker. See Bank. |
LinearKalmanFilter
kf = kalman.LinearKalmanFilter(nx, nz)
kf.F = [...]; kf.Q = [...]; kf.H = [...]; kf.R = [...]
kf.x = [...]; kf.P = [...]
result = kf.update_many(measurements)
The fast path. For shapes the compiler can autovectorize (the 9 kept Tier 1 +
Tier 2 pairs), the C++ per-tick cost is in the tens of nanoseconds; everything
else falls through to a runtime-sized _DynLinearKalmanFilter that's still C++
but ~2-5× slower per tick.
predict_kinematic / per-tick delta_t
When nx == 2*nz or nx == 3*nz and you pass delta_t=... to update or
update_many, the templated filter advances P via row-shear / column-shear
ops that exploit the structure of F — about 5 multiplies per cell instead of
the full 8-multiply matmul. The runtime _DynLinearKalmanFilter doesn't have
this specialization yet; passing delta_t to it raises ValueError.
AdaptiveKalmanFilter
R is updated online by exponentially smoothing the innovation outer product:
R ← forgetting · R + (1 − forgetting) · y yᵀ
with the diagonal of R floored at min_variance to avoid collapse.
forgetting close to 1.0 → slowly adapting (long memory); close to 0.5 →
quickly adapting. Defaults to 0.95.
Useful when the sensor noise floor varies over time and you don't want to tune
R against a calibration set.
ExtendedKalmanFilter
ekf = kalman.ExtendedKalmanFilter(nx, nz)
ekf.predict(transition, transition_jacobian)
ekf.correct(z, measurement, measurement_jacobian)
Callbacks receive a 1-D numpy view of the state and return either a 1-D vector
(transition, measurement) or a 2-D matrix (Jacobians). The library calls
them once per predict and once per correct.
update_many(measurements, transition, transition_jacobian, measurement, measurement_jacobian)
loops in C++ — each tick still costs one transition and one measurement Python
callback, but the loop overhead between them is gone.
IteratedExtendedKalmanFilter
Same callbacks as EKF. The correction step performs Gauss-Newton refinement:
iekf.correct(z, measurement, measurement_jacobian,
max_iterations=5, tolerance=1e-10)
Each iteration re-evaluates h(x) and H(x) at the latest estimate and
applies a damped linear update. Useful when the measurement is highly
nonlinear near the estimate (range-bearing at close range, log-pose
manifolds, etc.).
UnscentedKalmanFilter
Two callback styles, switchable per call:
Per-sample (one Python callback per sigma point)
ukf = kalman.UnscentedKalmanFilter(nx, nz)
ukf.predict(transition, jitter=1e-9)
ukf.correct(z, measurement, jitter=1e-9)
ukf.update_many(measurements, transition, measurement)
The library invokes transition(sigma_i) and measurement(sigma_i) once for
each of the 2 * nx + 1 sigma points per step. Simple to write.
Batched (one Python callback per step)
def transition_batch(sigmas): # sigmas: (2*nx+1, nx) numpy view
return f(sigmas) # return: (2*nx+1, nx) numpy array
def measurement_batch(sigmas):
return h(sigmas) # return: (2*nx+1, nz)
ukf.predict_batch(transition_batch)
ukf.correct_batch(z, measurement_batch)
ukf.update_many_batch(measurements, transition_batch, measurement_batch)
One Python call per step — much faster when the callback can vectorize over the sigma-point axis with numpy / numba / cython. Algebraically identical to the per-sample form.
Sigma-point parameters
alpha, beta, kappa are r/w properties. Defaults: alpha=1e-3,
beta=2.0, kappa=0.0 — the conventional choice for Gaussian state.
EnsembleKalmanFilter
8-member deterministic EnKF. Members are initialized by the user (or by the
EnsembleKalmanTuner). Per-step:
enkf.predict(transition) # per-member callbacks
enkf.correct_deterministic(z, measurement)
# or
enkf.predict_batch(transition_batch) # (8, nx) → (8, nx)
enkf.correct_deterministic_batch(z, measurement_batch)
enkf.update_many_batch(measurements, transition_batch, measurement_batch)
The deterministic correct does not perturb measurements with noise; it uses
the analytic K = Pxy Pyy⁻¹ form. This is the right choice for small
ensembles where stochastic perturbation would dominate the signal.
ensemble_size is fixed at 8 in the Python binding. The templated C++
EnsembleKalmanFilter<NX, NZ, M> supports any M, but the Python wheel only
exposes M=8.
RangeBearingEKF2D
Specialized EKF for 2D position tracking against a fixed landmark:
ekf = kalman.RangeBearingEKF2D(
dt=1.0, landmark_x=0.0, landmark_y=0.0,
x=[px, py, vx, vy],
P=[...], Q=[...], R=[...],
)
State is (px, py, vx, vy), measurement is (range, bearing). Constant
velocity assumed; per-tick delta_t not yet supported. update_many(measurements)
batches in C++.