Kea
1.9.9-git
|
Weighted random integer generator. More...
#include <random_number_generator.h>
Public Member Functions | |
WeightedRandomIntegerGenerator (const std::vector< double > &probabilities, size_t min=0) | |
Constructor. More... | |
WeightedRandomIntegerGenerator () | |
Default constructor. More... | |
size_t | operator() () |
Generate weighted random integer. More... | |
void | reset (const std::vector< double > &probabilities, size_t min=0) |
Reset the probabilities. More... | |
Weighted random integer generator.
Generate random integers according different probabilities
Definition at line 91 of file random_number_generator.h.
|
inline |
Constructor.
probabilities | The probabilities for all the integers, the probability must be between 0 and 1.0, the sum of probabilities must be equal to 1. For example, if the probabilities contains the following values: 0.5 0.3 0.2, the 1st integer will be generated more frequently than the other integers and the probability is proportional to its value. |
min | The minimum integer that generated, other integers will be min, min + 1, ..., min + probabilities.size() - 1 |
Definition at line 102 of file random_number_generator.h.
|
inline |
Default constructor.
Definition at line 119 of file random_number_generator.h.
|
inline |
Generate weighted random integer.
Definition at line 146 of file random_number_generator.h.
|
inline |
Reset the probabilities.
Change the weights of each integers
probabilities | The probabilities for all the integers |
min | The minimum integer that generated |
Definition at line 129 of file random_number_generator.h.