Repository navigation
Fix apply weights linearly in _average_quats - #14496
Merged
Merged
Conversation
ChenziqiAdam
requested review from
agramfort,
drammock and
larsoner
as code owners
November 5, 2026 09:17
larsoner
approved these changes
Nov 5, 2026
larsoner
enabled auto-merge (squash)
November 5, 2026 17:17
|
🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue (if any)
Fixes #14478.
What does this implement/fix?
_average_quats(used bycompute_average_dev_head_t) scaled each quaternion by its weight before forming the outer products, so the matrix being decomposed wassum_i w_i^2 q_i q_i^Trather than thesum_i w_i q_i q_i^Tof the Markley et al. method. The rotation was therefore averaged with squared weights, while the translation used linear weights.This PR scales each quaternion by
sqrt(w_i)instead. For the example in the issue, the averaged rotation angle changes from 0.1801 rad to 0.1501 rad, consistent with the time-weighted mean translation.I extended the existing
test_average_quatswith a weighted case.Additional information
AI disclosure: I used Claude Code to help draft the fix and the test assertion, and I reviewed the changes myself.