C++ main module for mmsd Package  1.0
STAT_BernoulliDistribution.h
Go to the documentation of this file.
1 #ifndef STAT_BernoulliDistribution_H
2 #define STAT_BernoulliDistribution_H
3 
4 #include "STAT_Distribution.h"
5 
6 //DEFINE_SPTR(STAT_UniformDistribution);
7 
8 #include "STAT_Distribution.h"
9 #include <boost/math/distributions/bernoulli.hpp>
10 #include <boost/random/bernoulli_distribution.hpp>
11 #include <boost/random/variate_generator.hpp>
12 
21  SP_OBJECT(STAT_BernoulliDistribution);
22  // ATTRIBUTES
23 
24 private:
25 
26 
27 
28  // ASSOCIATIONS
29  //SP::STAT_UniformDistribution mUniform;
30 
31  boost::math::bernoulli_distribution<tReal> *mDistribution;
32  boost::random::bernoulli_distribution<tReal> *mRandomDistribution;
33  boost::random::variate_generator<RNGType&,
34  boost::random::bernoulli_distribution<tReal> > *mGenerator;
35 protected:
36  // METHODS
37 
38  // CONSTRUCTORS
39 
42 
43 
44 
45  // DESTRUCTORS
46 
47 
50  virtual ~STAT_BernoulliDistribution(void);
51 
52 
53 
54 public:
55  //----------------
56  // NEW constructors
57  // ---------------
58 
61  inline static SP::STAT_BernoulliDistribution New(const tReal& p) {
62  SP::STAT_BernoulliDistribution ptr(new STAT_BernoulliDistribution(),
64  ptr->setProperties(p);
65  ptr->setThis(ptr);
66  return ptr;
67  }
70  inline static SP::STAT_BernoulliDistribution New() {
71  return New(0.5);
72  }
75  virtual SP::STAT_Distribution NewInstance() const {
76  return New();
77  }
78 
79 
82  virtual void copy(const STAT_Distribution& d) {
83  setProperties(d.mean());
84  }
85  // --------------------
86  // ATTRIBUTES setting
87  // --------------------
88 
89  void setProperties(const tReal & p);
90 
91  // -----------------------
92  // USUAL Functions
93  // ------------------------
94 
95 
98  virtual tReal pdf(const tReal& x) const;
99 
102  virtual tReal cdf(const tReal& x) const;
103 
106  virtual tReal cdfc(const tReal& x) const;
107 
110  virtual void range(tReal& xmin,tReal& xmax) const;
111 
114  virtual tReal mean() const;
115 
118  virtual tReal variance() const;
121  virtual tReal standardDeviation() const;
122 
126  virtual tReal random() const;
127 
130  virtual void computeSample(const int& n,CORE_RealArray& sample) const;
131 
132  protected:
133  /* \brief return the growth rate of the distribution
134  * @param adjust: is true rescale the parameters of the distribution suach as its growth rate is rho
135  *
136  */
137  virtual tReal computeGrowthRate(const tReal& v,
138  const tBoolean& adjust,
139  const tReal& rho);
140 
141 
142 
143 
144 };
145 
146 #endif
virtual tReal standardDeviation() const
compute the standard deviation
Definition: STAT_BernoulliDistribution.cpp:73
STAT_BernoulliDistribution()
create an object
Definition: STAT_BernoulliDistribution.cpp:4
virtual tReal computeGrowthRate()
return the growth rate of the distribution such that Esperance(E(exp(-z*X)))=0.5
Definition: STAT_Distribution.h:133
virtual void range(tReal &xmin, tReal &xmax) const
compute the range of the distribution
Definition: STAT_BernoulliDistribution.cpp:38
virtual SP::STAT_Distribution NewInstance() const
create a new instance of the distribution
Definition: STAT_BernoulliDistribution.h:75
virtual tReal random() const
random return a random numbers
Definition: STAT_BernoulliDistribution.cpp:78
virtual tReal mean() const =0
compute the mean
#define tBoolean
Definition: types.h:48
virtual void computeSample(const int &n, CORE_RealArray &sample) const
compute a sample of size n
Definition: STAT_BernoulliDistribution.cpp:85
virtual tReal pdf(const tReal &x) const
compute the probability density function at x point
Definition: STAT_BernoulliDistribution.cpp:46
virtual ~STAT_BernoulliDistribution(void)
destroy an object.
Definition: STAT_BernoulliDistribution.cpp:13
virtual tReal variance() const
compute the variance
Definition: STAT_BernoulliDistribution.cpp:68
this class describes an array
Definition: CORE_Array.h:18
virtual tReal cdfc(const tReal &x) const
compute the cumulative distribution complement function at x point
Definition: STAT_BernoulliDistribution.cpp:57
This class is the class to describes general distribution.
Definition: STAT_Distribution.h:25
This class is the class to describes Bernoulli distribution.
Definition: STAT_BernoulliDistribution.h:20
boost::mt19937 RNGType
Definition: STAT_Distribution.h:23
static SP::STAT_BernoulliDistribution New(const tReal &p)
create a Bernoulli distibution
Definition: STAT_BernoulliDistribution.h:61
static SP::STAT_BernoulliDistribution New()
create a Bernoulli distibution
Definition: STAT_BernoulliDistribution.h:70
virtual tReal mean() const
compute the mean
Definition: STAT_BernoulliDistribution.cpp:63
#define tReal
Definition: types.h:18
virtual tReal cdf(const tReal &x) const
compute the cumulative distribution function at x point
Definition: STAT_BernoulliDistribution.cpp:51
void setProperties(const tReal &p)
Definition: STAT_BernoulliDistribution.cpp:22
DEFINE_SPTR(STAT_BernoulliDistribution)
virtual void copy(const STAT_Distribution &d)
copy the distribution
Definition: STAT_BernoulliDistribution.h:82
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106