Skip to content

Preserve HSSSD PDF periodicity across multiple turns - #4282

Closed
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/wrap-hsssd-conditional-distance-20260713
Closed

Preserve HSSSD PDF periodicity across multiple turns#4282
FlorianPfaff wants to merge 17 commits into
mainfrom
agent/wrap-hsssd-conditional-distance-20260713

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • wrap hypercylindrical subdivision grid deltas modulo before conditional-component selection
  • use the same shortest-arc distance convention as HypertoroidalGridDistribution
  • add a focused regression for equivalent angles separated by two full turns

Bug

HypercylindricalStateSpaceSubdivisionDistribution.pdf() evaluates a periodic marginal and a grid-conditioned linear density. The periodic marginal already wraps arbitrary angles correctly, but the conditional selector computed

minimum(abs_delta**2, (2 * pi - abs_delta) ** 2)

without first reducing abs_delta modulo .

That expression only represents the shortest toroidal arc while the raw difference is within one revolution. For a grid with points at 0 and π, a query at 0.1 selected the first conditional, while the equivalent query at 0.1 + 4π selected the second. The joint PDF therefore violated periodicity even though its periodic marginal did not.

Fix

Reduce absolute angular differences modulo , then compute the shortest wrapped distance before selecting the nearest conditional distribution. This matches the established implementation in HypertoroidalGridDistribution.get_closest_point() and value_of_closest().

Validation

  • isolated numerical reproduction confirms the pre-fix selector maps 0.1 and 0.1 + 4π to different grid indices
  • the corrected selector maps both queries to the same index
  • regression uses distinct Gaussian conditionals and verifies equal joint densities for those equivalent angles
  • modified source and regression modules pass python -m py_compile
  • branch is two commits ahead of current main, zero behind
  • final diff is limited to 4 additions/5 deletions in the implementation and one 45-line regression file

The full repository test matrix is delegated to GitHub Actions.

@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 19.35s
✅ JSON prettier 7 0 0 0 0.93s
✅ JSON v8r 7 0 0 4.11s
✅ MARKDOWN markdownlint 68 0 0 0 1.65s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.8s
✅ PYTHON black 1490 182 0 0 87.5s
✅ PYTHON isort 1490 327 0 0 2.52s
✅ REPOSITORY betterleaks yes no no 1.98s
✅ REPOSITORY checkov yes no no 54.09s
✅ REPOSITORY gitleaks yes no no 14.37s
✅ REPOSITORY git_diff yes no no 0.26s
✅ REPOSITORY secretlint yes no no 63.37s
✅ REPOSITORY syft yes no no 5.49s
✅ REPOSITORY trivy-sbom yes no no 5.37s
✅ REPOSITORY trufflehog yes no no 31.1s
✅ YAML prettier 11 0 0 0 0.68s
✅ YAML v8r 11 0 0 10.76s
✅ YAML yamllint 11 0 0 0.56s

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/wrap-hsssd-conditional-distance-20260713 branch from 3cc28c1 to f308393 Compare July 13, 2026 16:38
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