Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
uniformDiscreteDistribution.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 uniformDiscreteDistribution_H
17 #define uniformDiscreteDistribution_H
18 
19 #include "discreteDistribution.h"
20 
26 
27  public:
35 
36 private:
37  int _valInf;
38  int _valSup;
39  int _span;
40  bool _isConstant;
42 public:
43  // accessors to specific variables
49  int valInf();
55  int valSup();
56 
57  public: // probabilistic member functions
61  double mean();
65  double rate();
69  double moment( int order );
73  double variance();
77  double laplace( double s );
81  double dLaplace( double s ); // derivative of the Laplace transform
85  double cdf( double x );
89  double ccdf( double x );
93  bool hasMoment( int order );
94 
98  uniformDiscreteDistribution *rescale( double factor );
106  double sample();
110  void iidSample( int n, double* s );
111 
112  public:
116  std::string toString();
120  void write( FILE *out, int mode );
121 
122 };
123 
124 #endif // uniformDiscreteDistribution_H
bool hasMoment(int order)
test for the existence of moments of any order
Definition: uniformDiscreteDistribution.cpp:112
double moment(int order)
Computing the moments of the distribution.
Definition: uniformDiscreteDistribution.cpp:74
double sample()
drawing a (pseudo)random value according to the distribution.
Definition: uniformDiscreteDistribution.cpp:236
uniformDiscreteDistribution * copy()
copying a distribution. Typically implemented as rescale(1.0).
Definition: uniformDiscreteDistribution.cpp:226
double dLaplace(double s)
computing the derivative of the Laplace transform at real points
Definition: uniformDiscreteDistribution.cpp:140
int valSup()
Read accessor to the upper end of the interval.
double laplace(double s)
computing the Laplace transform of the distribution at real point
Definition: uniformDiscreteDistribution.cpp:120
uniformDiscreteDistribution * rescale(double factor)
rescaling a distribution by some real factor. Not all distributions allow this for any real factor...
Definition: uniformDiscreteDistribution.cpp:208
double ccdf(double x)
computing the complementary cumulative distributon function (or tail) at some real point x...
double rate()
computing the "rate", defined as the inverse of the mean
Definition: uniformDiscreteDistribution.cpp:58
double variance()
Computing the variance of the random variable: the second moment minus the square of the first moment...
uniformDiscreteDistribution(int valInf, int valSup)
The unique constructor for the uniform discrete distribution on some interval [a..b].
Definition: uniformDiscreteDistribution.cpp:28
void write(FILE *out, int mode)
an utility to write the distribution to some file, according to some format.
Definition: uniformDiscreteDistribution.cpp:181
The uniform discrete distribution.
Definition: uniformDiscreteDistribution.h:25
double mean()
computing the mathematical expectation or mean
Definition: uniformDiscreteDistribution.cpp:49
std::string toString()
an utility to convert the distribution into a string.
Definition: uniformDiscreteDistribution.cpp:194
The general discrete distribution with finite support.
Definition: discreteDistribution.h:25
int valInf()
Read accessor to the lower end of the interval.
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: uniformDiscreteDistribution.cpp:246
double cdf(double x)
computing the cumulative distribution function at some real point x. This is the probability that the...
Definition: uniformDiscreteDistribution.cpp:163