22 #ifndef RandomDistributor_h 23 #define RandomDistributor_h 78 bool add(T val,
double prob,
bool checkDuplicates =
true) {
81 if (checkDuplicates) {
82 for (
int i = 0; i < (int)
myVals.size(); i++) {
106 for (
int i = 0; i < (int)
myVals.size(); i++) {
std::vector< double > myProbs
the corresponding probabilities
Represents a generic random distribution.
RandomDistributor()
Constructor for an empty distribution.
std::vector< T > myVals
the members
const std::vector< T > & getVals() const
Returns the members of the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
~RandomDistributor()
Destructor.
static double rand()
Returns a random real number in [0, 1)
double myProb
the total probability
void clear()
Clears the distribution.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.