tmp/tmp30tcim9z/{from.md → to.md}
RENAMED
|
@@ -208,11 +208,11 @@ It is unspecified whether `D::param_type` is declared as a (nested)
|
|
| 208 |
`D::param_type` are in the form of `typedef`s for convenience of
|
| 209 |
exposition only.
|
| 210 |
|
| 211 |
`P` shall satisfy the requirements of `CopyConstructible` (Table
|
| 212 |
[[copyconstructible]]), `CopyAssignable` (Table [[copyassignable]]),
|
| 213 |
-
and EqualityComparable (Table [[equalitycomparable]]) types.
|
| 214 |
|
| 215 |
For each of the constructors of `D` taking arguments corresponding to
|
| 216 |
parameters of the distribution, `P` shall have a corresponding
|
| 217 |
constructor subject to the same requirements and taking arguments
|
| 218 |
identical in number, type, and default values. Moreover, for each of the
|
|
@@ -237,13 +237,13 @@ namespace std {
|
|
| 237 |
template<class UIntType, UIntType a, UIntType c, UIntType m>
|
| 238 |
class linear_congruential_engine;
|
| 239 |
|
| 240 |
// [rand.eng.mers], class template mersenne_twister_engine
|
| 241 |
template<class UIntType, size_t w, size_t n, size_t m, size_t r,
|
| 242 |
-
UIntType a, size_t u,
|
| 243 |
UIntType b, size_t t,
|
| 244 |
-
UIntType c, size_t l,
|
| 245 |
class mersenne_twister_engine;
|
| 246 |
|
| 247 |
// [rand.eng.sub], class template subtract_with_carry_engine
|
| 248 |
template<class UIntType, size_t w, size_t s, size_t r>
|
| 249 |
class subtract_with_carry_engine;
|
|
@@ -431,12 +431,12 @@ public:
|
|
| 431 |
|
| 432 |
// engine characteristics
|
| 433 |
static constexpr result_type multiplier = a;
|
| 434 |
static constexpr result_type increment = c;
|
| 435 |
static constexpr result_type modulus = m;
|
| 436 |
-
static constexpr result_type min() { return c == 0u ? 1u: 0u }
|
| 437 |
-
static constexpr result_type max() { return m - 1u }
|
| 438 |
static constexpr result_type default_seed = 1u;
|
| 439 |
|
| 440 |
// constructors and seeding functions
|
| 441 |
explicit linear_congruential_engine(result_type s = default_seed);
|
| 442 |
template<class Sseq> explicit linear_congruential_engine(Sseq& q);
|
|
@@ -962,11 +962,11 @@ typedef discard_block_engine<ranlux24_base, 223, 23>
|
|
| 962 |
default-constructed object of type `ranlux24` shall produce the value
|
| 963 |
9901578.
|
| 964 |
|
| 965 |
``` cpp
|
| 966 |
typedef discard_block_engine<ranlux48_base, 389, 11>
|
| 967 |
-
ranlux48
|
| 968 |
```
|
| 969 |
|
| 970 |
*Required behavior:* The $10000^{\,th}$ consecutive invocation of a
|
| 971 |
default-constructed object of type `ranlux48` shall produce the value
|
| 972 |
249142670248501.
|
|
@@ -1060,13 +1060,10 @@ these values are generated.
|
|
| 1060 |
|
| 1061 |
### Utilities <a id="rand.util">[[rand.util]]</a>
|
| 1062 |
|
| 1063 |
#### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
|
| 1064 |
|
| 1065 |
-
No function described in this section [[rand.util.seedseq]] throws an
|
| 1066 |
-
exception.
|
| 1067 |
-
|
| 1068 |
``` cpp
|
| 1069 |
class seed_seq
|
| 1070 |
{
|
| 1071 |
public:
|
| 1072 |
// types
|
|
@@ -1102,10 +1099,12 @@ seed_seq();
|
|
| 1102 |
```
|
| 1103 |
|
| 1104 |
*Effects:* Constructs a `seed_seq` object as if by default-constructing
|
| 1105 |
its member `v`.
|
| 1106 |
|
|
|
|
|
|
|
| 1107 |
``` cpp
|
| 1108 |
template<class T>
|
| 1109 |
seed_seq(initializer_list<T> il);
|
| 1110 |
```
|
| 1111 |
|
|
@@ -1146,18 +1145,23 @@ s = `v.size()` and n = `end` - `begin`, fills the supplied range
|
|
| 1146 |
[`begin`,`end`) according to the following algorithm in which each
|
| 1147 |
operation is to be carried out modulo 2³², each indexing operator
|
| 1148 |
applied to `begin` is to be taken modulo n, and T(x) is defined as
|
| 1149 |
$x \, \xor \, (x \, \rightshift \, 27)$:
|
| 1150 |
|
|
|
|
|
|
|
|
|
|
| 1151 |
``` cpp
|
| 1152 |
size_t size() const;
|
| 1153 |
```
|
| 1154 |
|
| 1155 |
*Returns:* The number of 32-bit units that would be returned by a call
|
| 1156 |
to `param()`.
|
| 1157 |
|
| 1158 |
-
*
|
|
|
|
|
|
|
| 1159 |
|
| 1160 |
``` cpp
|
| 1161 |
template<class OutputIterator>
|
| 1162 |
void param(OutputIterator dest) const;
|
| 1163 |
```
|
|
@@ -1172,10 +1176,12 @@ destination, as if by executing the following statement:
|
|
| 1172 |
|
| 1173 |
``` cpp
|
| 1174 |
copy(v.begin(), v.end(), dest);
|
| 1175 |
```
|
| 1176 |
|
|
|
|
|
|
|
| 1177 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 1178 |
|
| 1179 |
Each function instantiated from the template described in this section
|
| 1180 |
[[rand.util.canonical]] maps the result of one or more invocations of a
|
| 1181 |
supplied uniform random number generator `g` to one member of the
|
|
@@ -1412,11 +1418,11 @@ constructed.
|
|
| 1412 |
|
| 1413 |
A `binomial_distribution` random number distribution produces integer
|
| 1414 |
values i ≥ 0 distributed according to the discrete probability function
|
| 1415 |
$$%
|
| 1416 |
P(i\,|\,t,p)
|
| 1417 |
-
= {t
|
| 1418 |
\; \mbox{.}$$
|
| 1419 |
|
| 1420 |
``` cpp
|
| 1421 |
template<class IntType = int>
|
| 1422 |
class binomial_distribution
|
|
@@ -1528,11 +1534,11 @@ constructed.
|
|
| 1528 |
|
| 1529 |
A `negative_binomial_distribution` random number distribution produces
|
| 1530 |
random integers i ≥ 0 distributed according to the discrete probability
|
| 1531 |
function $$%
|
| 1532 |
P(i\,|\,k,p)
|
| 1533 |
-
= {k+i-1
|
| 1534 |
\; \mbox{.}$$
|
| 1535 |
|
| 1536 |
``` cpp
|
| 1537 |
template<class IntType = int>
|
| 1538 |
class negative_binomial_distribution
|
|
@@ -1702,13 +1708,11 @@ constructed.
|
|
| 1702 |
|
| 1703 |
A `gamma_distribution` random number distribution produces random
|
| 1704 |
numbers x > 0 distributed according to the probability density function
|
| 1705 |
$$%
|
| 1706 |
p(x\,|\,\alpha,\beta)
|
| 1707 |
-
= {
|
| 1708 |
-
\over {\beta^{\alpha} \cdot \Gamma(\alpha)}
|
| 1709 |
-
}
|
| 1710 |
\, \cdot \, x^{\, \alpha-1}
|
| 1711 |
\; \mbox{.}$$
|
| 1712 |
|
| 1713 |
``` cpp
|
| 1714 |
template<class RealType = double>
|
|
@@ -1782,11 +1786,11 @@ public:
|
|
| 1782 |
// types
|
| 1783 |
typedef RealType result_type;
|
| 1784 |
typedef unspecified param_type;
|
| 1785 |
|
| 1786 |
// constructor and reset functions
|
| 1787 |
-
explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0)
|
| 1788 |
explicit weibull_distribution(const param_type& parm);
|
| 1789 |
void reset();
|
| 1790 |
|
| 1791 |
// generating functions
|
| 1792 |
template<class URNG>
|
|
@@ -1897,11 +1901,11 @@ constructed.
|
|
| 1897 |
##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
|
| 1898 |
|
| 1899 |
A `normal_distribution` random number distribution produces random
|
| 1900 |
numbers x distributed according to the probability density function $$%
|
| 1901 |
p(x\,|\,\mu,\sigma)
|
| 1902 |
-
= {1
|
| 1903 |
\cdot
|
| 1904 |
% e^{-(x-\mu)^2 / (2\sigma^2)}
|
| 1905 |
\exp{\left(- \, \frac{(x - \mu)^2}
|
| 1906 |
{2 \sigma^2}
|
| 1907 |
\right)
|
|
@@ -2391,11 +2395,11 @@ $$%
|
|
| 2391 |
The n+1 distribution parameters bᵢ, also known as this distribution’s
|
| 2392 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 2393 |
i = 0, …, n-1. Unless specified otherwise, the remaining n distribution
|
| 2394 |
parameters are calculated as: $$%
|
| 2395 |
\rho_k = \;
|
| 2396 |
-
{w_k
|
| 2397 |
\; \mbox{ for } k = 0, \ldots, n\!-\!1,$$ in which the values wₖ,
|
| 2398 |
commonly known as the *weights* , shall be non-negative, non-NaN, and
|
| 2399 |
non-infinity. Moreover, the following relation shall hold:
|
| 2400 |
0 < S = w₀ + ⋯ + wₙ₋₁.
|
| 2401 |
|
|
@@ -2519,12 +2523,12 @@ k = 0, …, n-1.
|
|
| 2519 |
|
| 2520 |
A `piecewise_linear_distribution` random number distribution produces
|
| 2521 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 2522 |
[ bᵢ, bᵢ₊₁ ) according to the probability density function $$%
|
| 2523 |
p(x\,|\,b_0,\ldots,b_n,\;\rho_0,\ldots,\rho_n)
|
| 2524 |
-
= \rho_i \cdot {{b_{i+1} - x}
|
| 2525 |
-
+ \rho_{i+1} \cdot {{x - b_i}
|
| 2526 |
\; \mbox{,}
|
| 2527 |
\mbox{ for } b_i \le x < b_{i+1}
|
| 2528 |
\; \mbox{.}$$
|
| 2529 |
|
| 2530 |
The n+1 distribution parameters bᵢ, also known as this distribution’s
|
|
|
|
| 208 |
`D::param_type` are in the form of `typedef`s for convenience of
|
| 209 |
exposition only.
|
| 210 |
|
| 211 |
`P` shall satisfy the requirements of `CopyConstructible` (Table
|
| 212 |
[[copyconstructible]]), `CopyAssignable` (Table [[copyassignable]]),
|
| 213 |
+
and `EqualityComparable` (Table [[equalitycomparable]]) types.
|
| 214 |
|
| 215 |
For each of the constructors of `D` taking arguments corresponding to
|
| 216 |
parameters of the distribution, `P` shall have a corresponding
|
| 217 |
constructor subject to the same requirements and taking arguments
|
| 218 |
identical in number, type, and default values. Moreover, for each of the
|
|
|
|
| 237 |
template<class UIntType, UIntType a, UIntType c, UIntType m>
|
| 238 |
class linear_congruential_engine;
|
| 239 |
|
| 240 |
// [rand.eng.mers], class template mersenne_twister_engine
|
| 241 |
template<class UIntType, size_t w, size_t n, size_t m, size_t r,
|
| 242 |
+
UIntType a, size_t u, UIntType d, size_t s,
|
| 243 |
UIntType b, size_t t,
|
| 244 |
+
UIntType c, size_t l, UIntType f>
|
| 245 |
class mersenne_twister_engine;
|
| 246 |
|
| 247 |
// [rand.eng.sub], class template subtract_with_carry_engine
|
| 248 |
template<class UIntType, size_t w, size_t s, size_t r>
|
| 249 |
class subtract_with_carry_engine;
|
|
|
|
| 431 |
|
| 432 |
// engine characteristics
|
| 433 |
static constexpr result_type multiplier = a;
|
| 434 |
static constexpr result_type increment = c;
|
| 435 |
static constexpr result_type modulus = m;
|
| 436 |
+
static constexpr result_type min() { return c == 0u ? 1u: 0u; }
|
| 437 |
+
static constexpr result_type max() { return m - 1u; }
|
| 438 |
static constexpr result_type default_seed = 1u;
|
| 439 |
|
| 440 |
// constructors and seeding functions
|
| 441 |
explicit linear_congruential_engine(result_type s = default_seed);
|
| 442 |
template<class Sseq> explicit linear_congruential_engine(Sseq& q);
|
|
|
|
| 962 |
default-constructed object of type `ranlux24` shall produce the value
|
| 963 |
9901578.
|
| 964 |
|
| 965 |
``` cpp
|
| 966 |
typedef discard_block_engine<ranlux48_base, 389, 11>
|
| 967 |
+
ranlux48;
|
| 968 |
```
|
| 969 |
|
| 970 |
*Required behavior:* The $10000^{\,th}$ consecutive invocation of a
|
| 971 |
default-constructed object of type `ranlux48` shall produce the value
|
| 972 |
249142670248501.
|
|
|
|
| 1060 |
|
| 1061 |
### Utilities <a id="rand.util">[[rand.util]]</a>
|
| 1062 |
|
| 1063 |
#### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
|
| 1064 |
|
|
|
|
|
|
|
|
|
|
| 1065 |
``` cpp
|
| 1066 |
class seed_seq
|
| 1067 |
{
|
| 1068 |
public:
|
| 1069 |
// types
|
|
|
|
| 1099 |
```
|
| 1100 |
|
| 1101 |
*Effects:* Constructs a `seed_seq` object as if by default-constructing
|
| 1102 |
its member `v`.
|
| 1103 |
|
| 1104 |
+
*Throws:* Nothing.
|
| 1105 |
+
|
| 1106 |
``` cpp
|
| 1107 |
template<class T>
|
| 1108 |
seed_seq(initializer_list<T> il);
|
| 1109 |
```
|
| 1110 |
|
|
|
|
| 1145 |
[`begin`,`end`) according to the following algorithm in which each
|
| 1146 |
operation is to be carried out modulo 2³², each indexing operator
|
| 1147 |
applied to `begin` is to be taken modulo n, and T(x) is defined as
|
| 1148 |
$x \, \xor \, (x \, \rightshift \, 27)$:
|
| 1149 |
|
| 1150 |
+
*Throws:* What and when `RandomAccessIterator` operations of `begin` and
|
| 1151 |
+
`end` throw.
|
| 1152 |
+
|
| 1153 |
``` cpp
|
| 1154 |
size_t size() const;
|
| 1155 |
```
|
| 1156 |
|
| 1157 |
*Returns:* The number of 32-bit units that would be returned by a call
|
| 1158 |
to `param()`.
|
| 1159 |
|
| 1160 |
+
*Throws:* Nothing.
|
| 1161 |
+
|
| 1162 |
+
*Complexity:* Constant time.
|
| 1163 |
|
| 1164 |
``` cpp
|
| 1165 |
template<class OutputIterator>
|
| 1166 |
void param(OutputIterator dest) const;
|
| 1167 |
```
|
|
|
|
| 1176 |
|
| 1177 |
``` cpp
|
| 1178 |
copy(v.begin(), v.end(), dest);
|
| 1179 |
```
|
| 1180 |
|
| 1181 |
+
*Throws:* What and when `OutputIterator` operations of `dest` throw.
|
| 1182 |
+
|
| 1183 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 1184 |
|
| 1185 |
Each function instantiated from the template described in this section
|
| 1186 |
[[rand.util.canonical]] maps the result of one or more invocations of a
|
| 1187 |
supplied uniform random number generator `g` to one member of the
|
|
|
|
| 1418 |
|
| 1419 |
A `binomial_distribution` random number distribution produces integer
|
| 1420 |
values i ≥ 0 distributed according to the discrete probability function
|
| 1421 |
$$%
|
| 1422 |
P(i\,|\,t,p)
|
| 1423 |
+
= \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i}
|
| 1424 |
\; \mbox{.}$$
|
| 1425 |
|
| 1426 |
``` cpp
|
| 1427 |
template<class IntType = int>
|
| 1428 |
class binomial_distribution
|
|
|
|
| 1534 |
|
| 1535 |
A `negative_binomial_distribution` random number distribution produces
|
| 1536 |
random integers i ≥ 0 distributed according to the discrete probability
|
| 1537 |
function $$%
|
| 1538 |
P(i\,|\,k,p)
|
| 1539 |
+
= \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i
|
| 1540 |
\; \mbox{.}$$
|
| 1541 |
|
| 1542 |
``` cpp
|
| 1543 |
template<class IntType = int>
|
| 1544 |
class negative_binomial_distribution
|
|
|
|
| 1708 |
|
| 1709 |
A `gamma_distribution` random number distribution produces random
|
| 1710 |
numbers x > 0 distributed according to the probability density function
|
| 1711 |
$$%
|
| 1712 |
p(x\,|\,\alpha,\beta)
|
| 1713 |
+
= \frac{e^{-x/\beta}}{\beta^{\alpha} \cdot \Gamma(\alpha)}
|
|
|
|
|
|
|
| 1714 |
\, \cdot \, x^{\, \alpha-1}
|
| 1715 |
\; \mbox{.}$$
|
| 1716 |
|
| 1717 |
``` cpp
|
| 1718 |
template<class RealType = double>
|
|
|
|
| 1786 |
// types
|
| 1787 |
typedef RealType result_type;
|
| 1788 |
typedef unspecified param_type;
|
| 1789 |
|
| 1790 |
// constructor and reset functions
|
| 1791 |
+
explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0);
|
| 1792 |
explicit weibull_distribution(const param_type& parm);
|
| 1793 |
void reset();
|
| 1794 |
|
| 1795 |
// generating functions
|
| 1796 |
template<class URNG>
|
|
|
|
| 1901 |
##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
|
| 1902 |
|
| 1903 |
A `normal_distribution` random number distribution produces random
|
| 1904 |
numbers x distributed according to the probability density function $$%
|
| 1905 |
p(x\,|\,\mu,\sigma)
|
| 1906 |
+
= \frac{1}{\sigma \sqrt{2\pi}}
|
| 1907 |
\cdot
|
| 1908 |
% e^{-(x-\mu)^2 / (2\sigma^2)}
|
| 1909 |
\exp{\left(- \, \frac{(x - \mu)^2}
|
| 1910 |
{2 \sigma^2}
|
| 1911 |
\right)
|
|
|
|
| 2395 |
The n+1 distribution parameters bᵢ, also known as this distribution’s
|
| 2396 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 2397 |
i = 0, …, n-1. Unless specified otherwise, the remaining n distribution
|
| 2398 |
parameters are calculated as: $$%
|
| 2399 |
\rho_k = \;
|
| 2400 |
+
\frac{w_k}{S \cdot (b_{k+1}-b_k)}
|
| 2401 |
\; \mbox{ for } k = 0, \ldots, n\!-\!1,$$ in which the values wₖ,
|
| 2402 |
commonly known as the *weights* , shall be non-negative, non-NaN, and
|
| 2403 |
non-infinity. Moreover, the following relation shall hold:
|
| 2404 |
0 < S = w₀ + ⋯ + wₙ₋₁.
|
| 2405 |
|
|
|
|
| 2523 |
|
| 2524 |
A `piecewise_linear_distribution` random number distribution produces
|
| 2525 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 2526 |
[ bᵢ, bᵢ₊₁ ) according to the probability density function $$%
|
| 2527 |
p(x\,|\,b_0,\ldots,b_n,\;\rho_0,\ldots,\rho_n)
|
| 2528 |
+
= \rho_i \cdot {\frac{b_{i+1} - x}{b_{i+1} - b_i}}
|
| 2529 |
+
+ \rho_{i+1} \cdot {\frac{x - b_i}{b_{i+1} - b_i}}
|
| 2530 |
\; \mbox{,}
|
| 2531 |
\mbox{ for } b_i \le x < b_{i+1}
|
| 2532 |
\; \mbox{.}$$
|
| 2533 |
|
| 2534 |
The n+1 distribution parameters bᵢ, also known as this distribution’s
|