celeritas-project / celeritas

Celeritas is a new Monte Carlo transport code designed to accelerate scientific discovery in high energy physics by improving detector simulation throughput and energy efficiency using GPUs.
https://celeritas-project.github.io/celeritas/
Other
65 stars 35 forks source link

Refactor rejection sampling using a helper class #1354

Closed sethrj closed 3 months ago

sethrj commented 3 months ago

This defines a RejectionSampler class that can be used as a more intuitive replacement for BernoulliDistribution during rejection sampling loops. Instead of "accepting" when the sample is within bounds (necessitating an easy-to-miss negation in the while condition) we "reject" by returning true unless the sampled value is accepted.