Skip to content

Commit 4d67af2

Browse files
committed
Zipf: Mention that rounding may occur
1 parent 6270248 commit 4d67af2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rand_distr/src/zipf.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ impl<F> Zipf<F>
142142
where F: Float, Standard: Distribution<F>, OpenClosed01: Distribution<F> {
143143
/// Construct a new `Zipf` distribution for a set with `n` elements and a
144144
/// frequency rank exponent `s`.
145+
///
146+
/// For large `n`, rounding may occur to fit the number into the float type.
145147
#[inline]
146148
pub fn new(n: u64, s: F) -> Result<Zipf<F>, ZipfError> {
147149
if !(s >= F::zero()) {
@@ -150,7 +152,7 @@ where F: Float, Standard: Distribution<F>, OpenClosed01: Distribution<F> {
150152
if n < 1 {
151153
return Err(ZipfError::NTooSmall);
152154
}
153-
let n = F::from(n).unwrap(); // FIXME
155+
let n = F::from(n).unwrap(); // This does not fail.
154156
let t = if s != F::one() {
155157
(n.powf(F::one() - s) - s) / (F::one() - s)
156158
} else {

0 commit comments

Comments
 (0)