Skip to content

Center hypertoroidal wrapped-normal truncation - #4290

Closed
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/center-wrapped-normal-truncation
Closed

Center hypertoroidal wrapped-normal truncation#4290
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/center-wrapped-normal-truncation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • center the finite wrapped-image expansion on the shortest residual between each query and the distribution mean
  • preserve periodic equivalence when the stored mean and query use different angular representatives
  • add a regression for zero-order truncation at a mean above π

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, with mu=5.5 and sigma=0.2, the implementation returned approximately 9.64e-215 at the mode instead of the Gaussian peak 1.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

  • isolated numerical reproduction confirms the pre-fix mode value is approximately 9.64e-215
  • the corrected calculation returns approximately 1.9947
  • regression checks both mu and the equivalent mu - 2π query with m=0
  • branch is two commits ahead of current main and zero behind

The full multi-backend test matrix is delegated to GitHub Actions because a local repository checkout was unavailable in this environment.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 21.64s
✅ JSON prettier 7 0 0 0 0.93s
✅ JSON v8r 7 0 0 5.39s
✅ MARKDOWN markdownlint 68 0 0 0 1.63s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.82s
✅ PYTHON black 1490 182 0 0 89.52s
✅ PYTHON isort 1490 328 0 0 2.14s
✅ REPOSITORY betterleaks yes no no 2.47s
✅ REPOSITORY checkov yes no no 50.66s
✅ REPOSITORY gitleaks yes no no 13.61s
✅ REPOSITORY git_diff yes no no 0.26s
✅ REPOSITORY secretlint yes no no 57.4s
✅ REPOSITORY syft yes no no 6.49s
✅ REPOSITORY trivy-sbom yes no no 6.93s
✅ REPOSITORY trufflehog yes no no 30.13s
✅ YAML prettier 11 0 0 0 0.68s
✅ YAML v8r 11 0 0 10.95s
✅ YAML yamllint 11 0 0 0.47s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

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 FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff force-pushed the agent/center-wrapped-normal-truncation branch from 78f2886 to d2eded0 Compare July 13, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant