42 #include "../../Text/TextTools.h"
43 #include "../NumConstants.h"
44 #include "../Random/RandomTools.h"
61 if (vn.size() <= 0 || vn.size() != valpha.size() - 1)
64 for (
size_t j = 0; j < valpha.size(); j++)
69 for (
size_t j = 0; j < vn.size(); j++)
75 for (
size_t j = 0; j < vn.size(); j++)
85 for (
unsigned int i = 0; i <
vpBDD_.size(); i++)
105 for (
size_t j = 0; j <
vpBDD_.size() + 1; j++)
124 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
127 for (
unsigned int i = j + 1; i < valpha.size(); i++)
135 vpBDD_[j]->matchParametersValues(pL);
146 for (
size_t j = 0; j <
vpBDD_.size(); j++)
148 n *=
vpBDD_[j]->getNumberOfCategories();
158 if (value.size() !=
vpBDD_.size() + 1)
159 throw Exception(
"Bad Vdouble parameter in DirichletDiscreteDistribution::getValueCategory");
164 for (
size_t j = 0; j <
vpBDD_.size(); j++)
169 y =
vpBDD_[j]->getValueCategory(value[j] / (1 - sumc)) * (1 - sumc);
173 vd.push_back(1 - sumc);
181 if (category.size() !=
vpBDD_.size() + 1)
182 throw Exception(
"Bad Vdouble parameter in DirichletDiscreteDistribution::getProbability");
187 for (
size_t j = 0; j <
vpBDD_.size(); j++)
189 p *=
vpBDD_[j]->getProbability(category[j] / (1 - sumc));
203 vdj =
vpBDD_[0]->getCategories();
204 for (
size_t k = 0; k < vdj.size(); k++)
206 vd.push_back(vdj[k]);
211 for (
size_t j = 1; j <
vpBDD_.size(); j++)
213 vdj =
vpBDD_[j]->getCategories();
215 for (
size_t i = 0; i < vvd1.size(); i++)
219 for (
size_t k = 0; k < vd.size(); k++)
223 for (
size_t k = 0; k < vdj.size(); k++)
225 vd.push_back(vdj[k] * (1 - sumc));
234 for (
size_t i = 0; i < vvd1.size(); i++)
238 for (
size_t k = 0; k < vd.size(); k++)
242 vd.push_back(1 - sumc);
255 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
257 x =
vpBDD_[j]->rand() * (1 - sumc);
262 vd.push_back(1 - sumc);
272 for (
unsigned int j = 0; j <
vpBDD_.size(); j++)
274 x =
vpBDD_[j]->randC() * (1 - sumc);
279 vd.push_back(1 - sumc);
A partial implementation of the Parametrizable interface.
void addParameter_(Parameter *parameter)
virtual void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
double getParameterValue(const std::string &name) const
Get the value for parameter of name 'name'.
Discretized Beta distribution with parameters alpha and beta, on a given interval....
~DirichletDiscreteDistribution()
Vdouble randC() const
Draw a random vector from the continuous version of this distribution.
DirichletDiscreteDistribution(std::vector< size_t > vn, Vdouble valpha)
Build a new discretized Dirichlet distribution.
Vdouble rand() const
Draw a random vector from this distribution.
size_t getNumberOfCategories() const
VVdouble getCategories() const
std::vector< BetaDiscreteDistribution * > vpBDD_
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
virtual double getProbability(Vdouble &category) const
void discretize(Vdouble &valpha)
Vdouble getValueCategory(Vdouble &Vvalue) const
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
static double VERY_TINY()
The parameter list object.
virtual void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
virtual void addParameter(const Parameter ¶m)
Add a new parameter at the end of the list.
This class is designed to facilitate the manipulation of parameters.
std::string toString(T t)
General template method to convert to a string.
std::vector< double > Vdouble
std::vector< Vdouble > VVdouble