bpp-core3  3.0.0
TruncatedExponentialDiscreteDistribution.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "../../Utils/MapTools.h"
6 #include "../Random/RandomTools.h"
8 
9 using namespace bpp;
10 
11 // From the STL:
12 #include <cmath>
13 
14 using namespace std;
15 
19  AbstractDiscreteDistribution(n, "TruncExponential."),
20  lambda_(lambda),
21  tp_(truncationPoint),
22  cond_(1 - exp(-lambda_ * tp_))
23 {
24  addParameter_(new Parameter("TruncExponential.tp", truncationPoint, Parameter::R_PLUS));
25  addParameter_(new Parameter("TruncExponential.lambda", lambda, Parameter::R_PLUS));
26 
27  intMinMax_->setLowerBound(0, true);
28  intMinMax_->setUpperBound(tp_, false);
29 
30  discretize();
31 }
32 
33 /******************************************************************************/
34 
36 {
38  lambda_ = getParameterValue("lambda");
39  tp_ = getParameterValue("tp");
40 
41  intMinMax_->setUpperBound(tp_, false);
42  cond_ = 1 - exp(-lambda_ * tp_);
43 
44  discretize();
45 }
46 
47 /******************************************************************************/
48 
50 {
53 }
static const std::shared_ptr< IntervalConstraint > R_PLUS
Definition: Parameter.h:307
virtual void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
Partial implementation of the DiscreteDistribution interface.
The constraint interface.
Definition: Constraints.h:28
STL namespace.
This class is designed to facilitate the manipulation of parameters.
Definition: Parameter.h:97
void addParameter_(Parameter *parameter)
virtual void setConstraint(std::shared_ptr< ConstraintInterface > constraint)
Set a constraint to this parameter.
Definition: Parameter.cpp:76
double getParameterValue(const std::string &name) const override
Get the value for parameter of name &#39;name&#39;.
The parameter list object.
Definition: ParameterList.h:27
virtual void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
std::shared_ptr< IntervalConstraint > intMinMax_
the interval where the distribution is defined/restricted.
TruncatedExponentialDiscreteDistribution(size_t n, double lambda=1., double truncationPoint=10)
Build a new truncated exponential discrete distribution.
virtual void discretize()
Discretizes the distribution in equiprobable classes.
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
Parameter & getParameter_(const std::string &name)
void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...