Add truncated distribution sampler#2304
Merged
sethrj merged 6 commits intoceleritas-project:developfrom Mar 10, 2026
Merged
Conversation
Test summary 5 930 files 9 549 suites 21m 34s ⏱️ Results for commit 071a9bd. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2304 +/- ##
===========================================
- Coverage 87.23% 87.22% -0.02%
===========================================
Files 1353 1354 +1
Lines 43155 43176 +21
Branches 13165 13171 +6
===========================================
+ Hits 37646 37660 +14
- Misses 4301 4307 +6
- Partials 1208 1209 +1
🚀 New features to boost your workflow:
|
Member
|
@amandalund Coverage test points out that the variant-based code isn't being tested yet. Could you add a quick one? |
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.
This adds a helper class for sampling from an arbitrary distribution restricted to some finite bounds. This is used in a few places where we were sampling from a truncated normal distribution and added as an energy distribution type for the optical primary generator so we can sample from a Gaussian without generating negative energies.
I also removed the rather subtle copy and move operations that allow setting new distribution parameters while possibly keeping or transferring the spare value in the normal distribution. Since we're now generating scintillation photons one at a time, this isn't used anymore (except in the scintillation unit test). If we do ever have another use case where we need to repeatedly generate normally distributed values with different distribution parameters we can always restore this.