5 #include "../NumConstants.h" 6 #include "../VectorTools.h" 27 for (
auto& p : probas)
36 for (
size_t i = 0; i <
dim_ - 1; i++)
43 for (
size_t i = 0; i < dim_ - 1; i++)
47 for (
size_t i = 0; i < dim_ - 1; i++)
53 for (
size_t i = 1; i <
dim_; i++)
63 double i1 = 0, i0 = 0;
65 size_t pi = i & ~(1 << (li2 - 1));
68 size_t t = (j << li2) + pi;
73 t += (1 << (li2 - 1));
84 Simplex::Simplex(
size_t dim,
unsigned short method,
bool allowNull,
const std::string& name) :
94 for (
size_t i = 0; i <
dim_; i++)
96 vProb_.push_back(1. / static_cast<double>(dim_));
105 for (
size_t i = 0; i < dim_ - 1; i++)
112 for (
size_t i = 0; i < dim_ - 1; i++)
116 for (
size_t i = 0; i < dim_ - 1; i++)
122 for (
size_t i = 0; i < dim_ - 1; i++)
142 for (
unsigned int i = 0; i <
dim_ - 1; i++)
151 for (
unsigned int i = 0; i < dim_ - 1; i++)
159 for (
unsigned int i = 0; i < dim_ - 1; i++)
172 for (
auto& vp : vProb_)
174 vp = 1.0 / double(dim_);
186 for (
size_t i = 0; i <
dim_; i++)
197 if ((k + (1 << (ld - 1))) < dim_)
224 for (
unsigned int i = 0; i <
dim_ - 1; i++)
231 for (
unsigned int i = 0; i < dim_ - 1; i++)
234 valpha_[i] = probas[i + 1] / probas[i];
238 for (
size_t i = 1; i <
dim_; i++)
248 double i1 = 0, i0 = 0;
250 size_t pi = i & ~(1 << (li2 - 1));
253 size_t t = (j << li2) + pi;
258 t += (1 << (li2 - 1));
275 Simplex(probas.size(), method, allowNull, name),
286 auto dim = probs.size();
289 for (
auto i = dim; i > 0; i--)
291 x += probs[i - 1] / (int)i;
300 auto dim = vValues.size();
303 for (
size_t i = 0; i < dim - 1; ++i)
305 vprob[i] =
static_cast<double>(i + 1) * (vValues[i] - vValues[i + 1]);
308 vprob[dim - 1] =
static_cast<double>(dim) * vValues[dim - 1];
void setFrequencies(const std::vector< double > &)
std::string getNamespace() const override
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
const std::vector< double > & getFrequencies() const
void fireParameterChanged(const ParameterList ¶meters)
Notify the class when one or several parameters have changed.
std::vector< double > vProb_
This class is designed to facilitate the manipulation of parameters.
void addParameter_(Parameter *parameter)
std::vector< double > vValues_
size_t dim_
The dimension+1 of the space simplex (ie the number of probabilities).
double getParameterValue(const std::string &name) const override
Get the value for parameter of name 'name'.
OrderedSimplex(size_t dim, unsigned short method=0, bool allowNull=false, const std::string &name="Simplex.")
Builds a new Simplex object from a number of probabilities. They are initialized equal.
A Simplex object, used to define sets of probabilities that sum 1.
The parameter list object.
A partial implementation of the Parametrizable interface.
bool matchParametersValues(const ParameterList ¶meters) override
Update the parameters from parameters.
std::vector< double > valpha_
just used with local ratio (method 2)
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_EX
Simplex(size_t dim, unsigned short method=0, bool allowNull=false, const std::string &name="Simplex.")
Builds a new Simplex object from a number of probabilities. They are initialized equal.
std::vector< double > Vdouble
static const std::shared_ptr< IntervalConstraint > PROP_CONSTRAINT_IN
void setFrequencies(const std::vector< double > &)
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)
std::string toString(T t)
General template method to convert to a string.
unsigned short method_
the method of parametrization.