19 #ifndef RandomDistributor_h 20 #define RandomDistributor_h 71 bool add(T val,
double prob,
bool checkDuplicates =
true) {
74 if (checkDuplicates) {
75 for (
int i = 0; i < (int)
myVals.size(); i++) {
93 for (
int i = 0; i < (int)
myVals.size(); i++) {
111 T
get(std::mt19937* which = 0)
const {
116 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.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
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.
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.