Skip to content

Stabilize wrapped Laplace PDFs for extreme skew - #5246

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-wrapped-laplace-skew
Open

Stabilize wrapped Laplace PDFs for extreme skew#5246
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-wrapped-laplace-skew

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

WrappedLaplaceDistribution.pdf(...) formed the skew mixture as

(positive_component + kappa**2 * negative_component) / (1 + kappa**2)

For a large but finite skew parameter, kappa**2 can overflow even though the normalized density is finite. For example, lambda_=1 and kappa=1e200 should be close to the uniform density, but the previous implementation raises under strict NumPy overflow handling (or produces non-finite intermediate values otherwise).

Fix

Evaluate the same normalized mixture in a scale-free form:

  • for kappa <= 1, retain the direct kappa * kappa weighting;
  • for kappa > 1, divide numerator and denominator by kappa**2 and use (1 / kappa) * (1 / kappa).

This avoids squaring a large skew parameter while preserving the ordinary parameter path.

Regression coverage

Add a NumPy regression with kappa=1e200 under strict overflow, invalid, and divide handling. It verifies that the PDF remains finite and approaches 1 / (2*pi) rather than failing during mixture normalization.

Validation

  • reproduced the old overflow encountered in square failure;
  • verified the scale-free calculation returns finite values for two query points;
  • branch comparison: 2 commits ahead and 0 behind main;
  • diff is limited to 30 implementation-line changes and an 18-line focused regression.

GitHub Actions is authoritative for the full backend, lint, packaging, documentation, and integration matrix.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 28.62s
✅ JSON prettier 7 0 0 0 1.23s
✅ JSON v8r 7 0 0 4.57s
✅ MARKDOWN markdownlint 68 0 0 0 1.97s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.48s
✅ PYTHON black 1865 88 0 0 100.73s
✅ PYTHON isort 1865 140 0 0 2.86s
✅ REPOSITORY betterleaks yes no no 2.46s
✅ REPOSITORY checkov yes no no 54.07s
✅ REPOSITORY gitleaks yes no no 18.33s
✅ REPOSITORY git_diff yes no no 0.25s
✅ REPOSITORY secretlint yes no no 87.58s
✅ REPOSITORY syft yes no no 6.15s
✅ REPOSITORY trivy-sbom yes no no 6.4s
✅ REPOSITORY trufflehog yes no no 33.25s
✅ YAML prettier 11 0 0 0 0.7s
✅ YAML v8r 11 0 0 13.18s
✅ YAML yamllint 11 0 0 0.66s

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 marked this pull request as ready for review August 7, 2026 17:56
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:57
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