Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Functions Variables
Distribution.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 DISTRIBUTION_H
17 #define DISTRIBUTION_H
18 
19 #include <math.h>
20 #include <stdio.h>
21 #include <string>
22 #include <vector>
23 #include "../marmoteConstants.h"
24 
25 // Definition of +oo for durations and rates
26 #define INFINITE_DURATION HUGE_VAL
27 #define INFINITE_RATE HUGE_VAL
28 
29 // Definitions for printing styles
30 #define NO_PRINT_MODE 0
31 #define DEFAULT_PRINT_MODE 1
32 #define NORMAL_PRINT_MODE 1
33 #define QNAP_PRINT_MODE 2
34 #define PROSIT_PRINT_MODE 3
35 #define MMPP_PRINT_MODE 4
36 #define PNED_PRINT_MODE 5
37 #define MAPLE_PRINT_MODE 6
38 
39 // Definition of the class
44 class Distribution {
45 
46  protected:
47  std::string _name;
49  protected:
50  // Distribution();
51  // Distribution( Distribution d ); // copy
52 
53  public:
57  virtual ~Distribution() {};
58 
59 public:
60  // accessors
66  std::string name() { return _name; };
67 
68  public:
69  // probabilistic member functions
75  virtual double mean() = 0;
81  virtual double rate() = 0;
88  virtual double moment( int order ) = 0;
97  double variance();
104  virtual double laplace( double s ) = 0;
111  virtual double dLaplace( double s ) = 0;
119  virtual double cdf( double x ) = 0;
129  double ccdf( double x ) { return 1.0 - cdf(x); };
136  virtual bool hasMoment( int order ) = 0;
137 
148  virtual Distribution* rescale( double factor ) = 0;
155  virtual Distribution* copy() = 0;
161  virtual double sample() = 0;
171  void iidSample( int n, double* s );
172 
179  virtual double distanceL1( Distribution* d );
180 
190  virtual bool hasProperty( std::string pro );
191  /* functions existing in the ERS package, not implemented yet
192  Law_Desc Parse_Law( char Nom, Liste_Reel Params,
193  Liste_Reel Params2, Law_List The_SubLaws );
194  int Parse_Law_From_Args ( char**, int, int, Law_Desc );
195  Law_List Append_Law( Law_List, Law_Desc New_Law );
196  */
197 
198  public:
199  // standard pseudo-random generators
206  static double u_0_1(void);
214  static double exponential(double mean);
215 
216  public:
222  virtual std::string toString() = 0;
230  virtual void write( FILE *out, int mode ) = 0;
231  // virtual void fprint() = 0;
236  void fprint() { write( stdout, NORMAL_PRINT_MODE ); }
237 
238  protected:
239  double _mean;
241 };
242 
243 #endif // DISTRIBUTION_H