bpp-core3  3.0.0
ConstantDistribution.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_NUMERIC_PROB_CONSTANTDISTRIBUTION_H
6 #define BPP_NUMERIC_PROB_CONSTANTDISTRIBUTION_H
7 
8 
10 
11 namespace bpp
12 {
20 {
21 private:
22  double value_;
23 
24 public:
33  ConstantDistribution(double value);
34 
36 
38 
39  virtual ~ConstantDistribution() {}
40 
42  {
43  return new ConstantDistribution(*this);
44  }
45 
46 public:
47  void fireParameterChanged(const ParameterList& parameters);
48 
49  double randC() const { return value_; }
50 
51  std::string getName() const { return "Constant"; }
52 
53  double getLowerBound() const { return value_; }
54 
55  double getUpperBound() const { return value_; }
56 
57  double qProb(double x) const { return (x >= 1) ? value_ : -NumConstants::VERY_BIG(); }
58 
59  double pProb(double x) const { return x < value_ ? 0 : 1; }
60 
61  double Expectation(double a) const { return a < value_ ? 0 : 1; }
62 
64 
65  void discretize() {}
66 };
67 } // end of namespace bpp.
68 #endif // BPP_NUMERIC_PROB_CONSTANTDISTRIBUTION_H
ConstantDistribution & operator=(const ConstantDistribution &)
Partial implementation of the DiscreteDistribution interface.
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
The constraint interface.
Definition: Constraints.h:28
void discretize()
Discretizes the distribution in equiprobable classes.
The parameter list object.
Definition: ParameterList.h:27
ConstantDistribution * clone() const
Create a copy of this object and send a pointer to it.
static double VERY_BIG()
Definition: NumConstants.h:48
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
ConstantDistribution(double value)
Builds a new ConstantDistribution object from a value.
std::string getName() const
Get the name of the distribution.
Constant discrete distribution.
void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
double randC() const
Draw a random number from the continuous version of this distribution, if it exists.
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
double getLowerBound() const
methods about the range of the definition