This class implements the Walker-Vose Alias Sampling method.
The initializing weights do not have to be normalized. The algorithm is described here
The class does not store the probabilities themselves. Look to AliasSampler_t for this additional feature.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(shared_array_real_t), | private | :: | bias |
this is the table of bias |
|||
type(shared_array_int32_t), | private | :: | alias |
this is the lookup table for the resulting random number |
constructor
pseudo-constructor for alias tables
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasTable_t), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | rank_with_info |
The intra-node rank that contains the weights to be used all other arr of all other ranks are ignored (and can be allocated with size 0). |
||
real(kind=dp), | intent(in) | :: | arr(:) |
arr array containing the (not necessarily normalized) probabilities we want to use for sampling |
only compute the data, without allocation
Set the bias and alias values for each value in range @param[in] arr - array containing the (not necessarily normalized) probabilities we want to use for sampling
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasTable_t), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | rank_with_info |
The intra-node rank that contains the weights to be used all other arr of all other ranks are ignored (and can be allocated with size 0). |
||
real(kind=dp), | intent(in) | :: | arr(:) |
destructor - final would be suited better, but is not supported by all compilers
clear the memory used by the alias table
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasTable_t), | intent(inout) | :: | this |
get a random value from the alias table
Draw a random number from an alias table created with the corresponding probabilities @return ind random number between 1 and the size of the array used to create the aliasTable object
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasTable_t), | intent(in) | :: | this |