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].

T must 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>
IntType poisson(double mean = 1.0)

turbo::poisson<T>(mean = 1) similar to turbo::poisson<T>(bitgen, mean = 1), using a thread-local generator.

Template Parameters:

IntType

Parameters:

mean

Returns:

IntType

template<typename IntType>
IntType fast_poisson(double mean = 1.0)

turbo::poisson<T>(mean = 1) similar to turbo::poisson<T>(bitgen, mean = 1), using a thread-local generator.

Template Parameters:

IntType

Parameters:

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:

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