bpp-core3  3.0.0
DiscreteDistribution.h
Go to the documentation of this file.
1 //
2 // File: DiscreteDistribution.h
3 // Authors:
4 // Julien Dutheil
5 // Created: ?
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 19, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for numerical calculus.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_NUMERIC_PROB_DISCRETEDISTRIBUTION_H
42 #define BPP_NUMERIC_PROB_DISCRETEDISTRIBUTION_H
43 
44 
45 #include "../../Exceptions.h"
46 #include "../../Io/OutputStream.h"
47 #include "../NumConstants.h"
48 #include "../ParameterAliasable.h"
49 #include "../VectorTools.h"
50 
51 namespace bpp
52 {
70  public virtual ParameterAliasable
71 {
72 public:
74  virtual ~DiscreteDistribution() {}
75 
76 
78 
79 public:
85  virtual std::string getName() const = 0;
86 
90  virtual size_t getNumberOfCategories() const = 0;
91 
92 
98  virtual void setNumberOfCategories(size_t nbClasses) = 0;
99 
107  virtual double getValueCategory(double value) const = 0;
108 
116  virtual size_t getCategoryIndex(double value) const = 0;
117 
123  virtual double getCategory(size_t categoryIndex) const = 0;
124 
129  virtual double getProbability(size_t categoryIndex) const = 0;
130 
135  virtual double getProbability(double category) const = 0;
136 
140  virtual Vdouble getCategories() const = 0;
144  virtual Vdouble getProbabilities() const = 0;
145 
157  virtual void set(double category, double probability) = 0;
158 
170  virtual void add(double category, double probability) = 0;
171 
176  virtual double getInfCumulativeProbability(double category) const = 0;
181  virtual double getIInfCumulativeProbability(double category) const = 0;
186  virtual double getSupCumulativeProbability(double category) const = 0;
191  virtual double getSSupCumulativeProbability(double category) const = 0;
192 
201  virtual double rand() const = 0;
202 
211  virtual double randC() const = 0;
212 
219  virtual double qProb(double x) const = 0;
220 
227  virtual double pProb(double x) const = 0;
228 
236  virtual double Expectation(double a) const = 0;
237 
252  virtual void setMedian(bool median) = 0;
253 
258  virtual void discretize() = 0;
259 
263  virtual Vdouble getBounds() const = 0;
264 
268  virtual double getBound(size_t) const = 0;
269 
278  virtual double getLowerBound() const
279  {
280  return -NumConstants::VERY_BIG();
281  }
282 
286  virtual double getUpperBound() const
287  {
288  return NumConstants::VERY_BIG();
289  }
290 
294  virtual bool strictLowerBound() const
295  {
296  return true;
297  }
298 
302  virtual bool strictUpperBound() const
303  {
304  return true;
305  }
306 
319  virtual void restrictToConstraint(const Constraint& c) = 0;
320 
326  virtual void print(OutputStream& out) const = 0;
327 };
328 } // end of namespace bpp.
329 #endif // BPP_NUMERIC_PROB_DISCRETEDISTRIBUTION_H
The constraint interface.
Definition: Constraints.h:66
Interface for discrete distribution objects.
virtual void add(double category, double probability)=0
Modify the probability associated to a class.
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...
virtual void discretize()=0
Discretizes the distribution in equiprobable classes.
virtual void setNumberOfCategories(size_t nbClasses)=0
sets the number of categories and discretizes if there is a change in this number.
virtual size_t getCategoryIndex(double value) const =0
virtual double getIInfCumulativeProbability(double category) const =0
virtual double getBound(size_t) const =0
virtual Vdouble getBounds() const =0
virtual double rand() const =0
Draw a random number from this distribution.
virtual double getProbability(double category) const =0
DiscreteDistribution * clone() const =0
Create a copy of this object and send a pointer to it.
virtual double Expectation(double a) const =0
Return a primitive function used for the expectation of the continuous version of the distribution,...
virtual double pProb(double x) const =0
Return the cumulative quantile of the continuous version of the distribution, ie .
virtual double getProbability(size_t categoryIndex) const =0
virtual bool strictLowerBound() const
virtual double getSupCumulativeProbability(double category) const =0
virtual double getUpperBound() const
virtual double getCategory(size_t categoryIndex) const =0
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 Vdouble getCategories() const =0
virtual double qProb(double x) const =0
Return the quantile of the continuous version of the distribution, ie y such that .
virtual Vdouble getProbabilities() const =0
virtual double getSSupCumulativeProbability(double category) const =0
virtual double getInfCumulativeProbability(double category) const =0
virtual double randC() const =0
Draw a random number from the continuous version of this distribution, if it exists.
virtual bool strictUpperBound() const
virtual void set(double category, double probability)=0
Set the probability associated to a class.
virtual void restrictToConstraint(const Constraint &c)=0
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
virtual double getValueCategory(double value) const =0
virtual std::string getName() const =0
Get the name of the distribution.
virtual size_t getNumberOfCategories() const =0
static double VERY_BIG()
Definition: NumConstants.h:84
OutputStream interface.
Definition: OutputStream.h:67
Extend the Parametrizable interface with support for parameter aliases.
std::vector< double > Vdouble
Definition: VectorTools.h:70