Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Distribution Class Referenceabstract

A class for representing probability distributions. More...

#include <Distribution.h>

Inheritance diagram for Distribution:
discreteDistribution discreteDistribution exponentialDistribution exponentialDistribution geometricDistribution geometricDistribution templateDistribution templateDistribution uniformDistribution uniformDistribution

Public Member Functions

virtual ~Distribution ()
 Standard destructor. More...
 
std::string name ()
 Read accessor to the type name of the distribution. More...
 
virtual double mean ()=0
 computing the mathematical expectation or mean More...
 
virtual double rate ()=0
 computing the "rate", defined as the inverse of the mean More...
 
virtual double moment (int order)=0
 Computing the moments of the distribution. More...
 
double variance ()
 Computing the variance of the random variable: the second moment minus the square of the first moment. Variance is the square of the coefficient of variation. The Distribution class offers a default implementation. More...
 
virtual double laplace (double s)=0
 computing the Laplace transform of the distribution at real point More...
 
virtual double dLaplace (double s)=0
 computing the derivative of the Laplace transform at real points More...
 
virtual double cdf (double x)=0
 computing the cumulative distribution function at some real point x. This is the probability that the random variable is less or equal to x. More...
 
double ccdf (double x)
 computing the complementary cumulative distributon function (or tail) at some real point x. This is the probability that the random variable is strictly larger than x. The Distribution class offers a default implementation. More...
 
virtual bool hasMoment (int order)=0
 test for the existence of moments of any order More...
 
virtual Distributionrescale (double factor)=0
 rescaling a distribution by some real factor. Not all distributions allow this for any real factor. If the operation fails, or if the factor is 1.0, a copy of the distribution should be returned (not by using the copy() function). More...
 
virtual Distributioncopy ()=0
 copying a distribution. Typically implemented as rescale(1.0). More...
 
virtual double sample ()=0
 drawing a (pseudo)random value according to the distribution. More...
 
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 been already allocated) passed as a parameter. The Distribution class offers the default implementation with repeated call to sample(). More...
 
virtual double distanceL1 (Distribution *d)
 Computing generally the L1 distance between distributions. More...
 
virtual bool hasProperty (std::string pro)
 Property test function. Current properties are: More...
 
virtual std::string toString ()=0
 an utility to convert the distribution into a string. More...
 
virtual void write (FILE *out, int mode)=0
 an utility to write the distribution to some file, according to some format. More...
 
void fprint ()
 write on stdout with NORMAL_PRINT_MODE More...
 
virtual ~Distribution ()
 Standard destructor. More...
 
std::string name ()
 Read accessor to the type name of the distribution. More...
 
virtual double mean ()=0
 computing the mathematical expectation or mean More...
 
virtual double rate ()=0
 computing the "rate", defined as the inverse of the mean More...
 
virtual double moment (int order)=0
 Computing the moments of the distribution. More...
 
double variance ()
 Computing the variance of the random variable: the second moment minus the square of the first moment. Variance is the square of the coefficient of variation. The Distribution class offers a default implementation. More...
 
virtual double laplace (double s)=0
 computing the Laplace transform of the distribution at real point More...
 
virtual double dLaplace (double s)=0
 computing the derivative of the Laplace transform at real points More...
 
virtual double cdf (double x)=0
 computing the cumulative distribution function at some real point x. This is the probability that the random variable is less or equal to x. More...
 
double ccdf (double x)
 computing the complementary cumulative distributon function (or tail) at some real point x. This is the probability that the random variable is strictly larger than x. The Distribution class offers a default implementation. More...
 
virtual bool hasMoment (int order)=0
 test for the existence of moments of any order More...
 
virtual Distributionrescale (double factor)=0
 rescaling a distribution by some real factor. Not all distributions allow this for any real factor. If the operation fails, or if the factor is 1.0, a copy of the distribution should be returned (not by using the copy() function). More...
 
virtual Distributioncopy ()=0
 copying a distribution. Typically implemented as rescale(1.0). More...
 
virtual double sample ()=0
 drawing a (pseudo)random value according to the distribution. More...
 
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 been already allocated) passed as a parameter. The Distribution class offers the default implementation with repeated call to sample(). More...
 
virtual double distanceL1 (Distribution *d)
 Computing generally the L1 distance between distributions. More...
 
virtual bool hasProperty (std::string pro)
 Property test function. Current properties are: More...
 
virtual std::string toString ()=0
 an utility to convert the distribution into a string. More...
 
virtual void write (FILE *out, int mode)=0
 an utility to write the distribution to some file, according to some format. More...
 
void fprint ()
 write on stdout with NORMAL_PRINT_MODE More...
 

Static Public Member Functions

static double u_0_1 (void)
 
static double exponential (double mean)
 
static double u_0_1 (void)
 
static double exponential (double mean)
 

Protected Attributes

std::string _name
 
double _mean
 

Detailed Description

A class for representing probability distributions.

Constructor & Destructor Documentation

virtual Distribution::~Distribution ( )
inlinevirtual

Standard destructor.

virtual Distribution::~Distribution ( )
inlinevirtual

Standard destructor.

Member Function Documentation

double Distribution::ccdf ( double  x)
inline

computing the complementary cumulative distributon function (or tail) at some real point x. This is the probability that the random variable is strictly larger than x. The Distribution class offers a default implementation.

Parameters
xthe value at which to compute the ccdf
Returns
the value of the ccdf
double Distribution::ccdf ( double  x)
inline

computing the complementary cumulative distributon function (or tail) at some real point x. This is the probability that the random variable is strictly larger than x. The Distribution class offers a default implementation.

Parameters
xthe value at which to compute the ccdf
Returns
the value of the ccdf
virtual double Distribution::cdf ( double  x)
pure virtual

computing the cumulative distribution function at some real point x. This is the probability that the random variable is less or equal to x.

Parameters
xthe value at which to compute the cdf
Returns
the value of the cdf

Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.

virtual double Distribution::cdf ( double  x)
pure virtual

computing the cumulative distribution function at some real point x. This is the probability that the random variable is less or equal to x.

Parameters
xthe value at which to compute the cdf
Returns
the value of the cdf

Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.

virtual Distribution* Distribution::copy ( )
pure virtual
virtual Distribution* Distribution::copy ( )
pure virtual
virtual double Distribution::distanceL1 ( Distribution d)
virtual

Computing generally the L1 distance between distributions.

Author
Alain Jean-Marie
Parameters
dthe distribution with which the distance is computed
Returns
the distance
double Distribution::distanceL1 ( Distribution d)
virtual

Computing generally the L1 distance between distributions.

Author
Alain Jean-Marie
Parameters
dthe distribution with which the distance is computed
Returns
the distance
virtual double Distribution::dLaplace ( double  s)
pure virtual
virtual double Distribution::dLaplace ( double  s)
pure virtual
static double Distribution::exponential ( double  mean)
static

The generator for exponential distributions. Warning: the parameter is the mean.

Author
Alain Jean-Marie
Parameters
meanthe average (not the rate)
Returns
a sample of the Exponential distribution with the given mean
double Distribution::exponential ( double  mean)
static

The generator for exponential distributions. Warning: the parameter is the mean.

Author
Alain Jean-Marie
Parameters
meanthe average (not the rate)
Returns
a sample of the Exponential distribution with the given mean
void Distribution::fprint ( )
inline

write on stdout with NORMAL_PRINT_MODE

void Distribution::fprint ( )
inline

write on stdout with NORMAL_PRINT_MODE

virtual bool Distribution::hasMoment ( int  order)
pure virtual
virtual bool Distribution::hasMoment ( int  order)
pure virtual
virtual bool Distribution::hasProperty ( std::string  pro)
virtual

Property test function. Current properties are:

  • discreteDistribution: tests if the distribution is discrete and finite
  • discrete: tests if the distribution is discrete
  • continuous: tests if the distribution is continuous.
    Author
    Alain Jean-Marie
    Parameters
    proa string/key for the property to be tested
    Returns
    true if the distribution has the property, false otherwise
bool Distribution::hasProperty ( std::string  pro)
virtual

Property test function. Current properties are:

  • discreteDistribution: tests if the distribution is discrete and finite
  • discrete: tests if the distribution is discrete
  • continuous: tests if the distribution is continuous.
    Author
    Alain Jean-Marie
    Parameters
    proa string/key for the property to be tested
    Returns
    true if the distribution has the property, false otherwise
void Distribution::iidSample ( int  n,
double *  s 
)

drawing an i.i.d. sample from the distribution. The result is returned in an array (that must have been already allocated) passed as a parameter. The Distribution class offers the default implementation with repeated call to sample().

Parameters
nthe number of values to sample
san array to be filled with the sample
void Distribution::iidSample ( int  n,
double *  s 
)

drawing an i.i.d. sample from the distribution. The result is returned in an array (that must have been already allocated) passed as a parameter. The Distribution class offers the default implementation with repeated call to sample().

Parameters
nthe number of values to sample
san array to be filled with the sample
virtual double Distribution::laplace ( double  s)
pure virtual
virtual double Distribution::laplace ( double  s)
pure virtual
virtual double Distribution::mean ( )
pure virtual
virtual double Distribution::mean ( )
pure virtual
virtual double Distribution::moment ( int  order)
pure virtual
virtual double Distribution::moment ( int  order)
pure virtual
std::string Distribution::name ( )
inline

Read accessor to the type name of the distribution.

Returns
the name
std::string Distribution::name ( )
inline

Read accessor to the type name of the distribution.

Returns
the name
virtual double Distribution::rate ( )
pure virtual
virtual double Distribution::rate ( )
pure virtual
virtual Distribution* Distribution::rescale ( double  factor)
pure virtual

rescaling a distribution by some real factor. Not all distributions allow this for any real factor. If the operation fails, or if the factor is 1.0, a copy of the distribution should be returned (not by using the copy() function).

See also
copy()
Parameters
factorthe real factor to be used
Returns
a new distribution object

Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.

virtual Distribution* Distribution::rescale ( double  factor)
pure virtual

rescaling a distribution by some real factor. Not all distributions allow this for any real factor. If the operation fails, or if the factor is 1.0, a copy of the distribution should be returned (not by using the copy() function).

See also
copy()
Parameters
factorthe real factor to be used
Returns
a new distribution object

Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.

virtual double Distribution::sample ( )
pure virtual
virtual double Distribution::sample ( )
pure virtual
virtual std::string Distribution::toString ( )
pure virtual
virtual std::string Distribution::toString ( )
pure virtual
static double Distribution::u_0_1 ( void  )
static

The generator for the uniform distribution on [0,1]. Serves as the building block for most sampling algorithms.

Author
Alain Jean-Marie
Returns
a sample of the Uniform([0,1]) distribution
double Distribution::u_0_1 ( void  )
static

The generator for the uniform distribution on [0,1]. Serves as the building block for most sampling algorithms.

Author
Alain Jean-Marie
Returns
a sample of the Uniform([0,1]) distribution
double Distribution::variance ( )

Computing the variance of the random variable: the second moment minus the square of the first moment. Variance is the square of the coefficient of variation. The Distribution class offers a default implementation.

Returns
the variance
double Distribution::variance ( )

Computing the variance of the random variable: the second moment minus the square of the first moment. Variance is the square of the coefficient of variation. The Distribution class offers a default implementation.

Returns
the variance
virtual void Distribution::write ( FILE *  out,
int  mode 
)
pure virtual
virtual void Distribution::write ( FILE *  out,
int  mode 
)
pure virtual

Member Data Documentation

double Distribution::_mean
protected

TODO

std::string Distribution::_name
protected

a string uniquely representing the distribution


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