zipf distribution¶
- group turbo_random_zipf
Functions
-
template<typename IntType, typename URBG>
IntType zipf(URBG &&urbg, IntType hi = (std::numeric_limits<IntType>::max)(), double q = 2.0, double v = 1.0)¶ turbo::zipf<T>(bitgen, hi = max, q = 2, v = 1) turbo::zipf produces discrete probabilities commonly used for modelling of rare events over the closed interval [0, hi].
The parameters
vandqdetermine the skew of the distribution.Tmust be an integral type, but may be inferred from the type ofhi.See http://mathworld.wolfram.com/ZipfDistribution.html
Example:
turbo::BitGen bitgen; ... int term_rank = turbo::zipf<int>(bitgen);
- Template Parameters:
IntType –
URBG –
- Parameters:
urbg –
hi –
q – = 2 default
v –
- Returns:
IntType
-
template<typename IntType = int>
class zipf_distribution¶ - #include <zipf_distribution.h>
turbo::zipf_distribution produces random integer-values in the range [0, k], distributed according to the unnormalized discrete probability function:
P(x) = (v + x) ^ -q
The parameter
vmust be greater than 0 and the parameterqmust be greater than 1. If either of these parameters take invalid values then the behavior is undefined.IntType is the result_type generated by the generator. It must be of integral type; a static_assert ensures this is the case.
The implementation is based on W.Hormann, G.Derflinger:
“Rejection-Inversion to Generate Variates from Monotone Discrete
Distributions”
http://eeyore.wu-wien.ac.at/papers/96-04-04.wh-der.ps.gz
See also
- Template Parameters:
IntType – default is int
-
class param_type¶
-
template<typename IntType, typename URBG>