ProjekinAja. Robotics Stage 4 · State Estimation Lesson 4.6
● Stage 4 · Lesson 4.6

The Unscented Kalman Filter: When the Jacobian Is Not Enough

The UKF propagates a set of carefully chosen sigma points instead of linearizing — it costs more but degrades gracefully where the EKF diverges.

⏱ ~24 min read 🎛 Interactive widget 📐 Sigma point geometry

🎯 By the end you'll understand

Why the EKF's first-order linearization breaks down on highly nonlinear functions, and what the approximation error actually looks like geometrically. How the unscented transform selects sigma points to capture the mean and covariance of a distribution through a nonlinear mapping — accurately to third order for Gaussian inputs. The full UKF predict and update cycle. How to tune alpha, beta, and kappa, and what happens when you get alpha too small. When the UKF is worth the extra computation versus when the EKF is perfectly adequate. And the specific numerical failure mode — non-positive-definite covariance — that an improperly tuned UKF produces.

KEY INSIGHTIt is easier to approximate a distribution than a function

The EKF approximates the nonlinear function with a line. The UKF approximates the distribution with a cloud of carefully placed points. For mildly nonlinear functions, both are fine. When the function curves significantly over the uncertainty ellipse, the UKF wins by design.

The Extended Kalman Filter's linearization strategy is elegant but fragile: it replaces the nonlinear measurement or process function with its first-order Taylor expansion at the current mean, then applies the linear Kalman equations. This works beautifully when the function is nearly linear over the support of the state distribution — which is exactly the regime most GPS-plus-IMU systems live in. But when the measurement function curves significantly over the uncertainty ellipse (think: bearing-only sensors, wrap-around angles, range sensors at extreme angles), the linearization introduces a systematic bias. The posterior mean is wrong in a direction you can predict from the function's second derivative, and the posterior covariance is wrong in a way that compounds over time. The EKF diverges not noisily — loudly, with clear outliers — but quietly, with an overconfident covariance and a mean that drifts just far enough from reality to cause downstream failures.

🔑 The key insight of the unscented transform

Julier and Uhlmann (1995) made a conceptual leap: rather than linearize the function and propagate the Gaussian analytically, propagate a small set of deterministically chosen sample points — sigma points — through the true nonlinear function, then reconstruct the mean and covariance from the transformed points. The reconstruction is accurate to at least second order in the Taylor expansion of the nonlinear function (third order for symmetric distributions like Gaussians). You do not compute any Jacobian. You evaluate the function 2n+1 times where n is the state dimension. The cost is predictable and the accuracy is substantially better when the function is strongly nonlinear.

CORE CONCEPTWhat breaks when the EKF linearizes badly

To see exactly where the EKF goes wrong, consider a concrete one-dimensional case. Suppose the true state x is Gaussian with mean μ = π/4 ≈ 0.785 and variance σ² = 0.3. The measurement function is h(x) = tan(x). At x = π/4, tan(π/4) = 1 — that is the linearization point. The EKF computes the Jacobian H = dh/dx = 1/cos²(x) = 2 at x = π/4, then propagates:

But what does the true distribution of h(x) actually look like? Because tan(x) curves dramatically near π/2, the true mean of h(x) is not h(μ) = 1.0 — it is larger, pulled by the asymmetric elongation of the distribution through the nonlinearity. The EKF underestimates the posterior mean and miscalibrates the variance. The sigma point approach, propagating 2n+1 = 3 points through the actual tan() function, captures this correctly.

In robotics, the classic example — and the one you will probe in the widget below — is bearing-only localization: the robot observes the angle to a landmark but not its distance. The measurement function is h(x, y) = atan2(y_L - y, x_L - x), where (x_L, y_L) is the known landmark position and (x, y) is the robot position. Near the landmark, the atan2 function changes extremely rapidly relative to changes in robot position. If the uncertainty ellipse in (x, y) is large, the EKF's linearization of atan2 at the mean is a very poor approximation of how the distribution transforms. The posterior mean the EKF produces is biased, the covariance underestimates the spread, and repeated updates pull the estimate in a systematically wrong direction. FollowBot's LIDAR scan-matching produces a similar geometric situation near corners and open doorways.

Input state (x) μ χ₀ χ₁ χ₂ σ points at μ ± √(nλ)·σ h(x) nonlinear EKF: tangent at μ only UKF: propagate all σ pts Output h(x) EKF μ̂ true μ UKF μ̂ EKF (linearized) True posterior UKF (sigma pts)
Left: input Gaussian with three sigma points (χ₀ at the mean, χ₁ and χ₂ at ±√(nλ)·σ). Right: the EKF output (red) is symmetric around a biased mean because it only uses the tangent at μ. The UKF propagates all three points through the true function, giving a posterior mean (orange dashed) that is much closer to the true posterior (grey dashed). The output's asymmetry is captured implicitly through the weighted combination of the transformed sigma points.

HOW IT WORKSThe unscented transform: sigma points, weights, reconstruction

Let the state dimension be n. The unscented transform works in three steps for any nonlinear function y = h(x) where x ~ N(μ, P).

1

Select 2n+1 sigma points

Define a composite parameter λ = α²(n + κ) − n. Then:

  • χ₀ = μ  (the mean itself)
  • χᵢ = μ + (√((n+λ)P))ᵢ  for i = 1, …, n
  • χᵢ = μ − (√((n+λ)P))ᵢ₋ₙ  for i = n+1, …, 2n

The notation (√((n+λ)P))ᵢ means the i-th column of the matrix square root (Cholesky factor) of (n+λ)P. For a 2D state (n=2), you get 5 sigma points; for a 5D state (n=5), you get 11.

2

Compute weights for mean and covariance

Each sigma point carries two scalar weights — one for reconstructing the mean (Wᵐ) and one for the covariance (Wᶜ):

  • Wᵐ₀ = λ / (n + λ)
  • Wᶜ₀ = λ / (n + λ) + (1 − α² + β)
  • Wᵐᵢ = Wᶜᵢ = 1 / (2(n + λ))  for i = 1, …, 2n

The parameter β allows you to incorporate prior knowledge of the distribution's kurtosis. For a Gaussian, β = 2 is optimal. The weights sum to one for the mean (Σ Wᵐᵢ = 1) but not necessarily for the covariance.

3

Propagate and reconstruct

Propagate each sigma point through the nonlinear function: γᵢ = h(χᵢ). No Jacobian required — you are evaluating the actual function at each point. Then reconstruct the output statistics as weighted sums:

  • ŷ = Σᵢ Wᵐᵢ γᵢ  (weighted mean)
  • S = Σᵢ Wᶜᵢ (γᵢ − ŷ)(γᵢ − ŷ)ᵀ + R  (weighted covariance + measurement noise)
  • Pₓᵧ = Σᵢ Wᶜᵢ (χᵢ − μ)(γᵢ − ŷ)ᵀ  (cross-covariance)

This reconstruction matches the mean and covariance of the true transformed distribution to second order in the Taylor expansion, and to third order for symmetric (Gaussian) inputs. The EKF matches only first order — it uses only the slope (the Jacobian), not the curvature.

📖 Why "unscented"?

Julier and Uhlmann reportedly coined the term as a deliberate non-sequitur, tired of the trend of forced algorithmic acronyms. The transform has nothing to do with smell — it refers to the strategy of "not stinking" of approximation errors the way the EKF's linearization does. The name stuck. Some papers use the more descriptive term "sigma point Kalman filter."

HOW IT WORKSUKF predict and update — the full cycle

The UKF predict-update cycle mirrors the EKF's structure but replaces every Jacobian matrix with an unscented transform. Here is the full algorithm for a state x ∈ ℝⁿ with process function f and measurement function h:

📋 UKF algorithm (one cycle)

Predict step:

  1. Compute sigma points χᵢ from current (μ, P) using the sigma point formula above.
  2. Propagate through process model: χ̄ᵢ = f(χᵢ, u) for each i.
  3. Predicted mean: μ̄ = Σᵢ Wᵐᵢ χ̄ᵢ
  4. Predicted covariance: P̄ = Σᵢ Wᶜᵢ (χ̄ᵢ − μ̄)(χ̄ᵢ − μ̄)ᵀ + Q

Update step:

  1. Recompute sigma points χᵢ from predicted (μ̄, P̄). (You can optionally augment with Q sigma points for additive noise — not covered here.)
  2. Propagate through measurement model: γᵢ = h(χᵢ) for each i.
  3. Predicted measurement: ŷ = Σᵢ Wᵐᵢ γᵢ
  4. Innovation covariance: S = Σᵢ Wᶜᵢ (γᵢ − ŷ)(γᵢ − ŷ)ᵀ + R
  5. Cross-covariance: Pₓᵧ = Σᵢ Wᶜᵢ (χᵢ − μ̄)(γᵢ − ŷ)ᵀ
  6. Kalman gain: K = Pₓᵧ S⁻¹
  7. Posterior mean: μ = μ̄ + K(z − ŷ)
  8. Posterior covariance: P = P̄ − K S Kᵀ

Notice that steps 6–8 of the update are identical to the standard Kalman filter update equations — the Kalman gain formula and covariance update are unchanged. Only the computation of S and Pₓᵧ differs: instead of Jacobians (H P̄ Hᵀ + R and P̄ Hᵀ), you use the empirical weighted covariances from the sigma point propagation. This is what makes the UKF a drop-in replacement for the EKF in almost any filter architecture: the interface is identical, only the internal prediction and innovation covariance computations change.

ukf_core.pyPython · bearing-only UKF skeleton
import numpy as np

def sigma_points(mu, P, alpha, kappa):
    # Returns (2n+1, n) array of sigma points and weights
    n = len(mu)
    lam = alpha**2 * (n + kappa) - n
    S = np.linalg.cholesky((n + lam) * P)   # Cholesky factor
    sigmas = np.zeros((2*n+1, n))
    sigmas[0] = mu
    for i in range(n):
        sigmas[i+1]   = mu + S[:, i]
        sigmas[n+i+1] = mu - S[:, i]
    return sigmas, lam, n

def weights(n, lam, alpha, beta):
    # Mean weights and covariance weights
    Wm = np.full(2*n+1, 1 / (2*(n+lam)))
    Wc = Wm.copy()
    Wm[0] = lam / (n + lam)
    Wc[0] = lam / (n + lam) + (1 - alpha**2 + beta)
    return Wm, Wc

def bearing_h(x, landmark):
    # Nonlinear measurement: bearing angle to a known landmark
    dx = landmark[0] - x[0]
    dy = landmark[1] - x[1]
    return np.array([np.arctan2(dy, dx)])

def ukf_update(mu, P, z, landmark, R, alpha=1e-3, beta=2, kappa=0):
    sigmas, lam, n = sigma_points(mu, P, alpha, kappa)
    Wm, Wc = weights(n, lam, alpha, beta)
    # Propagate through measurement function
    gamma = np.array([bearing_h(s, landmark) for s in sigmas])  # (2n+1, m)
    y_hat = Wm @ gamma                                              # predicted meas.
    S  = R.copy()
    Pxy = np.zeros((n, gamma.shape[1]))
    for i in range(2*n+1):
        dy = (gamma[i] - y_hat).reshape(-1,1)
        S  += Wc[i] * dy @ dy.T
        Pxy += Wc[i] * np.outer(sigmas[i]-mu, dy)
    K   = Pxy @ np.linalg.inv(S)
    mu_ = mu + K @ (z - y_hat)
    P_  = P - K @ S @ K.T
    return mu_, P_

The sigma point selection depends entirely on a successful Cholesky decomposition of (n+λ)P. When P is not positive-definite — which happens when the covariance has been corrupted by numerical errors or poor tuning — np.linalg.cholesky raises a LinAlgError. This is the UKF's characteristic failure signal. The EKF fails silently in the same situation (the matrix inversion produces garbage but does not error); the UKF crashes explicitly. That makes the UKF's failure mode louder and easier to diagnose — a property worth remembering during field debugging.

IN PRACTICETuning alpha, beta, kappa — and the failure modes of getting them wrong

The three UKF parameters (α, β, κ) control the spread, weight distribution, and scaling of the sigma points. Unlike Q and R (which encode physical quantities), these are algorithmic tuning knobs with more abstract interpretations.

ParameterRoleTypical valueEffect of going too smallEffect of going too large
α (alpha) Controls spread of sigma points around the mean. Determines how far out along the uncertainty ellipse the points are sampled. 10⁻³ to 1; typical 0.001 Sigma points collapse to the mean. The spread (√((n+λ)P)) shrinks to near-zero. Cholesky may fail on the zero or near-zero argument — non-positive-definite error. Even if it does not crash, σ points no longer probe the nonlinearity, so accuracy degrades to below EKF level. Sigma points spread far into the tails. For strongly non-Gaussian distributions or when the function has discontinuities, far-out sigma points hit bad regions of the function. Also, Wᶜ₀ = λ/(n+λ) + (1−α²+β) can become a large negative number at large α (e.g., α=10, n=5: Wᶜ₀ ≈ −96), which can make the reconstructed output covariance non-positive-definite. Note: it is small α that causes Wᵐ₀ = λ/(n+λ) to go negative (when α < √(n/(n+κ))), not large α.
β (beta) Incorporates prior knowledge of kurtosis into the covariance weight of the mean sigma point. 2 for Gaussian Under-weights the mean sigma point in covariance reconstruction. Marginal effect for Gaussian inputs. Over-weights the mean. Again marginal for Gaussian inputs; matters if the distribution is heavy-tailed (e.g., particle-estimated marginals passed in).
κ (kappa) Secondary scaling, combined with α to set λ. Often set to 0 or 3-n. 0 (default) or 3-n No failure; just shifts the sigma point spread slightly. 3-n is the "moments-matching" choice for Gaussian inputs when you set α=1. If (n+λ) = α²(n+κ) becomes negative (possible with small α and negative κ), the Cholesky argument is negative — guaranteed crash.
⚠ The alpha-too-small failure is the UKF's most common numerical trap

Setting α = 1e-5 or smaller is tempting because "smaller spread = less extrapolation." But when α approaches zero, λ = α²(n+κ) − n approaches −n, and (n+λ) approaches zero. The Cholesky factor of near-zero P gives near-zero sigma point displacements. Now Wᵐ₀ = λ/(n+λ) ≈ −n/0 diverges. In practice this means the reconstructed covariance has a pathological first term that dominates all other weights, and the resulting P is numerically non-positive-definite. The filter crashes on the next time step. The fix: keep α ≥ 10⁻³ unless you have a specific reason (and have tested it). A value of α = 0.1 to 1.0 is conservative and numerically stable for most robotics applications.

A practical starting recipe: set α = 0.1, β = 2, κ = 0 for any first deployment. Then do a NEES consistency check (introduced in Lesson 4.4) to verify the filter is calibrated. If the NEES is high (overconfident), increase α slightly to spread the sigma points and probe more curvature. If the NEES is low (overconservative), the problem is more likely in Q/R than in the sigma point spread.

SEE ITEKF vs. UKF — bearing-only nonlinear measurement

Both filters track the same 2D robot position using bearing-only measurements to a fixed landmark. Use the nonlinearity level slider to control how severely curved the measurement function is over the uncertainty ellipse. Then choose the alpha value to see the UKF's numerical stability boundary. Pay attention to when the EKF posterior mean drifts away from truth while the UKF holds — and when alpha is too small and the UKF itself fails.

⚙ Interactive · EKF vs. UKF sigma-point comparison

Adjust sliders and watch where each filter's posterior mean lands relative to ground truth. The worst choice: maximum nonlinearity + alpha too small — EKF diverges AND UKF crashes.

3

1 = mild (robot far from landmark), 5 = extreme (robot nearly on top of landmark)

—
EKF mean error (m)
—
UKF mean error (m)
—
UKF improvement
OK
Filter status
True robot position EKF posterior mean UKF posterior mean Sigma points (UKF) Landmark

Select nonlinearity level and alpha to see how the filters compare.

The visualization reveals a key asymmetry. The EKF's mean error grows smoothly as nonlinearity increases — it never crashes, it just slowly becomes wrong. The UKF with a sensible alpha value tracks truth accurately even at extreme nonlinearity. But the UKF with a near-zero alpha (α = 1e-6) fails catastrophically at any nonlinearity level: the sigma points collapse to the mean, the covariance reconstruction produces a non-positive-definite matrix, and the filter cannot continue. This failure is loud (the code throws an exception) but only if you are running the UKF correctly with a Cholesky decomposition — a naive implementation that uses eigendecomposition or ignores the breakdown will silently produce garbage.

COMPARISONComputational cost: EKF vs. UKF

The UKF costs more than the EKF per update cycle. Understanding the cost difference precisely helps you decide whether the accuracy improvement is worth the overhead.

OperationEKFUKFDominant factor
Sigma point generationNone (Jacobian instead)Cholesky: O(n³)UKF: matrix square root of (n+λ)P
Function evaluations1 (mean only)2n+1UKF: evaluates h() 2n+1 times
Jacobian computationO(m×n) analytical or numericalNone requiredEKF: often the bottleneck for complex functions
Covariance propagationH P Hᵀ: O(m×n²)Weighted outer products: O(n²×(2n+1))Comparable at small n; UKF grows faster
Total per update (n=5, m=1)~0.1 ms (C++)~0.4 ms (C++)~4× overhead at this scale
Total per update (n=15, m=3)~0.3 ms~3.5 ms~12× overhead; Cholesky dominates

For FollowBot's 5D state vector [x, y, θ, v, ω], a single UKF update takes roughly 0.4 ms in a well-implemented C++ node, versus ~0.1 ms for the EKF. At a 50 Hz filter rate, the UKF adds about 15 ms of compute budget per second — entirely manageable on FollowBot's onboard processor. The crossover where UKF cost becomes problematic is typically n ≳ 30 on embedded hardware, which is why UKF is rarely used for full SLAM (hundreds of states) but is commonly used for sensor fusion (5–15 states).

Note: timing figures (~0.1 ms EKF, ~0.4 ms UKF for n=5) are illustrative estimates for a typical desktop CPU. Actual values depend heavily on implementation and hardware. Benchmark on your target platform before drawing conclusions about real-time feasibility.

💡 When does the UKF's extra cost pay off?

Use the UKF when: (1) the measurement or process function has significant curvature over the uncertainty ellipse, (2) you cannot derive a Jacobian analytically (the UKF is Jacobian-free — a practical advantage for complex symbolic functions), (3) the EKF has been observed to diverge in a specific operating condition and you have ruled out Q/R miscalibration as the cause, or (4) you are prototyping and want to establish a ground truth filter before committing to a Jacobian derivation. Do not use the UKF merely because it "sounds more accurate." On a well-calibrated EKF with a mildly nonlinear problem, the accuracy difference is negligible and the EKF is faster and simpler.

FOLLOWBOTUKF as a validation benchmark for FollowBot's EKF

By the Stage 4 milestone, FollowBot is running a full EKF on the state vector [x, y, θ, v, ω], fusing wheel odometry, IMU, and LIDAR scan-matching. Position error is below 0.1 m RMS in a known map. The EKF's NEES has been validated on recorded data. So where does the UKF fit in?

The specific measurement functions that are most nonlinear in FollowBot's EKF are the LIDAR scan-matching residuals when the robot is near a corner, and the bearing component of person-tracking when the person is very close (< 1.5 m). For these two scenarios, the EKF's Jacobian approximation is under the most stress. The UKF is most naturally used here as a benchmark: run both filters on the same data log, compare posterior means and covariances. If the EKF and UKF agree (within NEES tolerance), your EKF is well-calibrated and there is no reason to replace it. If they diverge substantially — particularly if the EKF covariance is systematically smaller (overconfident) compared to the UKF on the same nonlinear update — that is a diagnostic signal that the linearization is introducing bias and the UKF would produce better estimates for that sensor.

🔑 FollowBot integration recipe

Adding a UKF to FollowBot's nav2 EKF setup requires: (1) implement the sigma point generation and propagation as a separate Python node subscribing to the same topics as the EKF (not replacing it — running in parallel), (2) publish the UKF posterior on a shadow topic (/ukf/odom), (3) record both /odometry/filtered and /ukf/odom during a sequence that includes close-range person tracking, (4) compute the posterior mean difference and the NEES ratio between the two filters offline. This gives you a principled, data-driven answer to "would the UKF help here?" rather than a guess.

ukf_shadow_node.pyrclpy · UKF shadow filter for FollowBot
import rclpy
from rclpy.node import Node
from nav_msgs.msg import Odometry
import numpy as np

class UKFShadow(Node):
    def __init__(self):
        super().__init__('ukf_shadow')
        # Subscribe to same odometry as the EKF
        self.create_subscription(Odometry, '/odometry/filtered',
                                  self.ekf_cb, 10)
        self.pub = self.create_publisher(Odometry, '/ukf/odom', 10)
        # UKF state: [x, y, theta, v, omega] — same as EKF
        self.mu = np.zeros(5)
        self.P  = np.eye(5) * 0.5
        self.alpha, self.beta, self.kappa = 0.1, 2, 0

    def ekf_cb(self, msg):
        # In production: run UKF predict+update independently.
        # Here: compare EKF output vs UKF output on the same measurement.
        z = np.array([msg.pose.pose.position.x,
                       msg.pose.pose.position.y])
        # ... run UKF update, publish on /ukf/odom ...
        self._publish(self.mu, self.P, msg.header)

    def _publish(self, mu, P, header):
        out = Odometry()
        out.header = header
        out.pose.pose.position.x = float(mu[0])
        out.pose.pose.position.y = float(mu[1])
        self.pub.publish(out)

def main():
    rclpy.init()
    rclpy.spin(UKFShadow())
    rclpy.shutdown()

Running this shadow node during FollowBot's person-following test and comparing the two filter posteriors on a recorded rosbag will give you a direct measurement of how much the EKF's linearization bias matters on your specific hardware and environment. If the RMS difference between EKF and UKF means exceeds 5 cm in position and 0.05 rad in heading during the close-range person-tracking phase, the UKF deserves a serious second look for those measurement updates specifically.

WEAKNESSWhere the UKF bites

⚠ Non-positive-definite covariance from alpha misconfiguration

The most common UKF failure in the field: alpha is set too small (≤ 10⁻⁵ for a 5D state), λ = α²(n+κ) − n goes strongly negative, Wᵐ₀ becomes a large negative number, and the reconstructed covariance P = Σ Wᶜᵢ ... has a dominant negative contribution from the zero-th sigma point. The matrix becomes non-positive-definite, the next Cholesky decomposition fails, and the filter crashes. The confusing part: this error is often blamed on the measurement model ("bad sensor data") rather than alpha, because the crash happens during an update when a new measurement arrives. Diagnosis: print (n+λ) and check that it is positive and numerically well-conditioned before the first run. Values between 1.0 and n+1 are generally safe.

⚠ The UKF does not fix a wrong noise model

The UKF's accuracy advantage over the EKF is in handling nonlinearity. It does not fix a miscalibrated Q or R. A UKF with Q set 100× too small will still diverge — its covariance will collapse with overconfidence, just as an EKF would. Engineers who switch from EKF to UKF expecting "more robustness" and then see the filter diverge are usually confused by this. Run the NEES test (Lesson 4.4) on the UKF output to verify consistency — the same check that validates the EKF. The UKF should pass the NEES test if Q, R, and alpha are all properly calibrated.

⚠ The UKF is not magic for multimodal or heavy-tailed distributions

The unscented transform approximates the propagation of a Gaussian distribution through a nonlinear function. It assumes the input distribution is Gaussian and remains unimodal after transformation. If the true posterior is multimodal — for example, if FollowBot is trying to localize in a symmetric corridor where it genuinely cannot distinguish left from right — the UKF will force a unimodal Gaussian onto a bimodal reality, and the resulting mean will sit between the two modes (a position with probability near zero in the true posterior). This is the same fundamental limitation as the EKF. For genuinely multimodal posteriors, you need a particle filter (Lesson 4.7). The UKF is a better Gaussian filter than the EKF; it is not a non-Gaussian filter.

KEY INSIGHTHow this connects

  • 4.5 · The Extended Kalman Filter: Nonlinear Systems and Jacobian Linearization — the EKF is the baseline the UKF improves on. The bearing-only measurement model used in the widget above is the same one introduced in Lesson 4.5. If you have not worked through the EKF Jacobian derivation for atan2, do that first — understanding what the EKF approximates makes the UKF's sigma point strategy immediately intuitive as the next step.
  • 4.7 · Particle Filters: Non-Gaussian and Multimodal Beliefs — the particle filter is the third major filter family and handles what the UKF cannot: multimodal and heavily non-Gaussian posteriors. The UKF and particle filter bracket the space of practical nonlinear filters: use the UKF for Gaussian posteriors with significant nonlinearity, the particle filter for multimodal posteriors, and the EKF for mildly nonlinear Gaussian posteriors where the Jacobian is easy to derive.

The UKF occupies a specific niche in the filter landscape: it is strictly better than the EKF for nonlinear Gaussian problems at moderate state dimensions (n ≤ ~20), and it gives you Jacobian-free implementation as a practical bonus. It is not better than the particle filter for multimodal problems, and it is not better than the linear Kalman filter for linear problems. Knowing the filter's operating conditions is as important as knowing how to implement it.

GLOSSARYKey terms

Unscented transform
A method for propagating the mean and covariance of a probability distribution through a nonlinear function by evaluating the function at a deterministically chosen set of sigma points and reconstructing the output statistics from weighted sums. Accurate to second order (third for Gaussian inputs) in the Taylor expansion of the nonlinear function.
Sigma points
The 2n+1 deterministically chosen sample points used in the unscented transform. One point is at the mean; n pairs are symmetrically placed along the principal axes of the covariance ellipse, scaled by √((n+λ)P). They are not random samples — their positions are exact functions of the mean, covariance, and tuning parameters.
Alpha (α)
The primary UKF tuning parameter controlling the spread of the sigma points around the mean. Through λ = α²(n+κ) − n, it scales how far from the mean the sigma points are placed. Values of 0.001 to 1.0 are typical; values below ~10⁻⁴ risk producing a non-positive-definite covariance through the weight Wᵐ₀ = λ/(n+λ).
Non-positive-definite covariance
A covariance matrix that fails to satisfy P ≻ 0 (all eigenvalues strictly positive). Required for a valid probability distribution; required for the Cholesky decomposition used in sigma point generation. Can result from numerical errors, accumulated rounding in filter updates, or UKF parameter misconfiguration (especially too-small alpha). Causes a hard crash in any implementation using Cholesky.
Bearing-only localization
A navigation problem where the robot observes only the angle to a known landmark, not the distance. The measurement function h(x,y) = atan2(y_L−y, x_L−x) is highly nonlinear near the landmark, making it an ideal test case for comparing EKF and UKF accuracy.
Jacobian-free filter
A filter that does not require the analytical derivation of a Jacobian matrix for nonlinear functions. The UKF is Jacobian-free because it evaluates the function numerically at sigma points rather than differentiating it analytically. This is a practical advantage when the function is complex or its derivative is difficult to derive symbolically.
Lambda (λ)
The composite UKF scaling parameter λ = α²(n+κ) − n. Appears in the sigma point formula as (n+λ)P under the square root and in the weights as λ/(n+λ). Must satisfy n+λ > 0 for the Cholesky decomposition to succeed. Negative λ is permissible if |λ| < n, but small positive values of n+λ are numerically risky.
Cross-covariance (Pₓᵧ)
The covariance between the predicted state sigma points and the propagated measurement sigma points, computed as Σᵢ Wᶜᵢ (χᵢ − μ̄)(γᵢ − ŷ)ᵀ in the UKF update. Plays the same role as P Hᵀ in the EKF — it is the numerator of the Kalman gain. The UKF computes it empirically from the sigma points rather than from the Jacobian.

ACTIVE RECALLCheck your understanding

Answer in your own words first, then reveal.

1Why does the EKF's first-order linearization introduce a biased posterior mean for highly nonlinear measurement functions, and how does the unscented transform address this?›

The EKF approximates h(x) as h(μ) + H(x − μ) where H is the Jacobian at μ. This is the tangent line to the function at the mean. For a linear function, the tangent is exact. For a curved function (like atan2 near a landmark or tan(x) near π/4), the true image of the Gaussian distribution through h is asymmetric and shifted relative to h(μ) — the function's curvature drags more probability mass to one side. The EKF uses only h(μ) as the predicted measurement mean, which misses this shift; the posterior mean is therefore biased in the direction the curvature bends. The unscented transform evaluates h at all 2n+1 sigma points spread across the uncertainty ellipse, then reconstructs the output mean as a weighted sum of h(χᵢ). The curvature effect on the output mean is captured empirically through those additional evaluations, because the sigma points at χ₁…χ₂ₙ probe the non-mean regions of the function. The result matches the true transformed mean to second order — which, for the EKF's zeroth-order error (the bias), is already a significant improvement.

2You set alpha = 1e-6 for a UKF with n=5 state dimensions and kappa=0. What happens, and at which specific step in the algorithm does it fail?›

With α = 10⁻⁶ and n = 5, κ = 0: λ = α²(n+κ) − n = 10⁻¹²×5 − 5 ≈ −5. Therefore n+λ ≈ 0. The sigma point formula calls for the Cholesky factor of (n+λ)P ≈ 0×P = 0 — a zero matrix. A zero matrix is positive semidefinite but not positive definite, so the Cholesky decomposition either returns a zero factor (if the library allows it) or raises an error immediately. If a zero factor is returned, all sigma points collapse to the mean (χᵢ = μ for all i), and the weight Wᵐ₀ = λ/(n+λ) ≈ −5/0 diverges. The covariance reconstruction Σ Wᶜᵢ(...) then has a divergent first term and produces a non-positive-definite or infinite P. The filter crashes on the very first call to sigma_points(), before any measurement update occurs — the failure is at sigma point generation, not at covariance update. The fix: enforce α ≥ 10⁻³ and verify that n+λ = α²(n+κ) > 0 at initialization.

3FollowBot's EKF is passing the NEES test with well-calibrated Q and R. A colleague argues you should switch to a UKF for robustness. Under what conditions would you agree, and under what conditions would you push back?›

Push back strongly if: the EKF is NEES-consistent (proven by test, not by eye), the operating conditions are the same ones you tested, the state dimension is large (making UKF ~4–12× more expensive), and the measurement functions have mild nonlinearity relative to the uncertainty ellipse. A NEES-consistent EKF already has calibrated posterior uncertainty — there is no accuracy gap to close. The UKF's 4× overhead per update with no accuracy benefit is an engineering regression. Agree to investigate the UKF if: field testing reveals specific operating conditions where the EKF diverges or NEES spikes — particularly during close-range person tracking (atan2 highly nonlinear) or near corner LIDAR matches — that coincide with high nonlinearity in h over the current uncertainty ellipse. The principled approach: run both filters on a recorded bag and compare NEES and mean error. Let data decide, not intuition about which algorithm "sounds more robust."

4What does the UKF share with the EKF in terms of fundamental limitations, and what does the particle filter address that neither Kalman variant can?›

Both the EKF and UKF assume the posterior distribution is (approximately) Gaussian and unimodal. The EKF represents this Gaussian with a mean and covariance and propagates it via linearization; the UKF propagates it via sigma points. But both ultimately maintain a single Gaussian as their state estimate — a mean vector and a covariance matrix. When the true posterior is multimodal (e.g., FollowBot in a symmetric environment where it genuinely cannot disambiguate which of two identical-looking corridors it is in), both filters must choose a single Gaussian to represent it. They will place that Gaussian between the two modes — at a location with near-zero true probability — and the posterior will be incoherent. Neither filter can represent "I think I am in corridor A or corridor B, equally likely." The particle filter can: it maintains an explicit weighted sample set that can represent arbitrary multimodal distributions. Its cost is O(N) function evaluations per update where N is the number of particles (often 1000–10000), which is far more expensive than the UKF's 2n+1 evaluations for small n — but it is the only correct filter for genuinely multimodal posteriors.

Next: particle filters — when Gaussians are not enough →