poisson distribution¶
- group turbo_random_poisson
Functions
-
template<typename IntType, typename URBG>
IntType poisson(URBG &&urbg, double mean = 1.0)¶ turbo::poisson<T>(bitgen, mean = 1) turbo::poisson produces discrete probabilities for a given number of events occurring within a fixed interval within the closed interval [0, max].
Tmust be an integral type.See https://en.wikipedia.org/wiki/Poisson_distribution
Example:
cpp turbo::BitGen bitgen; ... int requests_per_minute = turbo::poisson<int>(bitgen, 3.2);
- Template Parameters:
IntType –
URBG –
- Parameters:
urbg –
mean –
- Returns:
IntType
-
template<typename IntType = int>
class poisson_distribution¶ - #include <poisson_distribution.h>
turbo::poisson_distribution<T> Generates discrete variates conforming to a Poisson distribution.
p(n) = (mean^n / n!) exp(-mean)
Depending on the parameter, the distribution selects one of the following algorithms:
The standard algorithm, attributed to Knuth, extended using a split method for larger values
The “Ratio of Uniforms as a convenient method for sampling from classical
discrete distributions”, Stadlober, 1989.
http://www.sciencedirect.com/science/article/pii/0377042790903495
NOTE: param_type.mean() is a double, which permits values larger than poisson_distribution<IntType>::max(), however this should be avoided and the distribution results are limited to the max() value.
The goals of this implementation are to provide good performance while still beig thread-safe: This limits the implementation to not using lgamma provided by <math.h>.
- Template Parameters:
IntType –
-
class param_type¶
-
template<typename IntType, typename URBG>