DiffGeometric Class Reference

This class simulates a "Differential %Geometric distribution". More...

#include <DiffGeometric.h>

Inheritance diagram for DiffGeometric:
Geometric RandomVar< long >

List of all members.

Public Member Functions

 DiffGeometric (double mean=0)
 Creates a new instance of the differential geometric random number generator and sets the probability for a single Bernoulli trial.
 DiffGeometric (double mean, RNG &r)
 Creates a new differential geometric random generator instance by using the pseudo random number generator "r" for the determination of random values and sets the probability for a single Bernoulli trial.
long operator() (double mean)
 For a given probability "mean" for a single Benoulli trial, this method returns a differential geometric random number as difference between two geometric random numbers (trial difference).
long operator() ()
 For the current probability for a single Benoulli trial stored in Geometric::pMean, this method returns a differential geometric random number as difference between two geometric random numbers (trial difference).
double p (const long &) const
 For a value "x" of trial difference, this method returns the probability as given by the distribution function.

Detailed Description

This class simulates a "Differential %Geometric distribution".

This class is derived from class Geometric and uses two geometric random numbers based on the same probability for a single Bernoulli trial. The differential geometric random number is then the subtraction of the two geometric random numbers, so you can interpret it as trial difference.
In contrast to class Geometric, the distribution function is here given by:

$ f(x) = ( p \cdot (1 - p)^{|x|} ) / (2 - p) $

where $p$ is the probability for a single Bernoulli trial as stored in Geometric::pMean.
Below you can see the distribution function for the probabilities $p = 0.2$, $p = 0.5$ and $p = 0.8$ for a single Bernoulli trial:

diffGeom.png
Author:
M. Kreutz
Date:
1995-01-01
Changes:
none
Status:
stable
Examples:

RngTest.cpp.

Definition at line 86 of file DiffGeometric.h.


Constructor & Destructor Documentation

DiffGeometric::DiffGeometric ( double  mean = 0  )  [inline]

Creates a new instance of the differential geometric random number generator and sets the probability for a single Bernoulli trial.

The probability Geometric::pMean for a single Bernoulli trial is set to mean.
For this instance, the default pseudo random number generator as member of class RandomVar is used.

Parameters:
mean the probability for a single Bernoulli trial, the default is "0"
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 117 of file DiffGeometric.h.

DiffGeometric::DiffGeometric ( double  mean,
RNG r 
) [inline]

Creates a new differential geometric random generator instance by using the pseudo random number generator "r" for the determination of random values and sets the probability for a single Bernoulli trial.

Each instance of a differential geometric random number generator is based on a generator, that is defined in class RNG and returns uniformally pseudo random numbers of the interval (0,1). By default, this is a global generator named RNG::globalRng and included as member in class RandomVar.
Here another pseudo random number generator r is used instead.
Additionally to defining the used pseudo random number generator, the probability Geometric::pMean for a single Bernoulli trial is set to mean.

Parameters:
mean the probability for a single Bernoulli trial
r the pseudo random number generator that is used
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Definition at line 152 of file DiffGeometric.h.


Member Function Documentation

long DiffGeometric::operator() (  )  [virtual]

For the current probability for a single Benoulli trial stored in Geometric::pMean, this method returns a differential geometric random number as difference between two geometric random numbers (trial difference).

Returns:
the differential geometric random number (trial difference)
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Reimplemented from Geometric.

Definition at line 93 of file DiffGeometric.cpp.

Referenced by operator()().

long DiffGeometric::operator() ( double  mean  ) 

For a given probability "mean" for a single Benoulli trial, this method returns a differential geometric random number as difference between two geometric random numbers (trial difference).

Returns:
the differential geometric random number (trial difference)
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Reimplemented from Geometric.

Definition at line 67 of file DiffGeometric.cpp.

References operator()().

double DiffGeometric::p ( const long &  x  )  const [virtual]

For a value "x" of trial difference, this method returns the probability as given by the distribution function.

Parameters:
x the trial difference
Returns:
the probability, that the trial difference is x
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Reimplemented from Geometric.

Examples:
RngTest.cpp.

Definition at line 117 of file DiffGeometric.cpp.

References Geometric::pMean.


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