#include <Geometric.h>
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 ![]() |
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 for the occurrence of an event and following from this a probability of
for the non-occurrence of this event and you are performing
independantly Bernoulli trials, the geometric distribution gives you the number
of trials after which the first success (event) occurs after
fails (non-occurrences of the event). The probabilities for the first success at trial no.
(the distribution function) is given for all
by:
For the result is always
.
Below you can see the distribution function for the probabilities ,
and
for a single Bernoulli trial:
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.
mean | the probability for a single Bernoulli trial, the default is "0" |
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.
mean | the probability for a single Bernoulli trial | |
r | the pseudo random number generator that is used |
double Geometric::mean | ( | ) | const [inline] |
void Geometric::mean | ( | double | newMean | ) | [inline] |
Sets the probability pMean for a single Bernoulli trial to "newMean".
newMean | the new probability for a single Bernoulli trial |
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.
mean | the probability for a single Bernoulli trial |
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.
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.
x | the number of trials after which the first success shall occur |
Implements RandomVar< long >.
Reimplemented in DiffGeometric.