bpp-core3  3.0.0
SimpleDiscreteDistribution.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_SIMPLEDISCRETEDISTRIBUTION_H
6 #define BPP_NUMERIC_PROB_SIMPLEDISCRETEDISTRIBUTION_H
7 
8 
10 
11 // From the STL:
12 #include <map>
13 
14 namespace bpp
15 {
30 {
31 private:
32  std::map<size_t, std::vector<double>> givenRanges_;
33 
34 public:
47  SimpleDiscreteDistribution(const std::map<double, double>& distribution, double precision = NumConstants::TINY(), bool fixed = false);
48 
60  SimpleDiscreteDistribution(const std::vector<double>& values, const std::vector<double>& probas, double prec = NumConstants::TINY(), bool fixed = false);
61 
77  SimpleDiscreteDistribution(const std::vector<double>& values, const std::map<size_t, std::vector<double>>& ranges, const std::vector<double>& probas, double prec = NumConstants::TINY(), bool fixed = false);
78 
80 
82 
84 
86 
87 public:
88  /*
89  *@brief Returns the map of the given ranges for the values.
90  *
91  */
92  const std::map<size_t, std::vector<double>> getRanges() const { return givenRanges_;}
93 
94  std::string getName() const {return "Simple";}
95 
96  void discretize();
97 
98  void fireParameterChanged(const ParameterList& parameters);
99 
100  double getLowerBound() const
101  {
102  return distribution_.begin()->first;
103  }
104 
105  double getUpperBound() const
106  {
107  return distribution_.rbegin()->first;
108  }
109 
110  double qProb(double x) const;
111 
112  double pProb(double x) const;
113 
114  double Expectation(double a) const;
115 
117 };
118 } // end of namespace bpp.
119 #endif // BPP_NUMERIC_PROB_SIMPLEDISCRETEDISTRIBUTION_H
std::string getName() const
Get the name of the distribution.
Partial implementation of the DiscreteDistribution interface.
const std::map< size_t, std::vector< double > > getRanges() const
std::map< size_t, std::vector< double > > givenRanges_
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
The constraint interface.
Definition: Constraints.h:28
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
SimpleDiscreteDistribution & operator=(const SimpleDiscreteDistribution &)
SimpleDiscreteDistribution * clone() const
Create a copy of this object and send a pointer to it.
The parameter list object.
Definition: ParameterList.h:27
A Discrete distribution object, where some specific probabilities are assigned to a finite set of val...
void discretize()
Discretizes the distribution in equiprobable classes.
static double TINY()
Definition: NumConstants.h:46
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
std::map< double, double, Order > distribution_
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
SimpleDiscreteDistribution(const std::map< double, double > &distribution, double precision=NumConstants::TINY(), bool fixed=false)
Builds a new SimpleDiscreteDistribution object from a map<double,double> object. With this constructo...
double getLowerBound() const
methods about the range of the definition
void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...