EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | List of all members
EGS_SimpleAliasTable Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Member Function Documentation

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().


The documentation for this class was generated from the following files: