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