New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add random selector helper class #217
Conversation
This will be used by the random Selector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice additions, @sethrj! Looks good to me.
v -= i; | ||
return v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the advantage of the code use over 'just'
return v - i;
since 'v' does not appear to be a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires defining an extra operator for the detail iterator
This may be a bit over-engineered, but it abstracts the selection of a discrete PDF that's calculated on-the-fly. I'd intended to use it for the ElementSelector, Livermore, and AtomicRelaxation; but the element selector would be ugly (either re-instantiating the Selector at each sample, or requiring ugly templates to make it class data, or rephrasing it to be a function), and the Livermore/Atomic cases allow a "remainder" for the PDFs -- it's OK if they don't add up to one.
Regardless of those absences, I've implemented the selector in PhysicsStepUtils (which makes the code much cleaner) and replaced the awkward construction in the Rayleigh sampler with the simpler Selector. It is slightly less efficient (requiring one more subtraction) but I can't imagine that being a big deal.
For the purpose of testing, I wrote a SequenceEngine that allows us to use an arbitrary "random" number sequence that enables fine-grained testing of random distributions, and could also be used in our Interactor tests to make sure all of the rejection cases behave exactly as expected.