bpp-core  2.2.0
MixtureOfDiscreteDistributions.h
Go to the documentation of this file.
1 //
2 // File: MixtureOfDiscreteDistributions.h
3 // Created by: Laurent Guéguen
4 // Created on: mercredi 9 juin 2010, à 22h 44
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 17, 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 _MIXTUREOFDISCRETEDISTRIBUTIONS_H_
41 #define _MIXTUREOFDISCRETEDISTRIBUTIONS_H_
42 
44 
45 namespace bpp
46 {
71 {
72 protected:
73  std::vector<DiscreteDistribution*> vdd_;
74 
75  std::vector<double> probas_;
76 
77  std::vector<std::string> vNestedPrefix_;
78 
79 public:
92  MixtureOfDiscreteDistributions(const std::vector<DiscreteDistribution*>& distributions, const std::vector<double>& probas);
93 
95 
97 
99 
100 #if defined(NO_VIRTUAL_COV)
101  Clonable* clone() const { return new MixtureOfDiscreteDistributions(*this); }
102 #else
104 #endif
105 
106 public:
107  std::string getName() const {return "Mixture"; }
108 
114  size_t getNumberOfDistributions() const {return vdd_.size(); }
115 
121  const DiscreteDistribution* getNDistribution(size_t n) const
122  {
123  return vdd_[n];
124  }
125 
131  double getNProbability(size_t n) const
132  {
133  return probas_[n];
134  }
135 
143  void setNumberOfCategories(size_t nbClasses);
144 
145  void fireParameterChanged(const ParameterList& parameters);
146 
147  double qProb(double x) const;
148 
149  double pProb(double x) const;
150 
151  double Expectation(double a) const;
152 
153  void setMedian(bool median);
154 
155  void restrictToConstraint(const Constraint& c);
156 
157  void discretize();
158 
159  void setNamespace(const std::string& prefix);
160 
161 protected:
162  void updateDistribution();
163 };
164 } // end of namespace bpp.
165 
166 #endif // _MIXTUREOFDISCRETEDISTRIBUTIONS_H__
167 
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.
This class allows to perform a correspondence analysis.
Interface for discrete distribution objects.
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 ...
void restrictToConstraint(const Constraint &c)
Restricts the distribution to the domain where the constraint is respected, in addition of other pred...
A Discrete distribution object defined by a vector of Discrete Distributions and a set of probabiliti...
The parameter list object.
Definition: ParameterList.h:61
size_t getNumberOfDistributions() const
Returns the number of discrete distributions in the mixture.
std::string getName() const
Get the name of the distribution.
The constraint interface.
Definition: Constraints.h:62
MixtureOfDiscreteDistributions(const std::vector< DiscreteDistribution *> &distributions, const std::vector< double > &probas)
Builds a new MixtureOfDiscreteDistributions object from a vector of Discrete Distributions and a vect...
The Clonable interface (allow an object to be cloned).
Definition: Clonable.h:99
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...
std::vector< DiscreteDistribution * > vdd_
MixtureOfDiscreteDistributions * clone() const
Create a copy of this object and send a pointer to it.
void discretize()
Discretizes the distribution in equiprobable classes.
const DiscreteDistribution * getNDistribution(size_t n) const
Returns a pointer to the n-th discrete distribution in the mixture.