Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Functions Variables
Public Member Functions | List of all members
uniformDiscreteDistribution Class Reference

The uniform discrete distribution. More...

#include <uniformDiscreteDistribution.h>

Inheritance diagram for uniformDiscreteDistribution:
discreteDistribution Distribution

Public Member Functions

 uniformDiscreteDistribution (int valInf, int valSup)
 The unique constructor for the uniform discrete distribution on some interval [a..b]. More...
 
int valInf ()
 Read accessor to the lower end of the interval. More...
 
int valSup ()
 Read accessor to the upper end of the interval. More...
 
double mean ()
 computing the mathematical expectation or mean More...
 
double rate ()
 computing the "rate", defined as the inverse of the mean More...
 
double moment (int order)
 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...
 
double laplace (double s)
 computing the Laplace transform of the distribution at real point More...
 
double dLaplace (double s)
 computing the derivative of the Laplace transform at real points More...
 
double cdf (double x)
 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...
 
bool hasMoment (int order)
 test for the existence of moments of any order More...
 
uniformDiscreteDistributionrescale (double factor)
 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...
 
uniformDiscreteDistributioncopy ()
 copying a distribution. Typically implemented as rescale(1.0). More...
 
double sample ()
 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...
 
std::string toString ()
 an utility to convert the distribution into a string. More...
 
void write (FILE *out, int mode)
 an utility to write the distribution to some file, according to some format. More...
 
- Public Member Functions inherited from discreteDistribution
 discreteDistribution (int sz, double *vals, double *probas)
 Constructor for a general discrete distribution from arrays. The array is ***copied***, not taken as pointer. 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 i)
 Read accessor for the probas. This is a pseudo-accessor since it performs additional checks. More...
 
double getValue (int i)
 Read accessor for the values. This is a pseudo-accessor since it performs additional checks. More...
 
int nbVals ()
 Read accessor to the number of values in the distribution. More...
 
bool setProba (int i, double v)
 Write accessor for the probas. This is a pseudo-accessor since it performs additional checks. 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...
 
- Public Member Functions inherited from Distribution
virtual ~Distribution ()
 Standard destructor. More...
 
std::string name ()
 Read accessor to the type name 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...
 
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...
 
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...
 
void fprint ()
 write on stdout with NORMAL_PRINT_MODE More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Distribution
static double u_0_1 (void)
 
static double exponential (double mean)
 
- Protected Member Functions inherited from discreteDistribution
 discreteDistribution (int sz)
 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
 

Detailed Description

The uniform discrete distribution.

Constructor & Destructor Documentation

uniformDiscreteDistribution::uniformDiscreteDistribution ( int  valInf,
int  valSup 
)

The unique constructor for the uniform discrete distribution on some interval [a..b].

Parameters
valInfthe lower bound (a)
valSupthe upper bound (b)

Constructor for a discrete uniform distribution on [a..b] The mean is calculated at creation.

Author
Alain Jean-Marie
Parameters
valInfthe value of a
valSupthe value of b
Returns
an object of type uniformDiscreteDistribution

Member Function Documentation

double uniformDiscreteDistribution::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.

Parameters
xthe value at which to compute the ccdf
Returns
the value of the ccdf
double uniformDiscreteDistribution::cdf ( double  x)
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

Reimplemented from discreteDistribution.

uniformDiscreteDistribution * uniformDiscreteDistribution::copy ( )
virtual

copying a distribution. Typically implemented as rescale(1.0).

See Also
rescale(double)
Returns
a copy of the distribution

Reimplemented from discreteDistribution.

double uniformDiscreteDistribution::dLaplace ( double  s)
virtual

computing the derivative of the Laplace transform at real points

Parameters
sthe value at which to compute
Returns
the value of the derivative of the Laplace transform

Reimplemented from discreteDistribution.

bool uniformDiscreteDistribution::hasMoment ( int  order)
virtual

test for the existence of moments of any order

Parameters
orderthe order of the moment to be tested
Returns
true if the moment exists, false otherwise

Reimplemented from discreteDistribution.

void uniformDiscreteDistribution::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
double uniformDiscreteDistribution::laplace ( double  s)
virtual

computing the Laplace transform of the distribution at real point

Parameters
sthe value at which to compute
Returns
the value of the Laplace transform

Reimplemented from discreteDistribution.

double uniformDiscreteDistribution::mean ( )
virtual

computing the mathematical expectation or mean

Returns
the mean

Reimplemented from discreteDistribution.

double uniformDiscreteDistribution::moment ( int  order)
virtual

Computing the moments of the distribution.

Parameters
orderthe order of the moment to be computed
Returns
the moment

Reimplemented from discreteDistribution.

double uniformDiscreteDistribution::rate ( )
virtual

computing the "rate", defined as the inverse of the mean

Returns
the rate

Reimplemented from discreteDistribution.

uniformDiscreteDistribution * uniformDiscreteDistribution::rescale ( double  factor)
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

Reimplemented from discreteDistribution.

double uniformDiscreteDistribution::sample ( )
virtual

drawing a (pseudo)random value according to the distribution.

Returns
a sample

Reimplemented from discreteDistribution.

std::string uniformDiscreteDistribution::toString ( )
virtual

an utility to convert the distribution into a string.

Returns
the string representing the distribution.

Reimplemented from discreteDistribution.

int uniformDiscreteDistribution::valInf ( )

Read accessor to the lower end of the interval.

Returns
the lower end of the interval
int uniformDiscreteDistribution::valSup ( )

Read accessor to the upper end of the interval.

Returns
the upper end of the interval
double uniformDiscreteDistribution::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
void uniformDiscreteDistribution::write ( FILE *  out,
int  mode 
)
virtual

an utility to write the distribution to some file, according to some format.

Parameters
outthe file descriptor of the file
modea code for the format to be used

Reimplemented from discreteDistribution.


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