 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
18 #ifndef RandomDistributor_h
19 #define RandomDistributor_h
70 bool add(T val,
double prob,
bool checkDuplicates =
true) {
73 if (checkDuplicates) {
74 for (
int i = 0; i < (int)
myVals.size(); i++) {
95 for (
int i = 0; i < (int)
myVals.size(); i++) {
113 T
get(std::mt19937* which = 0)
const {
118 for (
int i = 0; i < (int)
myVals.size(); i++) {
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
RandomDistributor()
Constructor for an empty distribution.
std::vector< T > myVals
the members
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
~RandomDistributor()
Destructor.
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.
Represents a generic random distribution.
double myProb
the total probability
std::vector< double > myProbs
the corresponding probabilities
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
const std::vector< T > & getVals() const
Returns the members of the distribution.