Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
poissonDistribution.h
1 /* Marmote is free software: you can redistribute it and/or modify
2 it under the terms of the GNU General Public License as published by
3 the Free Software Foundation, either version 3 of the License, or
4 (at your option) any later version.
5 
6 Marmote is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10 
11 You should have received a copy of the GNU General Public License
12 along with Marmote. If not, see <http://www.gnu.org/licenses/>.
13 
14 Copyright 2015 Alain Jean-Marie, Jean-Michel Fourneau, Jean-Marc Vincent, Issam Rabhi */
15 
16 #ifndef poissonDistribution_H
17 #define poissonDistribution_H
18 
19 #include "Distribution.h"
20 #ifdef WITH_R
21 #include <RInside.h>
22 #endif
23 
31 class poissonDistribution : public virtual Distribution {
32 
33 public:
41  poissonDistribution( double lambda );
42 
48 
49 private:
50  // private variables specific to the distribution
51  double _lambda;
53 #ifdef WITH_R
54  static RInside* _Rmotor;
55 #else
56  typedef void* RInside;
57  static RInside* _Rmotor;
58 #endif
59 
60 private:
61  RInside* Rmotor();
62 
63 
64 public:
65  // accessors to specific variables
72  double getProba(double k );
73 
80  double lambda() { return _lambda; }
81 
82 public:
83  // probabilistic member functions
87  double mean();
91  double rate();
95  double moment( int order );
99  double variance();
103  double laplace( double s ); // Laplace transform at real points
107  double dLaplace( double s ); // derivative of the Laplace transform
111  double cdf( double x );
115  double ccdf( double x );
119  bool hasMoment( int order );
120 
124  poissonDistribution *rescale( double factor );
132  double sample();
136  void iidSample( int n, double* s );
137 
138  public:
142  std::string toString();
146  void write( FILE *out, int mode );
147 
148 };
149 
150 #endif // poissonDistribution_H
double ccdf(double x)
computing the complementary cumulative distributon function (or tail) at some real point x...
double sample()
Sample from the Poisson distibution. Uses the "R" package.
Definition: poissonDistribution.cpp:289
void write(FILE *out, int mode)
an utility to write the distribution to some file, according to some format.
Definition: poissonDistribution.cpp:227
void iidSample(int n, double *s)
drawing an i.i.d. sample from the distribution. The result is returned in an array (that must have be...
Definition: poissonDistribution.cpp:319
bool hasMoment(int order)
test for the existence of moments of any order
Definition: poissonDistribution.cpp:137
~poissonDistribution()
Destructor for a Poisson distribution.
Definition: poissonDistribution.cpp:38
std::string toString()
an utility to convert the distribution into a string.
Definition: poissonDistribution.cpp:250
double moment(int order)
Computing the moments of the distribution.
Definition: poissonDistribution.cpp:101
poissonDistribution(double lambda)
Constructor for a Poisson distribution from its "lambda" parameter. The mean is calculated at creatio...
Definition: poissonDistribution.cpp:27
double cdf(double x)
computing the cumulative distribution function at some real point x. This is the probability that the...
Definition: poissonDistribution.cpp:180
double variance()
Computing the variance of the random variable: the second moment minus the square of the first moment...
A class for representing probability distributions.
Definition: Distribution.h:44
poissonDistribution * rescale(double factor)
rescaling a distribution by some real factor. Not all distributions allow this for any real factor...
Definition: poissonDistribution.cpp:267
The Poisson distribution. The parameter is called "lambda". The Poisson distribution is discrete but ...
Definition: poissonDistribution.h:31
double mean()
computing the mathematical expectation or mean
Definition: poissonDistribution.cpp:74
poissonDistribution * copy()
copying a distribution. Typically implemented as rescale(1.0).
Definition: poissonDistribution.cpp:281
double getProba(double k)
Function to obtain the probability of a specific value k.
Definition: poissonDistribution.cpp:201
double laplace(double s)
computing the Laplace transform of the distribution at real point
Definition: poissonDistribution.cpp:148
double lambda()
Function to obtain the parameter (or ratio) of the distribution. Redundant with p() but defined to be...
Definition: poissonDistribution.h:80
double rate()
computing the "rate", defined as the inverse of the mean
Definition: poissonDistribution.cpp:85
double dLaplace(double s)
computing the derivative of the Laplace transform at real points
Definition: poissonDistribution.cpp:164