---
title: Weighted Quaternion Averaging
url: https://www.emergentmind.com/topics/weighted-quaternion-averaging
type: topic
---

# Weighted Quaternion Averaging

Weighted quaternion averaging refers to the computation of a representative or "mean" quaternion, given a set of unit quaternions and associated weights. This operation is central in fields such as 3D registration, pose estimation, ensemble sensor fusion, and probabilistic rotation regression, where robust estimation of orientation from multiple sources or predictions is critical. Weighted quaternion averaging methods address the challenge of averaging on the non-Euclidean manifold of unit quaternions ($S^3$), accounting for their double cover of $\mathrm{SO}(3)$ and the specifics of rotational metric geometry.

## 1. Problem Statement and Metrics

Given a collection $\{q_1,\dots,q_N\} \subset S^3$ of unit quaternions with strictly positive weights $\{w_1,\ldots,w_N\}$, the objective is to compute a mean quaternion $\bar{q} \in S^3$ that optimally represents the set according to a chosen rotational metric. Canonical formulations include:
- Minimizing the weighted sum of squared chordal distances:
  \[
  \bar{q} = \arg\min_{\|q\|=1} \sum_{i=1}^{N} w_i d_{\text{chord}}^2(q,q_i),\qquad
  d_{\text{chord}}(q,p) = \min\{\|q - p\|, \|q + p\|\}
  \]
- Minimizing the weighted sum of squared geodesic distances:
  \[
  J(q) = \sum_{i=1}^N w_i \, d_{S^3}^2(q, q_i), \qquad
  d_{S^3}(q, q_i) = 2\arccos |\langle q, q_i \rangle|
  \]
Handling the $q \leftrightarrow -q$ antipodal identification is essential for well-posedness [1804.03528][1904.03182].

## 2. Analytical and Algebraic Methods

A classical approach is to maximize
\[
\Delta(q) = \sum_{i=1}^N w_i (q \cdot q_i) = q^\top V, \qquad V \equiv \sum_{i=1}^N w_i q_i
\]
subject to $\|q\| = 1$. The weighted outer-product method constructs the (real symmetric) $4 \times 4$ matrix
\[
A = \sum_{i=1}^N w_i (q_i q_i^\top)
\]
and seeks the principal eigenvector:
\[
\max_{\|q\|=1} q^\top A q
\]
The solution $\bar{q}$ is the normalized eigenvector associated with the largest eigenvalue of $A$. This can be performed efficiently with standard eigensolvers or, for theoretical insights, the eigenproblem can be solved in closed form via quartic (Cardano–Ferrari) algebraic methods [1804.03528]. Block matrix expressions for $A$ directly assemble the computation from quaternion components. In practice, quaternions may be hemisphere-aligned prior to averaging to preserve orientation consistency.

## 3. Riemannian Manifold (Karcher) Approaches

The minimization of the squared geodesic cost on $S^3$ falls into the class of Karcher or Fréchet means on Riemannian manifolds. An explicit fixed-point iteration utilizes the exponential and logarithmic maps on $S^3$:
\[
q_{k+1} = \Exp_{q_k}\left( \frac{1}{W}\sum_{i=1}^N w_i \Log_{q_k}(q_i) \right),\qquad W = \sum_{i=1}^N w_i
\]
where $\Log_{q}(q_i)$ and $\Exp_q(v)$ have closed forms relying on principal angles and tangent space projections. The algorithm typically converges in a few iterations for moderate $N$ and is well-suited for contexts such as deep ensemble networks or sensor fusion where direct probabilistic uncertainty injection in the tangent space is meaningful [1904.03182].

## 4. Dynamical Systems and Gradient-Flow Algorithms

Weighted quaternion averaging can be posed as the equilibrium of a negative gradient flow for a suitably chosen potential function. The non-Abelian Kuramoto model on $\mathrm{SO}(3)$ gives rise to a set of ODEs for $N$ quaternions:
\[
\dot{q}_j = \frac{2}{N}\sum_{i=1}^N w_i \left( q_i - (q_j \cdot q_i) q_j \right)
\]
or, more invariantly,
\[
\dot{q}_j = \frac{2}{N} (I_4 - q_j q_j^\top) \sum_{i=1}^N w_i q_i
\]
Each iteration projects onto $S^3$, and all $q_j$ collapse to a common synchronization state almost globally asymptotically. The discrete-time Euler integration ("KLW quaternion algorithm") is practical, and convergence is tracked via an order parameter $M(t) = \|\frac{1}{N}\sum_i q_i(t)\|$ [2111.11723].

## 5. Weight Selection, Constraints, and Sensor Fusion

Weights $w_i$ determine the influence of each quaternion in the ensemble. In probabilistic estimation, weights can reflect epistemic or aleatoric uncertainty—e.g., inversely proportional to the trace or determinant of predictive covariance [1904.03182]. For physical sensor ensembles, e.g., multiple spatially separated IMUs, weights are determined by solving a quadratic program (QP) that minimizes aggregate measurement noise, enforces convexity ($w^j \geq 0$, $\sum_j w^j = 1$), and cancels lever-arm bias ($\sum_j w^j r^j = 0$). In such sensor fusion frameworks, averaging is not performed directly in quaternion space but on frame-aligned gyroscope and accelerometer measurements, and the resulting rate is integrated to propagate the common orientation [2506.00371]. This avoids direct closed-form expressions for the quaternion mean as a function of the input quaternions and weights in the presence of non-collocated sensors.

## 6. Practical Implementation and Stability Considerations

The eigenvalue-based approach is computationally efficient, requiring $O(N)$ operations to form $A$ and constant-time symmetric eigendecomposition. Fixed-point (Karcher mean) iteration converges rapidly when initialization is close to consensus or when orientations are not near antipodal. Chordal versus geodesic metrics yield nearly indistinguishable results except when orientations are highly dispersed on $S^3$. The dynamical (gradient-flow/Kuramoto) method provably converges for positive-definite weights and is robust against initialization except for a measure zero of degenerate cases [1804.03528][2111.11723].

Direct mean-by-summation ($\bar{q} \propto \sum_i w_i q_i$) following hemisphere-alignment is numerically less stable when sample orientations are broadly distributed due to the loss of convexity on $S^3$. In contrast, the outer-product and gradient-based methods are robust and yield consistent average orientations and covariances.

## 7. Applications and Experimental Outcomes

Weighted quaternion averaging underpins:
- Batch and recursive pose estimation in robotics and vision.
- Sensor fusion involving multiple attitude sources (e.g., multi-IMU arrays), where QP-based weight selection additionally suppresses noise and enforces spatial constraints [2506.00371].
- Probabilistic regression pipelines, with applications in deep learning ensemble methods, which leverage quaternion averaging for rotation prediction and covariance extraction [1904.03182].
- Rotational registration and 3D data alignment in computer vision [1804.03528].

Performance results show that, for sensor fusion, increasing the number of fused IMUs and optimizing weights via QP can reduce rotational mean absolute error (MAE) by approximately 35% and positional MAE by around 20% in simulation, and halve positional error in real-world datasets [2506.00371]. For direct averaging and registration, the eigenvalue-based and gradient-flow methods are observed to match geometric averaging performance and yield robust estimates across a range of datasets [1804.03528][2111.11723].

Source: https://www.emergentmind.com/topics/weighted-quaternion-averaging