bpp-core  2.2.0
DiscreteDistribution.h
Go to the documentation of this file.
1 //
2 // File: DiscreteDistribution.h
3 // Created by: Julien Dutheil
4 // Created on: ?
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 19, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for numerical calculus.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _DISCRETEDISTRIBUTION_H_
41 #define _DISCRETEDISTRIBUTION_H_
42 
43 #include "../VectorTools.h"
44 #include "../ParameterAliasable.h"
45 #include "../NumConstants.h"
46 #include "../../Exceptions.h"
47 #include "../../Io/OutputStream.h"
48 
49 namespace bpp
50 {
51 
69  public virtual ParameterAliasable
70  {
71  public:
73  virtual ~DiscreteDistribution() {}
74 
75 
76 #ifndef NO_VIRTUAL_COV
77  DiscreteDistribution* clone() const = 0;
78 #endif
79 
80  public:
81 
87  virtual std::string getName() const = 0;
88 
92  virtual size_t getNumberOfCategories() const = 0;
93 
94 
100  virtual void setNumberOfCategories(size_t nbClasses) = 0;
101 
109  virtual double getValueCategory(double value) const = 0 ;
110 
116  virtual double getCategory(size_t categoryIndex) const = 0;
117 
122  virtual double getProbability(size_t categoryIndex) const = 0;
123 
128  virtual double getProbability(double category) const = 0;
129 
133  virtual Vdouble getCategories() const = 0;
137  virtual Vdouble getProbabilities() const = 0;
138 
150  virtual void set(double category, double probability) = 0;
151 
163  virtual void add(double category, double probability) = 0;
164 
169  virtual double getInfCumulativeProbability(double category) const = 0;
174  virtual double getIInfCumulativeProbability(double category) const = 0;
179  virtual double getSupCumulativeProbability(double category) const = 0;
184  virtual double getSSupCumulativeProbability(double category) const = 0;
185 
194  virtual double rand() const = 0;
195 
204  virtual double randC() const throw (Exception) = 0;
205 
212  virtual double qProb(double x) const = 0;
213 
220  virtual double pProb(double x) const = 0;
221 
229  virtual double Expectation(double a) const = 0;
230 
245  virtual void setMedian(bool median) = 0;
246 
251  virtual void discretize() = 0;
252 
256  virtual Vdouble getBounds() const = 0;
257 
261  virtual double getBound(size_t) const = 0;
262 
271  virtual double getLowerBound() const {
272  return (-NumConstants::VERY_BIG());
273  }
274 
278  virtual double getUpperBound() const {
279  return (NumConstants::VERY_BIG());
280  }
281 
285  virtual bool strictLowerBound() const {
286  return (true);
287  }
288 
292  virtual bool strictUpperBound() const {
293  return (true);
294  }
295 
308  virtual void restrictToConstraint(const Constraint& c) = 0;
309 
315  virtual void print(OutputStream& out) const = 0;
316 
317  };
318 
319 } //end of namespace bpp.
320 
321 #endif //_DISCRETEDISTRIBUTION_H_
322 
virtual double getSSupCumulativeProbability(double category) const =0
virtual double getInfCumulativeProbability(double category) const =0
virtual double pProb(double x) const =0
Return the cumulative quantile of the continuous version of the distribution, ie .
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
Extend the Parametrizable interface with support for parameter aliases.
This class allows to perform a correspondence analysis.
Interface for discrete distribution objects.
virtual bool strictLowerBound() const
virtual double getProbability(size_t categoryIndex) const =0
virtual double getLowerBound() const
methods about the range of the definition
virtual void add(double category, double probability)=0
Modify the probability associated to a class.
virtual Vdouble getCategories() const =0
virtual double getCategory(size_t categoryIndex) const =0
virtual double getIInfCumulativeProbability(double category) const =0
virtual double rand() const =0
Draw a random number from this distribution.
virtual void discretize()=0
Discretizes the distribution in equiprobable classes.
The constraint interface.
Definition: Constraints.h:62
static double VERY_BIG()
Definition: NumConstants.h:83
std::vector< double > Vdouble
Definition: VectorTools.h:67
virtual std::string getName() const =0
Get the name of the distribution.
virtual double qProb(double x) const =0
Return the quantile of the continuous version of the distribution, ie y such that ...
virtual double getUpperBound() const
OutputStream interface.
Definition: OutputStream.h:64
Exception base class.
Definition: Exceptions.h:57
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 setNumberOfCategories(size_t nbClasses)=0
sets the number of categories and discretizes if there is a change in this number.
virtual double getBound(size_t) const =0
virtual double getSupCumulativeProbability(double category) const =0
virtual double randC() const =0
Draw a random number from the continuous version of this distribution, if it exists.
virtual Vdouble getProbabilities() const =0
virtual Vdouble getBounds() const =0
DiscreteDistribution * clone() const =0
Create a copy of this object and send a pointer to it.
virtual double getValueCategory(double value) const =0
virtual void print(OutputStream &out) const =0
Print the distribution (categories and corresponding probabilities) to a stream.
virtual bool strictUpperBound() const
virtual void restrictToConstraint(const Constraint &c)=0
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...