41 #include "../NumConstants.h" 42 #include "../../Utils/MapTools.h" 43 #include "../../Text/TextTools.h" 57 for (map<double, double>::const_iterator i = distribution.begin(); i != distribution.end(); i++)
69 for (map<double, double>::const_iterator i = distribution.begin(); i != distribution.end(); i++)
86 const vector<double>& probas,
94 if (values.size() != probas.size())
98 size_t size = values.size();
100 for (
size_t i = 0; i < size; i++)
103 throw Exception(
"SimpleDiscreteDistribution: two given values are equal");
115 for (
unsigned int i = 0; i < size - 1; i++)
128 const std::map<
size_t, std::vector<double> >& ranges,
129 const std::vector<double>& probas,
136 if (values.size() != probas.size())
140 size_t size = values.size();
142 for (
size_t i = 0; i < size; i++)
145 throw Exception(
"SimpleDiscreteDistribution: two given values are equal");
157 for (
size_t i = 0; i < size - 1; i++)
159 map<size_t, vector<double> >::const_iterator it = ranges.find(i + 1);
160 if (it == ranges.end())
164 if (values[i] >= it->second[0] && values[i] <= it->second[1])
176 map<size_t, vector<double> >::const_iterator it = ranges.find(size);
177 if (it == ranges.end())
181 if (values[size - 1] >= it->second[0] && values[size - 1] <= it->second[1])
198 givenRanges_(sdd.givenRanges_)
220 for (
size_t i = 0; i < size - 1; i++)
307 vector<double> values = MapTools::getKeys<double, double, AbstractDiscreteDistribution::Order>(
distribution_);
312 bounds_[i] = (values[i] + values[i + 1]) / 2.;
324 throw Exception(
"SimpleDiscreteDistribution::restrictToConstraint: Non-interval exception");
326 map<double, double>::const_iterator it;
337 for (
size_t i = 0; i < size; i++)
339 map<size_t, vector<double> >::const_iterator itr =
givenRanges_.find(i + 1);
virtual const Constraint * removeConstraint()
Remove the constraint associated to this parameter.
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
Partial implementation of the DiscreteDistribution interface.
std::map< size_t, std::vector< double > > givenRanges_
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
An interval, either bounded or not, which can also have infinite bounds.
This class allows to perform a correspondence analysis.
virtual bool isCorrect(double value) const
Tell if a given value is correct.
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
IntervalConstraint * clone() const
Create a copy of this object and send a pointer to it.
SimpleDiscreteDistribution & operator=(const SimpleDiscreteDistribution &)
This class is designed to facilitate the manipulation of parameters.
void addParameter_(Parameter *parameter)
size_t getNumberOfParameters() const
Get the number of parameters.
static std::string toString(T t)
General template method to convert to a string.
The parameter list object.
A Discrete distribution object, where some specific probabilities are assigned to a finite set of val...
void restrictToConstraint(const Constraint &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
AbstractDiscreteDistribution & operator=(const AbstractDiscreteDistribution &adde)
A partial implementation of the Parametrizable interface.
void discretize()
Discretizes the distribution in equiprobable classes.
virtual void setConstraint(Constraint *constraint, bool attach=false)
Set a constraint to this parameter.
The constraint interface.
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
std::map< double, double, Order > distribution_
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
SimpleDiscreteDistribution(const std::map< double, double > &distribution, double precision=NumConstants::TINY(), bool fixed=false)
Builds a new SimpleDiscreteDistribution object from a map<double,double> object. With this constructo...
static const IntervalConstraint PROP_CONSTRAINT_IN
Parameter & getParameter_(const std::string &name)
double getUpperBound() const
IntervalConstraint intMinMax_
the interval where the distribution is defined/restricted.
size_t numberOfCategories_
double getParameterValue(const std::string &name) const
Get the value for parameter of name 'name'.
virtual void restrictToConstraint(const Constraint &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
std::vector< double > bounds_