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
geometricDistribution Class Reference

The geometric distribution with starting value 0. The parameter "p" is called "ratio". More...

#include <geometricDistribution.h>

Inheritance diagram for geometricDistribution:
Distribution

Public Member Functions

 geometricDistribution (double p)
 Unique constructor for the class, from its "ratio". More...
 
double getProba (int k)
 Function to obtain the probability of a specific value k. More...
 
double p ()
 Function to obtain the parameter (or ratio) of the distribution. Redundant with p() but defined to be more explicit. More...
 
double getRatio ()
 Function to obtain the parameter (or ratio) of the distribution. Redundant with getRatio() but defined according to the coding convention. More...
 
double mean ()
 Function to obtain the mean (expectation). Its value is 1/(1-_p) More...
 
double rate ()
 
double moment (int order)
 Computing the moments of the distribution. 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)
 
bool hasMoment (int order)
 Test of existence of a moment. These distributions always have one. More...
 
geometricDistributionrescale (double factor)
 Rescaling the distribution. Geometric distributions cannot be rescaled. A copy is returned. A warning is issued if the factor is not 1.0. More...
 
geometricDistributioncopy ()
 copying a distribution. Typically implemented as rescale(1.0). More...
 
double sample ()
 Sampling from the distribution. The method uses the fact that the integer part of an exponential random variable is a geometric random variable. More...
 
std::string toString ()
 
void write (FILE *out, int mode)
 
- 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 Attributes inherited from Distribution
std::string _name
 
double _mean
 

Detailed Description

The geometric distribution with starting value 0. The parameter "p" is called "ratio".

Author
Alain Jean-Marie

Constructor & Destructor Documentation

geometricDistribution::geometricDistribution ( double  p)

Unique constructor for the class, from its "ratio".

Author
Alain Jean-Marie
Parameters
pthe probability of being larger than 0

Constructor for a geometric distribution The mean is calculated at creation. The value p = 1 is admitted, in which case the law is a Dirac at infinity and has no moments.

Author
Alain Jean-Marie
Parameters
pthe probability of being non 0
Returns
an object of type geometricDistribution

Member Function Documentation

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

Computation of the cumulative density function at some real point x. Based on the formula P(X >= k) = p^k for integer k so that P( X <= x ) = P( X <= floor(x) ) = 1 - P( X >= floor(x) + 1 ) = 1 - p^( floor(x) + 1 )

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

Implements Distribution.

geometricDistribution * geometricDistribution::copy ( )
virtual

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

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

Implements Distribution.

double geometricDistribution::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

Implements Distribution.

double geometricDistribution::getProba ( int  k)

Function to obtain the probability of a specific value k.

Parameters
kthe value at which the probability should be computed
Returns
double the probability that the random variable is k

Computation of the probability of some value

Author
Alain Jean-Marie
Parameters
kvalue at which the probability is computed
Returns
P( X = k )
double geometricDistribution::getRatio ( )
inline

Function to obtain the parameter (or ratio) of the distribution. Redundant with getRatio() but defined according to the coding convention.

Returns
double
bool geometricDistribution::hasMoment ( int  order)
virtual

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

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

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

Author
Alain Jean-Marie
Parameters
orderorder of the moment
Returns
true iff p < 1.0

Implements Distribution.

double geometricDistribution::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

Implements Distribution.

double geometricDistribution::mean ( )
virtual

Function to obtain the mean (expectation). Its value is 1/(1-_p)

See Also
geometricDistribution::_p
Returns
the mathematical expectation of the distribution

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 geometricDistribution::moment ( int  order)
virtual

Computing the moments of the distribution.

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

Implements Distribution.

double geometricDistribution::p ( )
inline

Function to obtain the parameter (or ratio) of the distribution. Redundant with p() but defined to be more explicit.

Returns
the value of the ratio
double geometricDistribution::rate ( )
virtual
Returns
double

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

Author
Alain Jean-Marie
Returns
the rate

Implements Distribution.

geometricDistribution * geometricDistribution::rescale ( double  factor)
virtual

Rescaling the distribution. Geometric distributions cannot be rescaled. A copy is returned. A warning is issued if the factor is not 1.0.

Parameters
factorthe factor by which to rescale
Returns
the rescaled distribution.

Implements Distribution.

double geometricDistribution::sample ( )
virtual

Sampling from the distribution. The method uses the fact that the integer part of an exponential random variable is a geometric random variable.

Returns
a sample from the geometric distribution

Implements Distribution.

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

Implements Distribution.

void geometricDistribution::write ( FILE *  out,
int  mode 
)
virtual
Parameters
out
mode

Implements Distribution.


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