18 #ifndef FOEDUS_ASSORTED_ZIPFIAN_RANDOM_HPP_
19 #define FOEDUS_ASSORTED_ZIPFIAN_RANDOM_HPP_
39 double zeta(uint64_t n) {
41 for (uint64_t i = 0; i < n; i++) {
42 sum += 1 / std::pow(i + 1, theta_);
48 void init(uint64_t items,
double theta, uint64_t urnd_seed) {
52 alpha_ = 1.0 / (1.0 - theta_);
53 eta_ = (1 - std::pow(2.0 / items, 1 - theta_)) / (1 - zeta(2) / zetan_);
58 init(items, theta, urnd_seed);
64 double u = urnd_.
uniform_within(0, max_) /
static_cast<double>(max_);
65 double uz = u * zetan_;
70 if (uz < 1.0 + std::pow(0.5, theta_)) {
74 uint64_t ret =
static_cast<uint64_t
>(max_ * std::pow(eta_ * u - eta_ + 1, alpha_));
94 #endif // FOEDUS_ASSORTED_ZIPFIAN_RANDOM_HPP_
void set_current_seed(uint64_t seed)
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
uint64_t get_current_seed() const
void init(uint64_t items, double theta, uint64_t urnd_seed)
Forward declarations of classes in memory package.
A simple zipfian generator based off of YCSB's Java implementation.
ZipfianRandom(uint64_t items, double theta, uint64_t urnd_seed)