EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
A class for sampling random bins from a given probability distribution using the alias table technique. More...
#include <egs_alias_table.h>
Public Member Functions | |
EGS_SimpleAliasTable (int N, const EGS_Float *f) | |
Constructor. More... | |
~EGS_SimpleAliasTable () | |
Destructor. | |
int | sample (EGS_RandomGenerator *rndm) const |
Sample a random bin. More... | |
A class for sampling random bins from a given probability distribution using the alias table technique.
Instances of this class can be used to efficiently sample random bins from any probability distribution. This is a special case of the more general EGS_AliasTable class that has a more efficient implementation and is easier to use when only sampling random bin indeces is needed
Definition at line 182 of file egs_alias_table.h.
EGS_SimpleAliasTable::EGS_SimpleAliasTable | ( | int | N, |
const EGS_Float * | f | ||
) |
Constructor.
Construct a simple alias table having N
bins with probabilities given by the array f
Definition at line 302 of file egs_alias_table.cpp.
References egsFatal, egsWarning, epsilon, and loopMax.
int EGS_SimpleAliasTable::sample | ( | EGS_RandomGenerator * | rndm | ) | const |
Sample a random bin.
Returns a random bin according to the bin probabilities for this alias table
Definition at line 200 of file egs_alias_table.h.
References EGS_RandomGenerator::getUniform().
Referenced by EGS_ConicalShellStackShape::getPoint().