Fix comment in LogUniform range sampler

PiperOrigin-RevId: 254481247
This commit is contained in:
Eugene Brevdo 2019-06-21 15:36:32 -07:00 committed by TensorFlower Gardener
parent cc6639d9a3
commit 2b57377402

View File

@ -160,9 +160,11 @@ LogUniformSampler::LogUniformSampler(int64 range)
int64 LogUniformSampler::Sample(random::SimplePhilox* rnd) const {
const int64 value =
static_cast<int64>(exp(rnd->RandDouble() * log_range_)) - 1;
CHECK_GE(value, 0);
DCHECK_GE(value, 0);
// Mathematically, value should be <= range_, but might not be due to some
// floating point roundoff, so we mod by range_.
// floating point roundoff, so we mod by range_. In practice this case
// happens never regardless of the value of range_, including and up to
// DBL_MAX. But we include it as a guarantee of the function's output.
return value % range_;
}