C++ main module for mmsd Package  1.0
STAT_Distribution.h
Go to the documentation of this file.
1 #ifndef STAT_Distribution_H
2 #define STAT_Distribution_H
3 
4 #include "STAT_Object.h"
5 
6 #include "CORE_Array.h"
7 
8 #include <boost/random/mersenne_twister.hpp>
9 
10 
19 // boost::mt19937
20 // boost::ecuyer1988
21 // boost::minstd_rand
22 // boost::rand48
23 typedef boost::mt19937 RNGType;
24 
26  SP_OBJECT(STAT_Distribution);
27  // ATTRIBUTES
28 
29 private:
30  // Generator of pseudo number method
31 
32  static RNGType mRNGenerator;
33  static tBoolean INIT_SEED;
34 
35 
36 private:
37 
38 
39  // ASSOCIATIONS
40 
41 
42 protected:
43  // METHODS
44 
45  // CONSTRUCTORS
46 
48  STAT_Distribution(void);
49 
50 
51 
52  // DESTRUCTORS
53 
54 
57  virtual ~STAT_Distribution(void);
58 
59 
60 
61 public:
62  //----------------
63  // NEW constructors
64  // ---------------
67  virtual SP::STAT_Distribution NewInstance() const=0;
68 
71  SP::STAT_Distribution NewCopyInstance() const {
72  SP::STAT_Distribution dist=NewInstance();
73  dist->copy(*this);
74  return dist;
75  };
76 
79  virtual void copy(const STAT_Distribution& d)=0;
80 
83  inline RNGType& getRNGenerator() {
84  return mRNGenerator;
85  };
86 
89  static void initSeed();
90 
93  static void initSeed(const long double& v);
94 
95  // -----------------------
96  // USUAL Functions
97  // ------------------------
98 
101  virtual tReal pdf(const tReal& x) const=0;
102 
105  virtual tReal cdf(const tReal& x) const=0;
106 
109  virtual tReal cdfc(const tReal& x) const=0;
110 
113  virtual tReal mean() const=0;
114 
117  virtual tReal variance() const=0;
118 
121  virtual tReal standardDeviation() const=0;
122 
125  virtual tReal random() const=0;
126 
129  virtual void computeSample(const int& n,CORE_RealArray& sample) const=0;
130 
134  return computeGrowthRate(0.5,false,0);
135  };
136 
139  virtual tReal computeGrowthRate(const tReal& rho,const tReal& death) {
140  return computeGrowthRate(0.5/(1-death),false,rho);
141  };
142 
145  virtual tReal adjustGrowthRate(const tReal& rho,const tReal& death) {
146  return computeGrowthRate(0.5/(1-death),true,rho);
147  };
148 protected:
149  /* \brief return the growth rate z of the distribution such that E(exp(-z.X))=v;
150  * @param adjust: is true rescale the parameters of the distribution such as its growth rate is rho
151  *
152  */
153  virtual tReal computeGrowthRate(const tReal& v,
154  const tBoolean& adjust,
155  const tReal& rho) =0;
156 
157 };
158 
159 #endif
virtual tReal random() const =0
compute the random
This class is the base class of all statistics package.
Definition: STAT_Object.h:13
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_Distribution)
virtual tReal pdf(const tReal &x) const =0
compute the probability density function at x point
virtual tReal mean() const =0
compute the mean
#define tBoolean
Definition: types.h:48
RNGType & getRNGenerator()
get the generator
Definition: STAT_Distribution.h:83
SP::STAT_Distribution NewCopyInstance() const
create a copy of the distribution
Definition: STAT_Distribution.h:71
static void initSeed()
init the seed
Definition: STAT_Distribution.cpp:22
virtual ~STAT_Distribution(void)
destroy an object.
Definition: STAT_Distribution.cpp:13
virtual tReal cdfc(const tReal &x) const =0
compute the cumulative distribution complement function at x point
this class describes an array
Definition: CORE_Array.h:18
virtual void copy(const STAT_Distribution &d)=0
copy the distribution
virtual tReal computeGrowthRate(const tReal &rho, const tReal &death)
return the growth rate of the distribution such that Esperance(E(exp(-z*X)))=0.5
Definition: STAT_Distribution.h:139
This class is the class to describes general distribution.
Definition: STAT_Distribution.h:25
virtual void computeSample(const int &n, CORE_RealArray &sample) const =0
compute a sample of size n
virtual tReal variance() const =0
compute the variance
boost::mt19937 RNGType
Definition: STAT_Distribution.h:23
virtual tReal standardDeviation() const =0
compute the standard deviation
virtual tReal adjustGrowthRate(const tReal &rho, const tReal &death)
adjuste the parameters of the distribution such that growth rate is rho
Definition: STAT_Distribution.h:145
STAT_Distribution(void)
create an object
Definition: STAT_Distribution.cpp:7
#define tReal
Definition: types.h:18
virtual tReal cdf(const tReal &x) const =0
compute the cumulative distribution function at x point
virtual SP::STAT_Distribution NewInstance() const =0
create a new instance of the distribution