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_
18 
19 #include "Distribution.h"
20 
27 class geometricDistribution : public virtual Distribution {
28 
29 public:
30  // constructors
36  geometricDistribution( double p );
37 
38 private:
39  // specific variables
40  double _p;
42 public:
43  // accessors
50  double getProba( int k );
57  double p() { return _p; }
64  double getRatio() { return _p; }
65 
66 public:
67  // probabilistic member functions
73  double mean();
79  double rate(); // inverse of the mean
83  double moment( int order );
87  double laplace( double s ); // Laplace transform at real points
91  double dLaplace( double s ); // derivative of the Laplace transform
98  double cdf( double x );
105  bool hasMoment( int order );
106 
113  geometricDistribution *rescale( double factor );
118 
126  double sample();
127 
128  public:
134  std::string toString();
141  void write( FILE *out, int mode );
142 
143 };
144 
145 #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:260
double laplace(double s)
computing the Laplace transform of the distribution at real point
Definition: geometricDistribution.cpp:142
double dLaplace(double s)
computing the derivative of the Laplace transform at real points
Definition: geometricDistribution.cpp:158
double getProba(int k)
Function to obtain the probability of a specific value k.
Definition: geometricDistribution.cpp:194
double cdf(double x)
Definition: geometricDistribution.cpp:177
geometricDistribution * rescale(double factor)
Rescaling the distribution. Geometric distributions cannot be rescaled. A copy is returned...
Definition: geometricDistribution.cpp:237
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:224
The geometric distribution with starting value 0. The parameter "p" is called "ratio".
Definition: geometricDistribution.h:27
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:57
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:64
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:131
geometricDistribution * copy()
copying a distribution. Typically implemented as rescale(1.0).
Definition: geometricDistribution.cpp:252
void write(FILE *out, int mode)
Definition: geometricDistribution.cpp:205