Skip to content

Stabilize discrete-state prior normalization - #4405

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-discrete-prior-normalization-robust
Closed

Stabilize discrete-state prior normalization#4405
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-discrete-prior-normalization-robust

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • normalize finite discrete-state priors after scaling by their largest entry
  • prevent summation overflow from turning valid priors into all-zero vectors
  • add public-API regressions for HMM and IMM state/mode priors near the float64 limit

Root cause

_validated_probability_vector() summed caller-provided probabilities at their original scale. A vector such as [np.finfo(float).max, np.finfo(float).max / 2] contains only finite, non-negative entries, but its sum overflows to infinity. Dividing by that total produces an all-zero prior, and the subsequent filtering recursion fails because no prior mass remains.

Fix

Scale the validated and masked vector by its maximum positive entry before summing. The scaled sum is finite and at least one, while all probability ratios and zero support are preserved.

Validation

Added focused regressions through discrete_forward_backward() and imm_forward_backward() covering state and mode priors at the maximum finite float64 scale.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 24.84s
✅ JSON prettier 7 0 0 0 1.21s
✅ JSON v8r 7 0 0 4.65s
✅ MARKDOWN markdownlint 68 0 0 0 1.94s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.54s
✅ PYTHON black 1542 197 0 0 98.6s
✅ PYTHON isort 1542 366 0 0 2.8s
✅ REPOSITORY betterleaks yes no no 2.62s
✅ REPOSITORY checkov yes no no 56.6s
✅ REPOSITORY gitleaks yes no no 15.45s
✅ REPOSITORY git_diff yes no no 0.43s
✅ REPOSITORY secretlint yes no no 63.71s
✅ REPOSITORY syft yes no no 6.59s
✅ REPOSITORY trivy-sbom yes no no 7.16s
✅ REPOSITORY trufflehog yes no no 32.83s
✅ YAML prettier 11 0 0 0 0.77s
✅ YAML v8r 11 0 0 11.44s
✅ 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 July 14, 2026 20:07
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) July 14, 2026 20:07
@FlorianPfaff
FlorianPfaff force-pushed the agent/stabilize-discrete-prior-normalization-robust branch from 12c3705 to 5f0df7a Compare July 15, 2026 03:51
auto-merge was automatically disabled July 15, 2026 05:04

Pull request was closed

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