Skip to content

Fix full Wiener density underflow - #3435

Open
martonaronvarga wants to merge 1 commit into
stan-dev:developfrom
martonaronvarga:fix/wiener-full-underflow-3329-pr
Open

martonaronvarga wants to merge 1 commit into
stan-dev:developfrom
martonaronvarga:fix/wiener-full-underflow-3329-pr

Conversation

@martonaronvarga

Copy link
Copy Markdown
Contributor

Summary

Fixes #3329.

Adds an automatic log-scaled fallback for the full Wiener density when
natural-scale integration produces a zero, subnormal, or non-finite result.
The public api is unchanged.

Tests

  • Prim Wiener full tests: 23/23 passed
  • Rev Wiener full tests: 5/5 passed
  • Standalone header compilation passed
  • cpplint passed
  • Benchmarks found no measurable slowdown in ordinary support regions

Side Effects

None expected.

Release notes

Fixed underflow in the full Wiener log density and its gradients for extreme
valid parameter values.

Checklist

  • Copyright holder: Marton A. Varga

  • the basic tests are passing

  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

Retry full-model integration with a shared log-density scale when the natural-scale density underflows. Apply the same scale to derivative integrals so reverse-mode ratios remain finite and consistent.

Add primal and reverse-mode regressions for issue stan-dev#3329 across starting-point and nondecision-time variability branches.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@martonaronvarga

martonaronvarga commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

@avehtari This is the PR fixing underflows mentioned in #3329. Unfortunately, I don't have permissions to assign reviewers, so please assign yourself for the time being.

@avehtari avehtari added the numerics Numerical issues label Oct 9, 2026
@avehtari
avehtari self-requested a review October 9, 2026 09:38
@avehtari

avehtari commented Oct 9, 2026

Copy link
Copy Markdown
Member

This doesn't compile for forward or mixed mode.** CI job "mix fun and prob tests 5" fails on all three platforms with 88 errors from three lines:

  • line 852: std::isfinite(density) with var or fvar;
  • line 854: wiener7_log_params{y_value, …}, which narrows T_partials_return to double;
  • line 863: xmin/xmax passed as const Eigen::VectorXd&.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

numerics Numerical issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wiener_lpdf full model returns -inf for valid-support inputs in variability branches

3 participants