Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
|
A class for representing probability distributions. More...
#include <Distribution.h>
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 Distribution * | rescale (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 Distribution * | copy ()=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 Distribution * | rescale (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 Distribution * | copy ()=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 |
A class for representing probability distributions.
|
inlinevirtual |
Standard destructor.
|
inlinevirtual |
Standard destructor.
|
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.
x | the value at which to compute the ccdf |
|
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.
x | the value at which to compute the ccdf |
|
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.
x | the value at which to compute the cdf |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
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.
x | the value at which to compute the cdf |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
copying a distribution. Typically implemented as rescale(1.0).
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
pure virtual |
copying a distribution. Typically implemented as rescale(1.0).
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
virtual |
Computing generally the L1 distance between distributions.
d | the distribution with which the distance is computed |
|
virtual |
Computing generally the L1 distance between distributions.
d | the distribution with which the distance is computed |
|
pure virtual |
computing the derivative of the Laplace transform at real points
s | the value at which to compute |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, geometricDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
computing the derivative of the Laplace transform at real points
s | the value at which to compute |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, geometricDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
static |
The generator for exponential distributions. Warning: the parameter is the mean.
mean | the average (not the rate) |
|
static |
The generator for exponential distributions. Warning: the parameter is the mean.
mean | the average (not the rate) |
|
inline |
write on stdout with NORMAL_PRINT_MODE
|
inline |
write on stdout with NORMAL_PRINT_MODE
|
pure virtual |
test for the existence of moments of any order
order | the order of the moment to be tested |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, geometricDistribution, bernoulliDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
pure virtual |
test for the existence of moments of any order
order | the order of the moment to be tested |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, geometricDistribution, bernoulliDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
virtual |
Property test function. Current properties are:
pro | a string/key for the property to be tested |
|
virtual |
Property test function. Current properties are:
pro | a string/key for the property to be tested |
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().
n | the number of values to sample |
s | an 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().
n | the number of values to sample |
s | an array to be filled with the sample |
|
pure virtual |
computing the Laplace transform of the distribution at real point
s | the value at which to compute |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, geometricDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
computing the Laplace transform of the distribution at real point
s | the value at which to compute |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, geometricDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
computing the mathematical expectation or mean
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, geometricDistribution, exponentialDistribution, diracDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, exponentialDistribution, diracDistribution, and templateDistribution.
|
pure virtual |
computing the mathematical expectation or mean
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, geometricDistribution, exponentialDistribution, diracDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, exponentialDistribution, diracDistribution, and templateDistribution.
|
pure virtual |
Computing the moments of the distribution.
order | the order of the moment to be computed |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, geometricDistribution, uniformDistribution, diracDistribution, exponentialDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, diracDistribution, exponentialDistribution, and templateDistribution.
|
pure virtual |
Computing the moments of the distribution.
order | the order of the moment to be computed |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, geometricDistribution, uniformDistribution, diracDistribution, exponentialDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, uniformDistribution, diracDistribution, exponentialDistribution, and templateDistribution.
|
inline |
Read accessor to the type name of the distribution.
|
inline |
Read accessor to the type name of the distribution.
|
pure virtual |
computing the "rate", defined as the inverse of the mean
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, exponentialDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
computing the "rate", defined as the inverse of the mean
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, bernoulliDistribution, uniformDiscreteDistribution, geometricDistribution, uniformDistribution, diracDistribution, templateDistribution, bernoulliDistribution, uniformDiscreteDistribution, exponentialDistribution, uniformDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
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).
factor | the real factor to be used |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
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).
factor | the real factor to be used |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, uniformDiscreteDistribution, geometricDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
pure virtual |
drawing a (pseudo)random value according to the distribution.
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
pure virtual |
drawing a (pseudo)random value according to the distribution.
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, exponentialDistribution, uniformDiscreteDistribution, bernoulliDistribution, uniformDistribution, templateDistribution, diracDistribution, and exponentialDistribution.
|
pure virtual |
an utility to convert the distribution into a string.
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
pure virtual |
an utility to convert the distribution into a string.
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, templateDistribution, exponentialDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, templateDistribution, and exponentialDistribution.
|
static |
The generator for the uniform distribution on [0,1]. Serves as the building block for most sampling algorithms.
|
static |
The generator for the uniform distribution on [0,1]. Serves as the building block for most sampling algorithms.
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.
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.
|
pure virtual |
an utility to write the distribution to some file, according to some format.
out | the file descriptor of the file |
mode | a code for the format to be used |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, exponentialDistribution, templateDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, exponentialDistribution, and templateDistribution.
|
pure virtual |
an utility to write the distribution to some file, according to some format.
out | the file descriptor of the file |
mode | a code for the format to be used |
Implemented in discreteDistribution, discreteDistribution, geometricDistribution, geometricDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, exponentialDistribution, templateDistribution, uniformDiscreteDistribution, uniformDistribution, bernoulliDistribution, diracDistribution, exponentialDistribution, and templateDistribution.
|
protected |
TODO
|
protected |
a string uniquely representing the distribution