5 #ifndef BPP_NUMERIC_PROB_ABSTRACTDISCRETEDISTRIBUTION_H 6 #define BPP_NUMERIC_PROB_ABSTRACTDISCRETEDISTRIBUTION_H 10 #include "../AbstractParameterAliasable.h" 11 #include "../Constraints.h" 46 precision_(ord.precision_)
128 void set(
double category,
double probability);
129 void add(
double category,
double probability);
135 double randC()
const {
throw Exception(
"AbstractDiscreteDistribution::randC. No continuous version available for this distribution."); }
143 if (i >= numberOfCategories_ - 1)
155 return intMinMax_->getLowerBound();
160 return intMinMax_->getUpperBound();
165 return intMinMax_->strictLowerBound();
170 return intMinMax_->strictUpperBound();
177 double precision()
const {
return distribution_.key_comp().precision();}
181 if (median_ != median)
205 #endif // BPP_NUMERIC_PROB_ABSTRACTDISCRETEDISTRIBUTION_H
double getInfCumulativeProbability(double category) const
double getCategory(size_t categoryIndex) const
Comparator class for AbstractDiscreteDistribution.
virtual void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
Vdouble getBounds() const
static short DISCRETIZATION_EQUAL_INTERVAL
Partial implementation of the DiscreteDistribution interface.
short discretizationScheme_
double getIInfCumulativeProbability(double category) const
The constraint interface.
double getSSupCumulativeProbability(double category) const
double getSupCumulativeProbability(double category) const
bool strictLowerBound() const
double getBound(size_t i) const
void add(double category, double probability)
Modify the probability associated to a class.
double randC() const
Draw a random number from the continuous version of this distribution, if it exists.
Vdouble getProbabilities() const
Interface for discrete distribution objects.
double getProbability(size_t categoryIndex) const
size_t getNumberOfCategories() const
bool operator()(double l1, double l2) const
std::shared_ptr< IntervalConstraint > intMinMax_
the interval where the distribution is defined/restricted.
A partial implementation of the Parametrizable interface.
void print(OutputStream &out) const
Print the distribution (categories and corresponding probabilities) to a stream.
double rand() const
Draw a random number from this distribution.
void setMedian(bool median)
Sets the median value to true to say that the value in a class is proportional to the median value of...
static short DISCRETIZATION_EQUAL_PROB_WHEN_POSSIBLE
void setPrecision(double prec)
AbstractDiscreteDistribution(size_t nbClasses, const std::string &prefix="", short discretization=DISCRETIZATION_EQUAL_PROB)
double getLowerBound() const
methods about the range of the definition
static short DISCRETIZATION_EQUAL_PROB
std::vector< double > Vdouble
std::map< double, double, Order > distribution_
virtual void discretize()
Discretizes the distribution in equiprobable classes.
virtual ~AbstractDiscreteDistribution()
void discretizeEqualProportions()
double getUpperBound() const
bool strictUpperBound() const
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
void setNumberOfCategories(size_t nbClasses)
sets the number of categories and discretizes if there is a change in this number.
Order & operator=(const Order &ord)
double getValueCategory(double value) const
Vdouble getCategories() const
Index out of bounds exception class.
Order(double prec=NumConstants::TINY())
void discretizeEqualIntervals()
size_t numberOfCategories_
size_t getCategoryIndex(double value) const
std::vector< double > bounds_