Geometric Class Reference

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

#include <Geometric.h>

Inheritance diagram for Geometric:

RandomVar< long > DiffGeometric

List of all members.

Public Member Functions

 Geometric (double mean=0)
 Creates a new instance of the geometric random number generator and sets the probability for a single Bernoulli trial.
 Geometric (double mean, RNG &r)
 Creates a new 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.
double mean () const
 Returns the current probability for a single Bernoulli trial as stored in pMean.
void mean (double newMean)
 Sets the probability pMean for a single Bernoulli trial to "newMean".
long operator() (double mean)
 For a given probability "mean" for a single Benoulli trial, this method returns the number of trials after which the first success occurs.
long operator() ()
 For the current probability for a single Benoulli trial stored in pMean, this method returns the number of trials after which the first success occurs.
double p (const long &) const
 For a number of trials "x", this method returns the probability that the first success occurs after this number of trials.

Protected Attributes

double pMean
 The probability $p$ for a single Bernoulli trial.


Detailed Description

This class simulates a "%Geometric distribution".

This class is derived from class RandomVar and the uniformally distributed pseudo random number values of the interval (0,1) are transformed to type "long", simulating the geometric distribution.
The geometric distribution is based on the Bernoulli distribution, i.e. if you have a probability of $p$ for the occurrence of an event and following from this a probability of $(1-p)$ for the non-occurrence of this event and you are performing $x$ independantly Bernoulli trials, the geometric distribution gives you the number $x$ of trials after which the first success (event) occurs after $x-1$ fails (non-occurrences of the event). The probabilities for the first success at trial no. $x$ (the distribution function) is given for all $x > 0$ by:

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

For $x = 0$ the result is always $f(x) = 0$.
Below you can see the distribution function for the probabilities $p = 0.8$, $p = 0.5$ and $p = 0.2$ for a single Bernoulli trial:

geom.png

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

Constructor & Destructor Documentation

Geometric::Geometric ( double  mean = 0  ) 

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

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

The probability 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

Geometric::Geometric ( double  mean,
RNG r 
)

Creates a new 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.

Creates a new 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 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 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


Member Function Documentation

double Geometric::mean (  )  const [inline]

Returns the current probability for a single Bernoulli trial as stored in pMean.

Returns:
the probability pMean for a single Bernoulli trial
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

void Geometric::mean ( double  newMean  )  [inline]

Sets the probability pMean for a single Bernoulli trial to "newMean".

Parameters:
newMean the new probability for a single Bernoulli trial
Returns:
none
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

long Geometric::operator() ( double  mean  ) 

For a given probability "mean" for a single Benoulli trial, this method returns the number of trials after which the first success occurs.

For a given probability "mean" for a single Benoulli trial, this method returns the number of trials after which the first success occurs.

This method performs the inverse transformation of the original uniformally distributed random numbers of the interval (0,1) created by the used pseudo random number generator to the type of the geometric distribution.

Parameters:
mean the probability for a single Bernoulli trial
Returns:
the number of trials after which the first success occurs
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Reimplemented in DiffGeometric.

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

For the current probability for a single Benoulli trial stored in pMean, this method returns the number of trials after which the first success occurs.

For the current probability for a single Benoulli trial stored in pMean, this method returns the number of trials after which the first success occurs.

Returns:
the number of trials after which the first success occurs
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< long >.

Reimplemented in DiffGeometric.

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

For a number of trials "x", this method returns the probability that the first success occurs after this number of trials.

For a number of trials "x", this method returns the probability that the first success occurs after this number of trials.

Parameters:
x the number of trials after which the first success shall occur
Returns:
the probability, that the first success occurs after x trials
Author:
M. Kreutz
Date:
1995-01-01
Changes
none
Status
stable

Implements RandomVar< long >.

Reimplemented in DiffGeometric.


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

Generated on Thu Aug 28 18:34:46 2008 for Dolphin by  doxygen 1.5.6