bpp-core3  3.0.0
MixtureOfDiscreteDistributions.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_MIXTUREOFDISCRETEDISTRIBUTIONS_H
6 #define BPP_NUMERIC_PROB_MIXTUREOFDISCRETEDISTRIBUTIONS_H
7 
8 
10 
11 namespace bpp
12 {
37 {
38 protected:
39  std::vector<std::unique_ptr<DiscreteDistributionInterface>> vdd_;
40 
41  std::vector<double> probas_;
42 
43  std::vector<std::string> vNestedPrefix_;
44 
45 public:
54  MixtureOfDiscreteDistributions(const std::vector<std::unique_ptr<DiscreteDistributionInterface>>& distributions, const std::vector<double>& probas);
55 
57 
59 
61 
63 
64 public:
65  std::string getName() const {return "Mixture"; }
66 
71  size_t getNumberOfDistributions() const { return vdd_.size(); }
72 
79  {
80  return *vdd_[n];
81  }
82 
88  double getNProbability(size_t n) const
89  {
90  return probas_[n];
91  }
92 
100  void setNumberOfCategories(size_t nbClasses);
101 
102  void fireParameterChanged(const ParameterList& parameters);
103 
104  double qProb(double x) const;
105 
106  double pProb(double x) const;
107 
108  double Expectation(double a) const;
109 
110  void setMedian(bool median);
111 
113 
114  void discretize();
115 
116  void setNamespace(const std::string& prefix);
117 
118 protected:
119  void updateDistribution();
120 };
121 } // end of namespace bpp.
122 #endif // BPP_NUMERIC_PROB_MIXTUREOFDISCRETEDISTRIBUTIONS_H
MixtureOfDiscreteDistributions & operator=(const MixtureOfDiscreteDistributions &mdd)
double getNProbability(size_t n) const
Returns the probability of the n-th discrete distribution in the mixture.
void setNumberOfCategories(size_t nbClasses)
sets the number of categories of EACH submodel to nbClasses, so the number of categories of the mixtu...
Partial implementation of the DiscreteDistribution interface.
The constraint interface.
Definition: Constraints.h:28
void setNamespace(const std::string &prefix)
Set the namespace for the parameter names.
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
Interface for discrete distribution objects.
const DiscreteDistributionInterface & nDistribution(size_t n) const
Returns a pointer to the n-th discrete distribution in the mixture.
A Discrete distribution object defined by a vector of Discrete Distributions and a set of probabiliti...
The parameter list object.
Definition: ParameterList.h:27
void restrictToConstraint(const ConstraintInterface &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
size_t getNumberOfDistributions() const
Returns the number of discrete distributions in the mixture.
std::string getName() const
Get the name of the distribution.
MixtureOfDiscreteDistributions(const std::vector< std::unique_ptr< DiscreteDistributionInterface >> &distributions, const std::vector< double > &probas)
Builds a new MixtureOfDiscreteDistributions object from a vector of Discrete Distributions and a vect...
void setMedian(bool median)
Sets the median value to true to say that the value in a class is proportional to the median value of...
MixtureOfDiscreteDistributions * clone() const
Create a copy of this object and send a pointer to it.
void discretize()
Discretizes the distribution in equiprobable classes.
std::vector< std::unique_ptr< DiscreteDistributionInterface > > vdd_