|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Geometric Distribution More...
#include <cassert>#include <cmath>#include <cstdint>#include <ctime>#include <iostream>#include <limits>#include <random>#include <vector>Classes | |
| class | probability::geometric_dist::geometric_distribution |
| A class to model the geometric distribution. More... | |
Namespaces | |
| namespace | probability |
| Probability algorithms. | |
| namespace | geometric_dist |
| Functions for the Geometric Distribution algorithm implementation. | |
Functions | |
| float | probability::geometric_dist::generate_uniform () |
| Returns a random number between [0,1]. More... | |
| void | sample_test (const probability::geometric_dist::geometric_distribution &dist) |
| Tests the sampling method of the geometric distribution. More... | |
| static void | test () |
| Self-test implementations. More... | |
| int | main () |
| Main function. More... | |
The geometric distribution models the experiment of doing Bernoulli trials until a sucess was observed. There are two formulations of the geometric distribution: 1) The probability distribution of the number X of Bernoulli trials needed to get one success, supported on the set { 1, 2, 3, ... } 2) The probability distribution of the number Y = X − 1 of failures before the first success, supported on the set { 0, 1, 2, 3, ... } Here, the first one is implemented.
Common variables used: p - The success probability k - The number of tries
| float probability::geometric_dist::generate_uniform | ( | ) |
| int main | ( | void | ) |
Main function.
| void sample_test | ( | const probability::geometric_dist::geometric_distribution & | dist | ) |
Tests the sampling method of the geometric distribution.
Draws 1000000 random samples and estimates mean and variance These should be close to the expected value and variance of the given distribution to pass.
| dist | The distribution to test |
|
static |
Self-test implementations.