TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
A class to model the geometric distribution. More...
Public Member Functions | |
geometric_distribution (const float &p) | |
Constructor for the geometric distribution. | |
float | expected_value () const |
The expected value of a geometrically distributed random variable X. | |
float | variance () const |
The variance of a geometrically distributed random variable X. | |
float | standard_deviation () const |
The standard deviation of a geometrically distributed random variable X. | |
float | probability_density (const uint32_t &k) const |
The probability density function. | |
float | cumulative_distribution (const uint32_t &k) const |
The cumulative distribution function. | |
float | inverse_cumulative_distribution (const float &cdf) const |
The inverse cumulative distribution function. | |
uint32_t | draw_sample () const |
Generates a (discrete) sample according to the geometrical distribution. | |
float | range_tries (const uint32_t &min_tries=1, const uint32_t &max_tries=std::numeric_limits< uint32_t >::max()) const |
This function computes the probability to have success in a given range of tries. | |
Private Attributes | |
float | p |
The succes probability p. | |
A class to model the geometric distribution.
Definition at line 55 of file geometric_dist.cpp.
|
inlineexplicit |
Constructor for the geometric distribution.
p | The success probability |
Definition at line 64 of file geometric_dist.cpp.
|
inline |
The cumulative distribution function.
The sum of all probabilities up to (and including) k trials. Basically CDF(k) = P(x <= k)
k | The number of trials in [1,\infty) |
Definition at line 104 of file geometric_dist.cpp.
|
inline |
Generates a (discrete) sample according to the geometrical distribution.
Definition at line 125 of file geometric_dist.cpp.
|
inline |
The expected value of a geometrically distributed random variable X.
Definition at line 71 of file geometric_dist.cpp.
|
inline |
The inverse cumulative distribution function.
This functions answers the question: Up to how many trials are needed to have success with a probability of cdf? The exact floating point value is reported.
cdf | The probability in [0,1] |
Definition at line 116 of file geometric_dist.cpp.
|
inline |
The probability density function.
As we use the first definition of the geometric series (1), we are doing k - 1 failed trials and the k-th trial is a success.
k | The number of trials to observe the first success in [1,\infty) |
Definition at line 93 of file geometric_dist.cpp.
|
inline |
This function computes the probability to have success in a given range of tries.
Computes P(min_tries <= x <= max_tries). Can be used to calculate P(x >= min_tries) by not passing a second argument. Can be used to calculate P(x <= max_tries) by passing 1 as the first argument
min_tries | The minimum number of tries in [1,\infty) (inclusive) |
max_tries | The maximum number of tries in [min_tries, \infty) (inclusive) |
Definition at line 145 of file geometric_dist.cpp.
|
inline |
The standard deviation of a geometrically distributed random variable X.
Definition at line 84 of file geometric_dist.cpp.
|
inline |
The variance of a geometrically distributed random variable X.
Definition at line 77 of file geometric_dist.cpp.
|
private |
The succes probability p.
Definition at line 57 of file geometric_dist.cpp.