Feature/truncated gaussian#1150
Merged
Jammy2211 merged 48 commits intofeature/jax_wrapperfrom Jun 24, 2025
Merged
Conversation
added 30 commits
June 19, 2025 21:13
added 15 commits
June 23, 2025 14:02
rhayes777
approved these changes
Jun 23, 2025
Collaborator
rhayes777
left a comment
There was a problem hiding this comment.
Nice how well does the truncated version work?
| database_aggregator, | ||
| output_directory, | ||
| ): | ||
| print((output_directory / "database.info").read_text()) |
Collaborator
There was a problem hiding this comment.
forgotten print statement
| # x_, a_, b_, c_, z_ = variables("x, a, b, c, z") | ||
| # x = np.arange(10.0).reshape(5, 2) | ||
| # a = np.arange(2.0).reshape(2, 1) | ||
| # b = np.ones(1) |
Collaborator
There was a problem hiding this comment.
lol core mp tests out of action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description: Implementation of a Truncated Gaussian Prior with Hard Limits
Previously, limits on Gaussian priors (and other priors) were implemented as soft bounds defined by
lower_limitandupper_limitattributes. When sampling from these priors, it was possible for drawn parameter values to fall outside the specified limits. In such cases,autofitperformed a runtime check, and if the sampled value violated the limits, aFitExceptionwas raised, triggering a resampling of the model. This approach introduced inefficiencies due to potentially many rejected samples and less robust sampling behavior near the bounds.Changes Introduced by This PR
New
TruncatedGaussianPriorclass:This class implements a Gaussian prior truncated between strict lower and upper bounds. Instead of sampling freely and then rejecting values outside the limits, this prior explicitly restricts the parameter space, normalizing the distribution within the truncated interval. This results in:
Support for prior passing:
The truncated Gaussian prior is now used in scenarios where prior parameters are updated or passed between model fits. For example, when a model-fit returns posterior estimates, these can be used to create new priors centered on the estimated median with limits reflecting credible intervals. Using a truncated Gaussian ensures the new prior accurately reflects the constrained parameter space without introducing invalid samples.
Benefits and Impact
FitExceptionerrors due to out-of-bound samples.JAX
The primary motivation of this PR is JAX, as the resampling API required annoying if loops which are no longer present as they are built into parameter mapping.