38 #ifndef EGS_ALIAS_TABLE_
39 #define EGS_ALIAS_TABLE_
45 typedef EGS_Float(*EGS_AtFunction)(EGS_Float,
void *);
95 int Type = 1) : n(0) {
96 initialize(N,x,f,Type);
111 EGS_AtFunction func,
void *data) : n(0) {
112 initialize(xmin,xmax,accu,nmax,func,data);
119 void initialize(
int N,
const EGS_Float *x,
const EGS_Float *f,
131 int initialize(EGS_Float xmin, EGS_Float xmax, EGS_Float accu,
int nmax,
132 EGS_AtFunction func,
void *data);
165 void allocate(
int N,
int Type);
203 return rndm->
getUniform() < wi[bin] ? bin : bins[bin];
A class for sampling random values from a given probability distribution using the alias table techni...
EGS_Float getMaximum() const
Get the maximum abscissa of this alias table object.
EGS_AliasTable()
Construct an empty (uninitialized) alias table.
EGS_AliasTable(const EGS_AliasTable &t)
Copy constructor. Performs a deep copy.
EGS_AliasTable(int N, const EGS_Float *x, const EGS_Float *f, int Type=1)
Construct an alias table from the tabulated distribution with N bins with probabilities f at the bins...
EGS_Float getAverage() const
Get the average of the probability distribution represented by this alias table object.
EGS_AliasTable(EGS_Float xmin, EGS_Float xmax, EGS_Float accu, int nmax, EGS_AtFunction func, void *data)
Construct an alias table for sampling values in the interval xmin ... xmax for the function func.
Base random number generator class. All random number generators should be derived from this class.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
A class for sampling random bins from a given probability distribution using the alias table techniqu...
int sample(EGS_RandomGenerator *rndm) const
Sample a random bin.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_RandomGenerator class header file.