tmp/tmpkaipu_rx/{from.md → to.md}
RENAMED
|
@@ -160,33 +160,45 @@ copy(v.begin(), v.end(), dest);
|
|
| 160 |
*Throws:* What and when `OutputIterator` operations of `dest` throw.
|
| 161 |
|
| 162 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 163 |
|
| 164 |
``` cpp
|
| 165 |
-
template<class RealType, size_t
|
| 166 |
RealType generate_canonical(URBG& g);
|
| 167 |
```
|
| 168 |
|
| 169 |
-
|
| 170 |
-
respectively. Calculates a quantity
|
| 171 |
-
$$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
|
| 172 |
-
\cdot R^i$$ using arithmetic of type `RealType`.
|
| 173 |
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
*Throws:* What and when `g` throws.
|
| 179 |
|
| 180 |
-
*Complexity:* Exactly k
|
| 181 |
-
where b[^6]
|
| 182 |
|
| 183 |
-
|
| 184 |
-
the value of `g.max()` - `g.min()` + 1.
|
| 185 |
-
|
| 186 |
-
[*Note 2*: If the values gᵢ produced by `g` are uniformly distributed,
|
| 187 |
the instantiation’s results are distributed as uniformly as possible.
|
| 188 |
Obtaining a value in this way can be a useful step in the process of
|
| 189 |
transforming a value generated by a uniform random bit generator into a
|
| 190 |
value that can be delivered by a random number
|
| 191 |
distribution. — *end note*]
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
*Throws:* What and when `OutputIterator` operations of `dest` throw.
|
| 161 |
|
| 162 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 163 |
|
| 164 |
``` cpp
|
| 165 |
+
template<class RealType, size_t digits, class URBG>
|
| 166 |
RealType generate_canonical(URBG& g);
|
| 167 |
```
|
| 168 |
|
| 169 |
+
Let
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
+
- r be `numeric_limits<RealType>::radix`,
|
| 172 |
+
- R be `g.max()` - `g.min()` + 1,
|
| 173 |
+
- d be the smaller of `digits` and
|
| 174 |
+
`numeric_limits<RealType>::digits`,[^6]
|
| 175 |
+
- k be the smallest integer such that Rᵏ ≥ rᵈ, and
|
| 176 |
+
- x be ⌊ Rᵏ / rᵈ ⌋.
|
| 177 |
|
| 178 |
+
An *attempt* is k invocations of `g()` to obtain values g₀, …, gₖ₋₁,
|
| 179 |
+
respectively, and the calculation of a quantity S given by :
|
| 180 |
+
|
| 181 |
+
*Effects:* Attempts are made until S < xrᵈ.
|
| 182 |
+
|
| 183 |
+
[*Note 1*: When R is a power of r, precisely one attempt is
|
| 184 |
+
made. — *end note*]
|
| 185 |
+
|
| 186 |
+
*Returns:* ⌊ S / x ⌋ / rᵈ.
|
| 187 |
+
|
| 188 |
+
[*Note 2*: The return value c satisfies 0 ≤ c < 1. — *end note*]
|
| 189 |
|
| 190 |
*Throws:* What and when `g` throws.
|
| 191 |
|
| 192 |
+
*Complexity:* Exactly k invocations of `g` per attempt.
|
|
|
|
| 193 |
|
| 194 |
+
[*Note 3*: If the values gᵢ produced by `g` are uniformly distributed,
|
|
|
|
|
|
|
|
|
|
| 195 |
the instantiation’s results are distributed as uniformly as possible.
|
| 196 |
Obtaining a value in this way can be a useful step in the process of
|
| 197 |
transforming a value generated by a uniform random bit generator into a
|
| 198 |
value that can be delivered by a random number
|
| 199 |
distribution. — *end note*]
|
| 200 |
|
| 201 |
+
[*Note 4*: When R is a power of r, an implementation can avoid using an
|
| 202 |
+
arithmetic type that is wider than the output when computing
|
| 203 |
+
S. — *end note*]
|
| 204 |
+
|