absl::Zipf

Produces a random integral value from a Zipf distribution.

Synopsis

Declared in <absl/random/distributions.h>

template<
    typename IntType,
    typename URBG>
IntType
Zipf(
    URBG&& urbg,
    IntType hi = (std::numeric_limits<IntType>::max)(),
    double q = 2.0,
    double v = 1.0);

Description

absl::Zipf produces discrete probabilities commonly used for modelling of rare events over the closed interval [0, hi]. The parameters v and q determine the skew of the distribution. T must be an integral type, but may be inferred from the type of hi.

See http://mathworld.wolfram.com/ZipfDistribution.html

Example:

absl::BitGen bitgen; ... int term_rank = absl::Zipf<int>(bitgen);

Return Value

A random value drawn from the Zipf distribution.

Parameters

NameDescription
urbgThe uniform random bit generator.
hiThe inclusive upper bound of the interval.
qThe skew parameter of the distribution.
vThe shift parameter of the distribution.