Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations
Public Member Functions | List of all members
BernoulliDistribution Class Reference
Inheritance diagram for BernoulliDistribution:
discreteDistribution Distribution

Public Member Functions

 BernoulliDistribution (double)
 
double getParameter ()
 
double mean ()
 
double rate ()
 
double moment (int n)
 
double variance ()
 
double laplace (double s)
 
double dLaplace (double s)
 
double cdf (double x)
 
bool hasMoment (int n)
 
BernoulliDistributionrescale (double factor)
 
BernoulliDistributioncopy ()
 
double sample ()
 
void iidSample (int n, double *s)
 
std::string toString ()
 
void write (FILE *out, int mode)
 
- Public Member Functions inherited from discreteDistribution
 discreteDistribution (int sz, double *vals, double *probs)
 Constructor from tables of values and probabilities. The mean is calculated at creation. More...
 
 discreteDistribution (int sz, char *name)
 Constructor for a general discrete distribution from a file. The file is assumed to contain only the probas. The values are arbitrarily chosen between 0 and sz-1 The mean is calculated at creation. More...
 
 ~discreteDistribution ()
 Destructor for a general discrete distribution. The convention is that internal arrays for values and probas are freed at this moment. If they are useful for something else, they sould be copied. More...
 
double getProba (int)
 Accessor for the probas. This is a pseudo-accessor since it performs additional checks. More...
 
double getValue (int)
 Accessor for the values. This is a pseudo-accessor since it performs additional checks. More...
 
int nbVals ()
 accessor to the number of values in the distribution More...
 
bool setProba (int, double)
 Accessor for the probas. This is a pseudo-accessor since it performs additional checks. More...
 
double mean ()
 Calculation of the mean. Returns the value since it is pre-computed. More...
 
double rate ()
 Calculation of the rate, which is the inverse of the mean. More...
 
double moment (int n)
 Calculation of the of order n. More...
 
double laplace (double s)
 Computation of the Laplace transform at some real point s. More...
 
double dLaplace (double s)
 Computation of the derivative of the Laplace transform at some real point s. More...
 
double cdf (double x)
 Computation of the cumulative density function at some real point x. More...
 
bool hasMoment (int n)
 Test of existence of a moment. These distributions always have one. More...
 
discreteDistributionrescale (double factor)
 Rescaling the law X by some real factor f. More...
 
discreteDistributioncopy ()
 Copying the law. More...
 
double sample ()
 Sampling from the law This is the straightforward, non optimized, linear-time algorithm. More...
 
void iidSample (int n, double *s)
 Iid samples from the law in a table The result is stored in a table, passed as an argument, that must have been allocated beforehand. More...
 
double distanceL2 (discreteDistribution *d)
 Computes the L2 distance between two distributions. In case of incompatible or infinite sizes, a negative number is returned. More...
 
double distanceL1 (discreteDistribution *d)
 Computes the L1 distance between this distribution and another one. In case of incompatible or infinite sizes, a negative number is returned. More...
 
double distanceLinfinity (discreteDistribution *d)
 Computes the L-infinity distance between two distributions. In case of incompatible or infinite sizes, a negative number is returned. More...
 
std::string toString ()
 Printing a representation of the law into a string. More...
 
void write (FILE *out, int mode)
 Printing a representation of the law. More...
 
- Public Member Functions inherited from Distribution
std::string getName ()
 
double variance ()
 
double ccdf (double x)
 
virtual double distanceL1 (Distribution *)
 
virtual bool hasProperty (std::string)
 
void fprint ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Distribution
static double u_0_1 (void)
 
static double exponential (double)
 
- Protected Member Functions inherited from discreteDistribution
 discreteDistribution (int)
 Constructor for a general discrete distribution from its size. Arrays are created to this size but not initialized. DANGEROUS to use since methods cannot check whether these arrays are correct or not. Use reserved to sub-types such as diracDistribution. More...
 
- Protected Attributes inherited from discreteDistribution
int _nbVals
 
double * _values
 
double * _probas
 

Constructor & Destructor Documentation

BernoulliDistribution::BernoulliDistribution ( double  val)
Parameters
doubleConstructor for a Bernoulli distribution. The mean is calculated at creation.
Author
Alain Jean-Marie
Parameters
valthe value P( X = 1 )
Returns
an object of type BernoulliDistribution

Member Function Documentation

double BernoulliDistribution::cdf ( double  x)
virtual
Parameters
x
Returns
double

Computation of the cumulative density function at some real point x

Author
Alain Jean-Marie
Parameters
xvalue at which the CDF is computed
Returns
CDF(x)

Implements Distribution.

BernoulliDistribution * BernoulliDistribution::copy ( )
virtual
Returns
BernoulliDistribution

Copying the law

Author
Alain Jean-Marie
Returns
a copy of the law

Implements Distribution.

double BernoulliDistribution::dLaplace ( double  s)
virtual
Parameters
s
Returns
double

Computation of the derivative of the Laplace transform at some real point s

Author
Alain Jean-Marie
Parameters
svalue at which the derivative is computed
Returns
d LT(s)/ds

Implements Distribution.

double BernoulliDistribution::getParameter ( )
inline
Returns
double
bool BernoulliDistribution::hasMoment ( int  order)
virtual
Parameters
n
Returns
bool

Test of existence of a moment. These distributions always have one.

Author
Alain Jean-Marie
Parameters
orderorder of the moment
Returns
true

Implements Distribution.

void BernoulliDistribution::iidSample ( int  nbSamples,
double *  sequence 
)
virtual
Parameters
n
sIid samples from the law in a table The result is stored in a table, passed as an argument, that must have been allocated beforehand
Author
Alain Jean-Marie
Parameters
nbSamplesnumber of values to draw
sequencethe table where the values are stored

Implements Distribution.

double BernoulliDistribution::laplace ( double  s)
virtual
Parameters
s
Returns
double

Computation of the Laplace transform at some real point s

Author
Alain Jean-Marie
Parameters
svalue at which the derivative is computed
Returns
LT(s)

Implements Distribution.

double BernoulliDistribution::mean ( )
virtual
Returns
double

Calculation of the mean. Returns the value since it is pre-computed

Author
Alain Jean-Marie
Returns
the mathematical expectation of the distribution

Implements Distribution.

double BernoulliDistribution::moment ( int  order)
virtual
Parameters
n
Returns
double

Calculation of the of order n

Author
Alain Jean-Marie
Parameters
orderorder of the moment
Returns
the moment

Implements Distribution.

double BernoulliDistribution::rate ( )
virtual
Returns
double

Calculation of the rate, which is the inverse of the mean

Author
Alain Jean-Marie
Returns
the rate

Implements Distribution.

BernoulliDistribution * BernoulliDistribution::rescale ( double  factor)
virtual
Parameters
factor
Returns
BernoulliDistribution

Rescaling the law X by some real factor f

Author
Alain Jean-Marie
Parameters
factorthe factor f
Returns
the law f*X

Implements Distribution.

double BernoulliDistribution::sample ( )
virtual
Returns
double

Sampling from the law This is the straightforward, non optimized, linear-time algorithm

Author
Alain Jean-Marie
Returns
a copy of the law

Implements Distribution.

std::string BernoulliDistribution::toString ( )
virtual
Returns
std::string

Printing a representation of the law into a string

Author
Alain Jean-Marie
Returns
a string

Implements Distribution.

double BernoulliDistribution::variance ( )
Returns
double
void BernoulliDistribution::write ( FILE *  out,
int  mode 
)
virtual
Parameters
out
modePrinting a representation of the law
Author
Alain Jean-Marie
Parameters
ostreamthe output stream
moderepresentation for the output

Implements Distribution.


The documentation for this class was generated from the following files: