Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Functions Variables
discreteDistribution.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 DISCRETEDISTRIBUTION_H
17 #define DISCRETEDISTRIBUTION_H
18 
19 #include "Distribution.h"
20 
25 class discreteDistribution : public virtual Distribution {
26 
27  public:
28  // constructors
44  discreteDistribution( int sz, double* vals, double* probas );
45 
57  discreteDistribution( int sz, char *name );
58 
59  protected:
60  // partial constructors
69  discreteDistribution( int sz );
70 
71 public:
72  // destructor
80 
81 protected:
82  // specific variables
83  int _nbVals;
84  double* _values;
85  double* _probas;
87 public:
88  // accessors
89 
97  double getProba(int i);
98 
106  double getValue(int i);
107 
113  int nbVals() { return _nbVals; };
114 
123  bool setProba(int i, double v);
124 
125 public:
126  // probabilistic member functions
127 
133  double mean() { return _mean; };
134 
141  double rate(); // inverse of the mean
145  double moment( int order );
149  double laplace( double s ); // Laplace transform at real points
153  double dLaplace( double s ); // derivative of the Laplace transform
160  double cdf( double x );
167  bool hasMoment( int order );
168 
172  discreteDistribution *rescale( double factor );
177 
183  double sample();
184 
192  double distanceL2( discreteDistribution* d );
200  double distanceL1(discreteDistribution* d);
208 
209  public:
215  std::string toString();
222  void write( FILE *out, int mode );
223 
224 };
225 
226 #endif // DISCRETEDISTRIBUTION_H