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