bpp-core3  3.0.0
DiscreteDistribution.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_DISCRETEDISTRIBUTION_H
6 #define BPP_NUMERIC_PROB_DISCRETEDISTRIBUTION_H
7 
8 
9 #include "../../Exceptions.h"
10 #include "../../Io/OutputStream.h"
11 #include "../NumConstants.h"
12 #include "../ParameterAliasable.h"
13 #include "../VectorTools.h"
14 
15 namespace bpp
16 {
34  public virtual ParameterAliasable
35 {
36 public:
39 
40 
42 
43 public:
49  virtual std::string getName() const = 0;
50 
54  virtual size_t getNumberOfCategories() const = 0;
55 
56 
62  virtual void setNumberOfCategories(size_t nbClasses) = 0;
63 
71  virtual double getValueCategory(double value) const = 0;
72 
80  virtual size_t getCategoryIndex(double value) const = 0;
81 
87  virtual double getCategory(size_t categoryIndex) const = 0;
88 
93  virtual double getProbability(size_t categoryIndex) const = 0;
94 
99  virtual double getProbability(double category) const = 0;
100 
104  virtual Vdouble getCategories() const = 0;
108  virtual Vdouble getProbabilities() const = 0;
109 
121  virtual void set(double category, double probability) = 0;
122 
134  virtual void add(double category, double probability) = 0;
135 
140  virtual double getInfCumulativeProbability(double category) const = 0;
145  virtual double getIInfCumulativeProbability(double category) const = 0;
150  virtual double getSupCumulativeProbability(double category) const = 0;
155  virtual double getSSupCumulativeProbability(double category) const = 0;
156 
165  virtual double rand() const = 0;
166 
175  virtual double randC() const = 0;
176 
183  virtual double qProb(double x) const = 0;
184 
191  virtual double pProb(double x) const = 0;
192 
200  virtual double Expectation(double a) const = 0;
201 
216  virtual void setMedian(bool median) = 0;
217 
222  virtual void discretize() = 0;
223 
227  virtual Vdouble getBounds() const = 0;
228 
232  virtual double getBound(size_t) const = 0;
233 
242  virtual double getLowerBound() const
243  {
244  return -NumConstants::VERY_BIG();
245  }
246 
250  virtual double getUpperBound() const
251  {
252  return NumConstants::VERY_BIG();
253  }
254 
258  virtual bool strictLowerBound() const
259  {
260  return true;
261  }
262 
266  virtual bool strictUpperBound() const
267  {
268  return true;
269  }
270 
281  virtual void restrictToConstraint(const ConstraintInterface& c) = 0;
282 
288  virtual void print(OutputStream& out) const = 0;
289 };
290 } // end of namespace bpp.
291 #endif // BPP_NUMERIC_PROB_DISCRETEDISTRIBUTION_H
virtual double randC() const =0
Draw a random number from the continuous version of this distribution, if it exists.
virtual void restrictToConstraint(const ConstraintInterface &c)=0
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
virtual std::string getName() const =0
Get the name of the distribution.
virtual double getValueCategory(double value) const =0
DiscreteDistributionInterface * clone() const =0
Create a copy of this object and send a pointer to it.
Extend the Parametrizable interface with support for parameter aliases.
virtual void discretize()=0
Discretizes the distribution in equiprobable classes.
virtual void setMedian(bool median)=0
Sets the median value to true to say that the value in a class is proportional to the median value of...
The constraint interface.
Definition: Constraints.h:28
virtual size_t getCategoryIndex(double value) const =0
virtual Vdouble getCategories() const =0
Interface for discrete distribution objects.
virtual double getBound(size_t) const =0
virtual double getProbability(size_t categoryIndex) const =0
virtual double getInfCumulativeProbability(double category) const =0
virtual Vdouble getProbabilities() const =0
virtual void add(double category, double probability)=0
Modify the probability associated to a class.
virtual double rand() const =0
Draw a random number from this distribution.
virtual double getSupCumulativeProbability(double category) const =0
virtual double Expectation(double a) const =0
Return a primitive function used for the expectation of the continuous version of the distribution...
virtual size_t getNumberOfCategories() const =0
static double VERY_BIG()
Definition: NumConstants.h:48
std::vector< double > Vdouble
Definition: VectorTools.h:34
OutputStream interface.
Definition: OutputStream.h:29
virtual double getLowerBound() const
methods about the range of the definition
virtual void print(OutputStream &out) const =0
Print the distribution (categories and corresponding probabilities) to a stream.
virtual double pProb(double x) const =0
Return the cumulative quantile of the continuous version of the distribution, ie .
virtual double getCategory(size_t categoryIndex) const =0
virtual double qProb(double x) const =0
Return the quantile of the continuous version of the distribution, ie y such that ...
virtual void setNumberOfCategories(size_t nbClasses)=0
sets the number of categories and discretizes if there is a change in this number.
virtual double getSSupCumulativeProbability(double category) const =0
virtual double getIInfCumulativeProbability(double category) const =0
virtual Vdouble getBounds() const =0