Center hypertoroidal wrapped-normal truncation - #4290
Closed
FlorianPfaff wants to merge 17 commits into
Closed
Conversation
Contributor
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining
|
FlorianPfaff
force-pushed
the
agent/center-wrapped-normal-truncation
branch
from
July 13, 2026 16:32
78f2886 to
d2eded0
Compare
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.

Summary
Bug
HypertoroidalWrappedNormalDistribution.pdf()first mapped queries to[-π, π), while constructor means are stored in[0, 2π). It then evaluated truncated Gaussian images around the unwrapped stored mean.For a valid zero-order truncation (
m=0) and a mean above π, a query at the distribution's own mode was therefore compared with the wrong Gaussian image. For example, withmu=5.5andsigma=0.2, the implementation returned approximately9.64e-215at the mode instead of the Gaussian peak1.9947.Fix
Compute the shortest wrapped residual
mod(x - mu + π, 2π) - πfirst, then evaluate the finite image expansion around a zero-mean Gaussian. This makes truncation independent of equivalent angular representations and centers every finite expansion on the nearest image.Validation
9.64e-2151.9947muand the equivalentmu - 2πquery withm=0mainand zero behindThe full multi-backend test matrix is delegated to GitHub Actions because a local repository checkout was unavailable in this environment.