68 bool add(T val,
double prob,
bool checkDuplicates =
true) {
71 if (checkDuplicates) {
72 for (
int i = 0; i < (int)
myVals.size(); i++) {
93 for (
int i = 0; i < (int)
myVals.size(); i++) {
116 for (
int i = 0; i < (int)
myVals.size(); i++) {
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
~RandomDistributor()
Destructor.
double myProb
the total probability
std::vector< double > myProbs
the corresponding probabilities
T get(SumoRNG *which=nullptr) const
Draw a sample of the distribution.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
bool remove(T val)
Removes a value with an assigned probability from the distribution.
void clear()
Clears the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
std::vector< T > myVals
the members
RandomDistributor()
Constructor for an empty distribution.