summaryrefslogtreecommitdiff
path: root/abseil-cpp/absl/random/zipf_distribution.h
diff options
context:
space:
mode:
Diffstat (limited to 'abseil-cpp/absl/random/zipf_distribution.h')
-rw-r--r--abseil-cpp/absl/random/zipf_distribution.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/abseil-cpp/absl/random/zipf_distribution.h b/abseil-cpp/absl/random/zipf_distribution.h
index 22ebc75..03497b1 100644
--- a/abseil-cpp/absl/random/zipf_distribution.h
+++ b/abseil-cpp/absl/random/zipf_distribution.h
@@ -23,13 +23,14 @@
#include <type_traits>
#include "absl/random/internal/iostream_state_saver.h"
+#include "absl/random/internal/traits.h"
#include "absl/random/uniform_real_distribution.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
// absl::zipf_distribution produces random integer-values in the range [0, k],
-// distributed according to the discrete probability function:
+// distributed according to the unnormalized discrete probability function:
//
// P(x) = (v + x) ^ -q
//
@@ -94,7 +95,7 @@ class zipf_distribution {
double hxm_; // h(k + 0.5)
double hx0_minus_hxm_; // h(x0) - h(k + 0.5)
- static_assert(std::is_integral<IntType>::value,
+ static_assert(random_internal::IsIntegral<IntType>::value,
"Class-template absl::zipf_distribution<> must be "
"parameterized using an integral type.");
};
@@ -221,7 +222,7 @@ zipf_distribution<IntType>::operator()(
const double u = p.hxm_ + v * p.hx0_minus_hxm_;
const double x = p.hinv(u);
k = rint(x); // std::floor(x + 0.5);
- if (k > p.k()) continue; // reject k > max_k
+ if (k > static_cast<double>(p.k())) continue; // reject k > max_k
if (k - x <= p.s_) break;
const double h = p.h(k + 0.5);
const double r = p.pow_negative_q(p.v_ + k);