41 #include "../NumConstants.h" 42 #include "../../Utils/MapTools.h" 43 #include "../../Text/TextTools.h" 49 const vector<double>& probas ) :
56 if (distributions.size() != probas.size())
61 size_t size = distributions.size();
62 for (
size_t i = 0; i < size; i++)
64 if (distributions[i] == 0)
68 for (
size_t i = 0; i < size; i++)
78 for (
size_t i = 0; i < size - 1; i++)
85 for (
size_t i = 0; i < size; i++)
87 vdd_.push_back(distributions[i]->
clone());
92 for (
size_t i = 0; i < size; i++)
97 for (
size_t i = 0; i < size; i++)
102 for (
size_t i = 0; i < size; i++)
117 for (
size_t i = 0; i < mdd.
vdd_.size(); i++)
120 vdd_.push_back(mdd.
vdd_[i]->clone());
133 for (
size_t i = 0; i < mdd.
vdd_.size(); i++)
136 vdd_.push_back(mdd.
vdd_[i]->clone());
145 for (
size_t i = 0; i <
vdd_.size(); i++)
155 for (
size_t i = 0; i <
vdd_.size(); i++)
157 vdd_[i]->setNumberOfCategories(nbClasses);
167 size_t size =
vdd_.size();
169 for (
size_t i = 0; i < size - 1; i++)
178 for (
size_t i = 0; i < size; i++)
180 vdd_[i]->matchParametersValues(parameters);
188 size_t size =
vdd_.size();
192 for (
size_t i = 0; i < size; i++)
194 vector<double> values =
vdd_[i]->getCategories();
195 for (
size_t j = 0; j < values.size(); j++)
201 for (
size_t i = 0; i < size; i++)
203 vector<double> values =
vdd_[i]->getCategories();
204 vector<double> probas2 =
vdd_[i]->getProbabilities();
205 for (
size_t j = 0; j < values.size(); j++)
219 bool suB =
true, slB =
true;
221 for (
size_t i = 0; i < size; i++)
225 lB =
vdd_[i]->getLowerBound();
226 slB =
vdd_[i]->strictLowerBound();
230 uB =
vdd_[i]->getUpperBound();
231 suB =
vdd_[i]->strictUpperBound();
239 vector<double> values = MapTools::getKeys<double, double, AbstractDiscreteDistribution::Order>(
distribution_);
246 bounds_[i] = (values[i] + values[i + 1]) / 2.;
255 for (
size_t i = 0; i <
vdd_.size(); i++)
257 vdd_[i]->setMedian(median);
264 for (
size_t i = 0; i <
vdd_.size(); i++)
266 vdd_[i]->discretize();
275 for (
size_t i = 0; i <
vdd_.size(); i++)
284 throw Exception(
"MixtureOfDiscreteDistributions::qProb to difficult to compute: not implemented");
291 for (
size_t i = 0; i <
vdd_.size(); i++)
300 for (
size_t i = 0; i <
vdd_.size(); i++)
302 vdd_[i]->restrictToConstraint(c);
314 for (
size_t i = 0; i <
vdd_.size(); i++)
MixtureOfDiscreteDistributions & operator=(const MixtureOfDiscreteDistributions &mdd)
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
~MixtureOfDiscreteDistributions()
void setNumberOfCategories(size_t nbClasses)
sets the number of categories of EACH submodel to nbClasses, so the number of categories of the mixtu...
Partial implementation of the DiscreteDistribution interface.
This class allows to perform a correspondence analysis.
void setLowerBound(double lowerBound, bool strict)
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
This class is designed to facilitate the manipulation of parameters.
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
void addParameter_(Parameter *parameter)
void updateDistribution()
void restrictToConstraint(const Constraint &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
static std::string toString(T t)
General template method to convert to a string.
A Discrete distribution object defined by a vector of Discrete Distributions and a set of probabiliti...
The parameter list object.
AbstractDiscreteDistribution & operator=(const AbstractDiscreteDistribution &adde)
A partial implementation of the Parametrizable interface.
void addParameters_(const ParameterList ¶meters)
double getLowerBound() const
methods about the range of the definition
The constraint interface.
std::map< double, double, Order > distribution_
MixtureOfDiscreteDistributions(const std::vector< DiscreteDistribution *> &distributions, const std::vector< double > &probas)
Builds a new MixtureOfDiscreteDistributions object from a vector of Discrete Distributions and a vect...
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
double getUpperBound() const
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 const IntervalConstraint PROP_CONSTRAINT_IN
const ParameterList & getParameters() const
Get all parameters available.
void setUpperBound(double upperBound, bool strict)
std::vector< DiscreteDistribution * > vdd_
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
MixtureOfDiscreteDistributions * clone() const
Create a copy of this object and send a pointer to it.
void discretize()
Discretizes the distribution in equiprobable classes.
std::string getNamespace() const
std::vector< double > probas_
IntervalConstraint intMinMax_
the interval where the distribution is defined/restricted.
std::vector< std::string > vNestedPrefix_
size_t numberOfCategories_
double getParameterValue(const std::string &name) const
Get the value for parameter of name 'name'.
std::vector< double > bounds_