bpp-core3  3.0.0
GammaDiscreteDistribution.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_GAMMADISCRETEDISTRIBUTION_H
6 #define BPP_NUMERIC_PROB_GAMMADISCRETEDISTRIBUTION_H
7 
8 
9 #include "../Constraints.h"
10 #include "../Random/RandomTools.h"
12 
13 namespace bpp
14 {
23 {
24 private:
25  double alpha_, beta_;
26 
27  double offset_;
28 
29  // To prevent useless computations
30  double ga1_;
31 
32 public:
33  std::string getName() const {return "Gamma";}
34 
55  GammaDiscreteDistribution(size_t n, double alpha = 1., double beta = 1., double minimumAlpha = 0.05, double minimumBeta = 0.05, bool paramOffset = false, double offset = 0);
56 
58 
60 
62 
64 
65  void fireParameterChanged(const ParameterList& parameters);
66 
67  double randC() const
68  {
69  double x = RandomTools::randGamma(getParameterValue("alpha"),
70  getParameterValue("beta"));
71  while (!intMinMax_->isCorrect(x))
73  getParameterValue("beta"));
74 
75  return x + offset_;
76  }
77 
78  double qProb(double x) const;
79 
80  double pProb(double x) const;
81 
82  double Expectation(double a) const;
83 };
84 } // end of namespace bpp.
85 #endif // BPP_NUMERIC_PROB_GAMMADISCRETEDISTRIBUTION_H
double Expectation(double a) const
Return a primitive function used for the expectation of the continuous version of the distribution...
Partial implementation of the DiscreteDistribution interface.
std::string getName() const
Get the name of the distribution.
GammaDiscreteDistribution * clone() const
Create a copy of this object and send a pointer to it.
double getParameterValue(const std::string &name) const override
Get the value for parameter of name 'name'.
The parameter list object.
Definition: ParameterList.h:27
static double randGamma(double alpha)
Definition: RandomTools.h:126
std::shared_ptr< IntervalConstraint > intMinMax_
the interval where the distribution is defined/restricted.
GammaDiscreteDistribution & operator=(const GammaDiscreteDistribution &)
double randC() const
Draw a random number from the continuous version of this distribution, if it exists.
GammaDiscreteDistribution(size_t n, double alpha=1., double beta=1., double minimumAlpha=0.05, double minimumBeta=0.05, bool paramOffset=false, double offset=0)
Build a new discretized gamma distribution.
Discretized Gamma distribution with an offset.
double pProb(double x) const
Return the cumulative quantile of the continuous version of the distribution, ie .
double qProb(double x) const
Return the quantile of the continuous version of the distribution, ie y such that ...
void fireParameterChanged(const ParameterList &parameters)
Notify the class when one or several parameters have changed.