Skip to content

Commit 8c5b0ac

Browse files
committed
Uniform range sampling: improve docs
Final part of #395
1 parent b418b61 commit 8c5b0ac

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/distributions/uniform.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ pub trait UniformImpl: Sized {
162162
/// this.
163163
///
164164
/// Via this method, implementations can provide a method optimized for
165-
/// sampling only a limited number of values from the range. The default
166-
/// implementation just sets up a `Uniform` with `UniformImpl::new` and samples
167-
/// from that.
165+
/// sampling only a single value from the specified range. The default
166+
/// implementation simply calls `UniformImpl::new` then `sample` on the
167+
/// result.
168168
fn sample_single<R: Rng + ?Sized>(low: Self::X, high: Self::X, rng: &mut R)
169169
-> Self::X
170170
{

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,11 @@ pub trait Rng: RngCore {
325325
/// `low` and exclusive of `high`.
326326
///
327327
/// This is a convenience wrapper around
328-
/// `distributions::Uniform`. If this function will be called
329-
/// repeatedly with the same arguments, one should use `Uniform`, as
330-
/// that will amortize the computations that allow for perfect
331-
/// uniformity, as they only happen when constructing the `Uniform`.
328+
/// `distributions::Uniform::sample_single`. If this function will be called
329+
/// repeatedly with the same arguments, it will likely be faster to
330+
/// construct a `Uniform` distribution object and sample from that; this
331+
/// allows amortization of the computations that allow for perfect
332+
/// uniformity within the `Uniform::new` constructor.
332333
///
333334
/// # Panics
334335
///

0 commit comments

Comments
 (0)