M-Estimator

Ordinary least squares is statistically optimal under Gaussian noise — and catastrophically fragile under outliers, because the squared loss grows without bound: a single gross outlier can drag the estimate arbitrarily far. M-estimators (maximum-likelihood-type estimators) fix this by replacing the squared loss with a robust kernel ρ\rho that grows more slowly for large residuals:

minθiρ ⁣(ri(θ)σ)\min_{\theta} \sum_i \rho\!\left(\frac{r_i(\theta)}{\sigma}\right)

where rir_i is the ii-th residual (e.g. a reprojection error) and σ\sigma is a scale parameter that normalizes residuals to noise units.

Common robust kernels

ρ(r)={r2/2rkkrk2/2r>k\rho(r) = \begin{cases} r^2/2 & |r| \leq k \\ k|r| - k^2/2 & |r| > k \end{cases}

Convex, safe, mild — the default choice when unsure.

The derivative ψ(r)=ρ(r)\psi(r) = \rho'(r) is called the influence function: it measures how much a datum at residual rr tugs on the estimate. For least squares ψ(r)=r\psi(r) = r (unbounded influence); for Huber it is clipped at ±k\pm k; for Tukey it redescends to zero.

Solving with IRLS

Setting the gradient of the robust cost to zero gives iψ(ri)ri/θ=0\sum_i \psi(r_i)\,\partial r_i/\partial\theta = 0. Defining a weight wi=ψ(ri)/riw_i = \psi(r_i)/r_i turns this into the condition of a weighted least-squares problem, which suggests Iteratively Reweighted Least Squares (IRLS):

  1. Compute residuals rir_i at the current estimate.
  2. Compute weights wi=ρ(ri)/riw_i = \rho'(r_i)/r_i (small residual → weight near 1; large residual → weight near 0).
  3. Solve the weighted least-squares problem minθiwiri(θ)2\min_\theta \sum_i w_i\, r_i(\theta)^2 (one Gauss-Newton/LM step).
  4. Repeat until convergence.

In practice this integrates seamlessly into a Gauss-Newton or Levenberg-Marquardt loop: the robust kernel just rescales each residual block’s Jacobian and error. Ceres calls these LossFunctions, g2o calls them RobustKernels.

The scale σ\sigma matters as much as the kernel: it defines what counts as “large”. A standard robust estimate is derived from the median absolute deviation, σ^=1.4826medianirimedian(r)\hat{\sigma} = 1.4826 \cdot \mathrm{median}_i\,|r_i - \mathrm{median}(r)|, where the constant makes it consistent with the Gaussian standard deviation.

M-estimators vs. RANSAC

The two are complementary, and real pipelines use both:

The standard recipe: RANSAC to find a coarse model and inlier set, then robust nonlinear refinement (Huber/Cauchy) over the inliers to absorb the remaining mismatches.

Why it matters for SLAM

Every residual in SLAM is occasionally wrong: mismatched features, moving objects, false loop closures. Feeding even a handful of these into a pure least-squares bundle adjustment corrupts the whole trajectory. Robust kernels are therefore ubiquitous — ORB-SLAM wraps reprojection errors in Huber kernels, pose-graph back-ends wrap loop-closure edges in Cauchy or switchable-constraint formulations, and modern globally robust methods (graduated non-convexity) are built directly on redescending M-estimators. Knowing which kernel a system uses, and at what threshold, tells you how it will behave the day the front-end lies to it.