Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
geometricDistribution.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 geometricDistribution_H
17 #define geometricDistribution_H
18 
19 #include "Distribution.h"
20 
28 class geometricDistribution : public virtual Distribution {
29 
30 public:
31  // constructors
37  geometricDistribution( double p );
38 
39 private:
40  // specific variables
41  double _p;
43 public:
44  // accessors
51  double getProba(double k );
58  double p() { return _p; }
65  double getRatio() { return _p; }
66 
67 public:
68  // probabilistic member functions
74  double mean();
80  double rate(); // inverse of the mean
84  double moment( int order );
88  double laplace( double s ); // Laplace transform at real points
92  double dLaplace( double s ); // derivative of the Laplace transform
99  double cdf( double x );
106  bool hasMoment( int order );
107 
114  geometricDistribution *rescale( double factor );
119 
127  double sample();
128 
129  public:
135  std::string toString();
142  void write( FILE *out, int mode );
143 
144 };
145 
146 #endif // geometricDistribution_H
double sample()
Sampling from the distribution. The method uses the fact that the integer part of an exponential rand...
Definition: geometricDistribution.cpp:266
double laplace(double s)
computing the Laplace transform of the distribution at real point
Definition: geometricDistribution.cpp:146
double dLaplace(double s)
computing the derivative of the Laplace transform at real points
Definition: geometricDistribution.cpp:162
double cdf(double x)
Definition: geometricDistribution.cpp:181
geometricDistribution * rescale(double factor)
Rescaling the distribution. Geometric distributions cannot be rescaled. A copy is returned...
Definition: geometricDistribution.cpp:243
A class for representing probability distributions.
Definition: Distribution.h:44
geometricDistribution(double p)
Unique constructor for the class, from its "ratio".
Definition: geometricDistribution.cpp:29
std::string toString()
Definition: geometricDistribution.cpp:230
The geometric distribution with starting value 0. The parameter "p" is called "ratio". The Geometric distribution is discrete but does not inherit from discreteDistribution because its range is infinite.
Definition: geometricDistribution.h:28
double rate()
Definition: geometricDistribution.cpp:68
double p()
Function to obtain the parameter (or ratio) of the distribution. Redundant with p() but defined to be...
Definition: geometricDistribution.h:58
double moment(int order)
Computing the moments of the distribution.
Definition: geometricDistribution.cpp:89
double getRatio()
Function to obtain the parameter (or ratio) of the distribution. Redundant with getRatio() but define...
Definition: geometricDistribution.h:65
double mean()
Function to obtain the mean (expectation). Its value is 1/(1-_p)
Definition: geometricDistribution.cpp:57
bool hasMoment(int order)
Test of existence of a moment. These distributions always have one.
Definition: geometricDistribution.cpp:135
double getProba(double k)
Function to obtain the probability of a specific value k.
Definition: geometricDistribution.cpp:198
geometricDistribution * copy()
copying a distribution. Typically implemented as rescale(1.0).
Definition: geometricDistribution.cpp:258
void write(FILE *out, int mode)
Definition: geometricDistribution.cpp:211