C++ main module for mmsd Package  1.0
STAT_GammaDistribution.h
Go to the documentation of this file.
1 #ifndef STAT_GammaDistribution_H
2 #define STAT_GammaDistribution_H
3 
4 #include "STAT_Distribution.h"
5 #include <boost/math/distributions/gamma.hpp>
6 #include <boost/random/gamma_distribution.hpp>
7 #include <boost/random/variate_generator.hpp>
8 
17  SP_OBJECT(STAT_GammaDistribution);
18  // ATTRIBUTES
19 
20 public:
21  //static SPC::STAT_GammaDistribution GOF_GAMMA_BA;
22 private:
23 
24 
25 
26  // ASSOCIATIONS
27  boost::math::gamma_distribution<tReal> *mDistribution;
28  boost::random::gamma_distribution<tReal> *mRandomDistribution;
29  boost::random::variate_generator<RNGType&,
30  boost::random::gamma_distribution<tReal> > *mGenerator;
31 
32 protected:
33  // METHODS
34 
35  // CONSTRUCTORS
36 
39 
40 
41 
42  // DESTRUCTORS
43 
44 
47  virtual ~STAT_GammaDistribution(void);
48 
49 
50 
51 public:
52  //----------------
53  // NEW constructors
54  // ---------------
55 
58  inline static SP::STAT_GammaDistribution New(const tReal& shape,
59  const tReal& scale) {
60  SP::STAT_GammaDistribution p(new STAT_GammaDistribution(),
62  p->setProperties(shape,scale);
63  p->setThis(p);
64  return p;
65  }
68  inline static SP::STAT_GammaDistribution New() {
69  return New(1.,1.);
70  }
73  virtual SP::STAT_Distribution NewInstance() const {
74  return New();
75  }
76 
77 
80  virtual void copy(const STAT_Distribution& d) {
81  tReal v=d.variance();
82  tReal m=d.mean();
83  if (v*m!=0)
84  setProperties(m*m/v,v/m);
85  }
86  // --------------------
87  // ATTRIBUTES setting
88  // --------------------
89 
90  void setProperties(const tReal& shape,
91  const tReal& scale);
92 
93  void getProperties(tReal& shape,tReal& scale) const {
94  shape=mDistribution->shape();
95  scale=mDistribution->scale();
96  }
97 
98  // -----------------------
99  // USUAL Functions
100  // ------------------------
101 
102 
105  virtual tReal pdf(const tReal& x) const;
106 
109  virtual tReal cdf(const tReal& x) const;
110 
113  virtual tReal cdfc(const tReal& x) const;
114 
117  virtual void range(tReal& xmin,tReal& xmax) const;
118 
121  virtual tReal mean() const;
122 
125  virtual tReal variance() const;
128  virtual tReal standardDeviation() const;
129 
133  virtual tReal random() const;
134 
137  virtual void computeSample(const int& n,CORE_RealArray& sample) const;
140  virtual void computeSample(const int& n,double* samples) const;
141 
142 protected:
143  /* \brief return the growth rate of the distribution
144  * @param adjust: is true rescale the parameters of the distribution suach as its growth rate is rho
145  *
146  */
147  virtual tReal computeGrowthRate(const tReal& v,
148  const tBoolean& adjust,
149  const tReal& rho) ;
150 
151 
152 
153 
154 
155 
156 
157 };
158 
159 #endif
virtual ~STAT_GammaDistribution(void)
destroy an object.
Definition: STAT_GammaDistribution.cpp:15
static SP::STAT_GammaDistribution New(const tReal &shape, const tReal &scale)
create a Gamma distibution
Definition: STAT_GammaDistribution.h:58
void setProperties(const tReal &shape, const tReal &scale)
Definition: STAT_GammaDistribution.cpp:24
virtual tReal cdf(const tReal &x) const
compute the cumulative distribution function at x point
Definition: STAT_GammaDistribution.cpp:53
virtual tReal computeGrowthRate()
return the growth rate of the distribution such that Esperance(E(exp(-z*X)))=0.5
Definition: STAT_Distribution.h:133
DEFINE_SPTR(STAT_GammaDistribution)
virtual void computeSample(const int &n, CORE_RealArray &sample) const
compute a sample of size n
Definition: STAT_GammaDistribution.cpp:87
virtual tReal cdfc(const tReal &x) const
compute the cumulative distribution complement function at x point
Definition: STAT_GammaDistribution.cpp:59
virtual tReal mean() const =0
compute the mean
#define tBoolean
Definition: types.h:48
virtual tReal variance() const
compute the variance
Definition: STAT_GammaDistribution.cpp:69
virtual void copy(const STAT_Distribution &d)
copy the distribution
Definition: STAT_GammaDistribution.h:80
virtual tReal standardDeviation() const
compute the standard deviation
Definition: STAT_GammaDistribution.cpp:74
virtual tReal random() const
random return a random numbers in range
Definition: STAT_GammaDistribution.cpp:79
static SP::STAT_GammaDistribution New()
create a Gamma distibution
Definition: STAT_GammaDistribution.h:68
virtual void range(tReal &xmin, tReal &xmax) const
compute the range of the distribution
Definition: STAT_GammaDistribution.cpp:40
this class describes an array
Definition: CORE_Array.h:18
This class is the class to describes Gamma distribution.
Definition: STAT_GammaDistribution.h:16
This class is the class to describes general distribution.
Definition: STAT_Distribution.h:25
virtual tReal pdf(const tReal &x) const
compute the probability density function at x point
Definition: STAT_GammaDistribution.cpp:48
void getProperties(tReal &shape, tReal &scale) const
Definition: STAT_GammaDistribution.h:93
virtual tReal variance() const =0
compute the variance
boost::mt19937 RNGType
Definition: STAT_Distribution.h:23
virtual tReal mean() const
compute the mean
Definition: STAT_GammaDistribution.cpp:64
#define tReal
Definition: types.h:18
virtual SP::STAT_Distribution NewInstance() const
create a new instance of the distribution
Definition: STAT_GammaDistribution.h:73
STAT_GammaDistribution()
create an object
Definition: STAT_GammaDistribution.cpp:7
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106