|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -//! Generating random samples from [probability distributions]. |
| 11 | +//! Generating random samples from probability distributions. |
12 | 12 | //!
|
13 | 13 | //! This module is the home of the [`Distribution`] trait and several of its
|
14 |
| -//! implementations, which is the workhorse behind some of the convenient |
| 14 | +//! implementations. It is the workhorse behind some of the convenient |
15 | 15 | //! functionality of the [`Rng`] trait, including [`gen`], [`gen_range`] and
|
16 | 16 | //! of course [`sample`].
|
17 |
| -//! |
18 |
| -//! Abstractly, a probability distribution describes the probability of |
| 17 | +//! |
| 18 | +//! Abstractly, a [probability distribution] describes the probability of |
19 | 19 | //! occurance of each value in its sample space.
|
| 20 | +//! |
20 | 21 | //! More concretely, an implementation of `Distribution<T>` for type `X` is an
|
21 | 22 | //! algorithm for choosing values from the sample space (a subset of `T`)
|
22 | 23 | //! according to the distribution `X` represents, using an external source of
|
23 | 24 | //! randomness (an RNG supplied to the `sample` function).
|
| 25 | +//! |
24 | 26 | //! A type `X` may implement `Distribution<T>` for multiple types `T`.
|
25 | 27 | //! Any type implementing [`Distribution`] is stateless (i.e. immutable),
|
26 | 28 | //! but it may have internal parameters set at construction time (for example,
|
|
35 | 37 | //! types, tuples, arrays, and a few derived types. See the documentation of
|
36 | 38 | //! [`Standard`] for more details.
|
37 | 39 | //!
|
38 |
| -//! It is possible to implement `Distribution<T>` for [`Standard`] for user |
39 |
| -//! types `T`; doing so makes it possible to generate type `T` with |
40 |
| -//! [`Rng::gen()`], and by extension also with the [`random()`] function. |
| 40 | +//! Implementing `Distribution<T>` for [`Standard`] for user types `T` makes it |
| 41 | +//! possible to generate type `T` with [`Rng::gen()`], and by extension also |
| 42 | +//! with the [`random()`] function. |
41 | 43 | //!
|
42 | 44 | //!
|
43 | 45 | //! # Distribution to sample from a `Uniform` range
|
|
49 | 51 | //!
|
50 | 52 | //! Values may be sampled from this distribution using [`Rng::gen_range`] or
|
51 | 53 | //! by creating a distribution object with [`Uniform::new`],
|
52 |
| -//! [`Uniform::new_inclusive`] or `From<Range>`; |
53 |
| -//! when the range limits are not known at compile time it is typically faster |
54 |
| -//! to reuse an existing distribution object than to call [`Rng::gen_range`]. |
| 54 | +//! [`Uniform::new_inclusive`] or `From<Range>`. When the range limits are not |
| 55 | +//! known at compile time it is typically faster to reuse an existing |
| 56 | +//! distribution object than to call [`Rng::gen_range`]. |
55 | 57 | //!
|
56 | 58 | //! User types `T` may also implement `Distribution<T>` for [`Uniform`],
|
57 | 59 | //! although this is less straightforward than for [`Standard`] (see the
|
|
126 | 128 | //! }
|
127 | 129 | //! ```
|
128 | 130 | //!
|
129 |
| -//! |
130 |
| -//! [probability distributions]: https://en.wikipedia.org/wiki/Probability_distribution |
| 131 | +//! |
| 132 | +//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution |
131 | 133 | //! [`Distribution`]: trait.Distribution.html
|
132 | 134 | //! [`gen_range`]: ../trait.Rng.html#method.gen_range
|
133 | 135 | //! [`gen`]: ../trait.Rng.html#method.gen
|
|
0 commit comments