44 #ifndef THRILL_COMMON_ZIPF_DISTRIBUTION_HEADER 45 #define THRILL_COMMON_ZIPF_DISTRIBUTION_HEADER 93 template <
typename Engine>
97 size_t N()
const {
return N_; }
100 double q()
const {
return q_; }
103 double s()
const {
return s_; }
106 size_t min()
const {
return 1; }
121 LOG1 <<
"s (" << s <<
") must be greater than 0.0.";
125 std::vector<double> probs(N);
128 for (
size_t k = 1; k < N + 1; ++k) {
129 double prob = 1.0 / std::pow(static_cast<double>(k) + q, s);
134 double p_norm = 1.0 / p_sum;
135 for (
size_t i = 0; i <
N; ++i) {
139 return dist_type(probs.begin(), probs.end());
146 #endif // !THRILL_COMMON_ZIPF_DISTRIBUTION_HEADER size_t max() const
maximum value (inclusive) of distribution
ZipfDistribution()=default
create uninitialized object. be careful.
std::discrete_distribution< size_t > dist_type
size_t min() const
minimum value of distribution
A class for producing random integers distributed according to the Zipf-Mandelbrot probability mass f...
double s() const
parameter of distribution
size_t N() const
deliver population size
static dist_type make_dist(size_t N, double s, double q)
ZipfDistribution(const size_t N, const double s, const double q=0)
Creates a new Zipf-Mandelbrot distribution given s, q, N.
size_t operator()(Engine &eng)
pick next random number in the range [1,num)
double q() const
parameter of distribution