5 #include "../../Text/TextTools.h" 6 #include "../NumConstants.h" 7 #include "../Random/RandomTools.h" 24 if (vn.size() <= 0 || vn.size() != valpha.size() - 1)
27 for (
size_t j = 0; j < valpha.size(); j++)
32 for (
size_t j = 0; j < vn.size(); j++)
38 for (
size_t j = 0; j < vn.size(); j++)
48 for (
unsigned int i = 0; i <
vpBDD_.size(); i++)
68 for (
size_t j = 0; j <
vpBDD_.size() + 1; j++)
87 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
90 for (
unsigned int i = j + 1; i < valpha.size(); i++)
98 vpBDD_[j]->matchParametersValues(pL);
109 for (
size_t j = 0; j <
vpBDD_.size(); j++)
111 n *=
vpBDD_[j]->getNumberOfCategories();
121 if (value.size() !=
vpBDD_.size() + 1)
122 throw Exception(
"Bad Vdouble parameter in DirichletDiscreteDistribution::getValueCategory");
127 for (
size_t j = 0; j <
vpBDD_.size(); j++)
132 y =
vpBDD_[j]->getValueCategory(value[j] / (1 - sumc)) * (1 - sumc);
136 vd.push_back(1 - sumc);
144 if (category.size() !=
vpBDD_.size() + 1)
145 throw Exception(
"Bad Vdouble parameter in DirichletDiscreteDistribution::getProbability");
150 for (
size_t j = 0; j <
vpBDD_.size(); j++)
152 p *=
vpBDD_[j]->getProbability(category[j] / (1 - sumc));
166 vdj =
vpBDD_[0]->getCategories();
167 for (
size_t k = 0; k < vdj.size(); k++)
169 vd.push_back(vdj[k]);
174 for (
size_t j = 1; j <
vpBDD_.size(); j++)
176 vdj =
vpBDD_[j]->getCategories();
178 for (
size_t i = 0; i < vvd1.size(); i++)
182 for (
size_t k = 0; k < vd.size(); k++)
186 for (
size_t k = 0; k < vdj.size(); k++)
188 vd.push_back(vdj[k] * (1 - sumc));
197 for (
size_t i = 0; i < vvd1.size(); i++)
201 for (
size_t k = 0; k < vd.size(); k++)
205 vd.push_back(1 - sumc);
218 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
220 x =
vpBDD_[j]->rand() * (1 - sumc);
225 vd.push_back(1 - sumc);
235 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
237 x =
vpBDD_[j]->randC() * (1 - sumc);
242 vd.push_back(1 - sumc);
~DirichletDiscreteDistribution()
Vdouble rand() const
Draw a random vector from this distribution.
This class is designed to facilitate the manipulation of parameters.
void addParameter_(Parameter *parameter)
Discretized Beta distribution with parameters alpha and beta, on a given interval. On default, the interval is , but it can be restricted.
static double VERY_TINY()
virtual void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
double getParameterValue(const std::string &name) const override
Get the value for parameter of name 'name'.
The parameter list object.
Vdouble getValueCategory(Vdouble &Vvalue) const
virtual void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
VVdouble getCategories() const
A partial implementation of the Parametrizable interface.
std::vector< double > Vdouble
DirichletDiscreteDistribution(std::vector< size_t > vn, Vdouble valpha)
Build a new discretized Dirichlet distribution.
virtual double getProbability(Vdouble &category) const
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
virtual void addParameter(const Parameter ¶m)
Add a new parameter at the end of the list.
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Vdouble randC() const
Draw a random vector from the continuous version of this distribution.
std::vector< BetaDiscreteDistribution *> vpBDD_
std::string toString(T t)
General template method to convert to a string.
std::vector< Vdouble > VVdouble
void discretize(Vdouble &valpha)
size_t getNumberOfCategories() const