tmp/tmpwu2yi550/{from.md → to.md}
RENAMED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
### Random number distribution class templates <a id="rand.dist">[[rand.dist]]</a>
|
| 2 |
|
| 3 |
-
####
|
| 4 |
|
| 5 |
-
Each type instantiated from a class template specified in
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
Descriptions are provided in
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
The algorithms for producing each of the specified distributions are
|
| 17 |
*implementation-defined*.
|
| 18 |
|
| 19 |
The value of each probability density function p(z) and of each discrete
|
|
@@ -24,11 +24,11 @@ outside its stated domain.
|
|
| 24 |
|
| 25 |
##### Class template `uniform_int_distribution` <a id="rand.dist.uni.int">[[rand.dist.uni.int]]</a>
|
| 26 |
|
| 27 |
A `uniform_int_distribution` random number distribution produces random
|
| 28 |
integers i, a ≤ i ≤ b, distributed according to the constant discrete
|
| 29 |
-
probability function
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
namespace std {
|
| 33 |
template<class IntType = int>
|
| 34 |
class uniform_int_distribution {
|
|
@@ -61,14 +61,16 @@ namespace std {
|
|
| 61 |
result_type max() const;
|
| 62 |
|
| 63 |
// inserters and extractors
|
| 64 |
template<class charT, class traits>
|
| 65 |
friend basic_ostream<charT, traits>&
|
| 66 |
-
operator<<(basic_ostream<charT, traits>& os,
|
|
|
|
| 67 |
template<class charT, class traits>
|
| 68 |
friend basic_istream<charT, traits>&
|
| 69 |
-
operator>>(basic_istream<charT, traits>& is,
|
|
|
|
| 70 |
};
|
| 71 |
}
|
| 72 |
```
|
| 73 |
|
| 74 |
``` cpp
|
|
@@ -96,11 +98,11 @@ constructed.
|
|
| 96 |
|
| 97 |
##### Class template `uniform_real_distribution` <a id="rand.dist.uni.real">[[rand.dist.uni.real]]</a>
|
| 98 |
|
| 99 |
A `uniform_real_distribution` random number distribution produces random
|
| 100 |
numbers x, a ≤ x < b, distributed according to the constant probability
|
| 101 |
-
density function
|
| 102 |
|
| 103 |
[*Note 1*: This implies that p(x | a,b) is undefined when
|
| 104 |
`a == b`. — *end note*]
|
| 105 |
|
| 106 |
``` cpp
|
|
@@ -174,15 +176,11 @@ constructed.
|
|
| 174 |
#### Bernoulli distributions <a id="rand.dist.bern">[[rand.dist.bern]]</a>
|
| 175 |
|
| 176 |
##### Class `bernoulli_distribution` <a id="rand.dist.bern.bernoulli">[[rand.dist.bern.bernoulli]]</a>
|
| 177 |
|
| 178 |
A `bernoulli_distribution` random number distribution produces `bool`
|
| 179 |
-
values b distributed according to the discrete probability function
|
| 180 |
-
$$P(b\,|\,p) = \left\{ \begin{array}{ll}
|
| 181 |
-
p & \text{ if $b = \tcode{true}$, or} \\
|
| 182 |
-
1 - p & \text{ if $b = \tcode{false}$.}
|
| 183 |
-
\end{array}\right.$$
|
| 184 |
|
| 185 |
``` cpp
|
| 186 |
namespace std {
|
| 187 |
class bernoulli_distribution {
|
| 188 |
public:
|
|
@@ -240,11 +238,11 @@ constructed.
|
|
| 240 |
|
| 241 |
##### Class template `binomial_distribution` <a id="rand.dist.bern.bin">[[rand.dist.bern.bin]]</a>
|
| 242 |
|
| 243 |
A `binomial_distribution` random number distribution produces integer
|
| 244 |
values i ≥ 0 distributed according to the discrete probability function
|
| 245 |
-
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
namespace std {
|
| 249 |
template<class IntType = int>
|
| 250 |
class binomial_distribution {
|
|
@@ -312,11 +310,11 @@ constructed.
|
|
| 312 |
|
| 313 |
##### Class template `geometric_distribution` <a id="rand.dist.bern.geo">[[rand.dist.bern.geo]]</a>
|
| 314 |
|
| 315 |
A `geometric_distribution` random number distribution produces integer
|
| 316 |
values i ≥ 0 distributed according to the discrete probability function
|
| 317 |
-
|
| 318 |
|
| 319 |
``` cpp
|
| 320 |
namespace std {
|
| 321 |
template<class IntType = int>
|
| 322 |
class geometric_distribution {
|
|
@@ -375,12 +373,11 @@ constructed.
|
|
| 375 |
|
| 376 |
##### Class template `negative_binomial_distribution` <a id="rand.dist.bern.negbin">[[rand.dist.bern.negbin]]</a>
|
| 377 |
|
| 378 |
A `negative_binomial_distribution` random number distribution produces
|
| 379 |
random integers i ≥ 0 distributed according to the discrete probability
|
| 380 |
-
function
|
| 381 |
-
$$P(i\,|\,k,p) = \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i \text{ .}$$
|
| 382 |
|
| 383 |
[*Note 1*: This implies that P(i | k,p) is undefined when
|
| 384 |
`p == 1`. — *end note*]
|
| 385 |
|
| 386 |
``` cpp
|
|
@@ -454,17 +451,19 @@ constructed.
|
|
| 454 |
|
| 455 |
##### Class template `poisson_distribution` <a id="rand.dist.pois.poisson">[[rand.dist.pois.poisson]]</a>
|
| 456 |
|
| 457 |
A `poisson_distribution` random number distribution produces integer
|
| 458 |
values i ≥ 0 distributed according to the discrete probability function
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
| 461 |
|
| 462 |
``` cpp
|
|
|
|
| 463 |
template<class IntType = int>
|
| 464 |
-
class poisson_distribution
|
| 465 |
-
{
|
| 466 |
public:
|
| 467 |
// types
|
| 468 |
using result_type = IntType;
|
| 469 |
using param_type = unspecified;
|
| 470 |
|
|
@@ -496,10 +495,11 @@ template<class IntType = int>
|
|
| 496 |
operator<<(basic_ostream<charT, traits>& os, const poisson_distribution& x);
|
| 497 |
template<class charT, class traits>
|
| 498 |
friend basic_istream<charT, traits>&
|
| 499 |
operator>>(basic_istream<charT, traits>& is, poisson_distribution& x);
|
| 500 |
};
|
|
|
|
| 501 |
```
|
| 502 |
|
| 503 |
``` cpp
|
| 504 |
explicit poisson_distribution(double mean);
|
| 505 |
```
|
|
@@ -517,11 +517,11 @@ constructed.
|
|
| 517 |
|
| 518 |
##### Class template `exponential_distribution` <a id="rand.dist.pois.exp">[[rand.dist.pois.exp]]</a>
|
| 519 |
|
| 520 |
An `exponential_distribution` random number distribution produces random
|
| 521 |
numbers x > 0 distributed according to the probability density function
|
| 522 |
-
|
| 523 |
|
| 524 |
``` cpp
|
| 525 |
namespace std {
|
| 526 |
template<class RealType = double>
|
| 527 |
class exponential_distribution {
|
|
@@ -580,13 +580,11 @@ constructed.
|
|
| 580 |
|
| 581 |
##### Class template `gamma_distribution` <a id="rand.dist.pois.gamma">[[rand.dist.pois.gamma]]</a>
|
| 582 |
|
| 583 |
A `gamma_distribution` random number distribution produces random
|
| 584 |
numbers x > 0 distributed according to the probability density function
|
| 585 |
-
|
| 586 |
-
\frac{e^{-x/\beta}}{\beta^{\alpha} \cdot \Gamma(\alpha)} \, \cdot \, x^{\, \alpha-1}
|
| 587 |
-
\text{ .}$$
|
| 588 |
|
| 589 |
``` cpp
|
| 590 |
namespace std {
|
| 591 |
template<class RealType = double>
|
| 592 |
class gamma_distribution {
|
|
@@ -654,14 +652,11 @@ constructed.
|
|
| 654 |
|
| 655 |
##### Class template `weibull_distribution` <a id="rand.dist.pois.weibull">[[rand.dist.pois.weibull]]</a>
|
| 656 |
|
| 657 |
A `weibull_distribution` random number distribution produces random
|
| 658 |
numbers x ≥ 0 distributed according to the probability density function
|
| 659 |
-
|
| 660 |
-
\cdot \left(\frac{x}{b}\right)^{a-1}
|
| 661 |
-
\cdot \, \exp\left( -\left(\frac{x}{b}\right)^a\right)
|
| 662 |
-
\text{ .}$$
|
| 663 |
|
| 664 |
``` cpp
|
| 665 |
namespace std {
|
| 666 |
template<class RealType = double>
|
| 667 |
class weibull_distribution {
|
|
@@ -729,15 +724,11 @@ constructed.
|
|
| 729 |
|
| 730 |
##### Class template `extreme_value_distribution` <a id="rand.dist.pois.extreme">[[rand.dist.pois.extreme]]</a>
|
| 731 |
|
| 732 |
An `extreme_value_distribution` random number distribution produces
|
| 733 |
random numbers x distributed according to the probability density
|
| 734 |
-
function[^7]
|
| 735 |
-
|
| 736 |
-
$$p(x\,|\,a,b) = \frac{1}{b}
|
| 737 |
-
\cdot \exp\left(\frac{a-x}{b} - \exp\left(\frac{a-x}{b}\right)\right)
|
| 738 |
-
\text{ .}$$
|
| 739 |
|
| 740 |
``` cpp
|
| 741 |
namespace std {
|
| 742 |
template<class RealType = double>
|
| 743 |
class extreme_value_distribution {
|
|
@@ -807,20 +798,13 @@ constructed.
|
|
| 807 |
#### Normal distributions <a id="rand.dist.norm">[[rand.dist.norm]]</a>
|
| 808 |
|
| 809 |
##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
|
| 810 |
|
| 811 |
A `normal_distribution` random number distribution produces random
|
| 812 |
-
numbers x distributed according to the probability density function
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
\cdot
|
| 816 |
-
% e^{-(x-\mu)^2 / (2\sigma^2)}
|
| 817 |
-
\exp{\left(- \, \frac{(x - \mu)^2}
|
| 818 |
-
{2 \sigma^2}
|
| 819 |
-
\right)
|
| 820 |
-
}
|
| 821 |
-
\text{ .}$$ The distribution parameters μ and σ are also known as this
|
| 822 |
distribution’s *mean* and *standard deviation*.
|
| 823 |
|
| 824 |
``` cpp
|
| 825 |
namespace std {
|
| 826 |
template<class RealType = double>
|
|
@@ -889,13 +873,11 @@ constructed.
|
|
| 889 |
|
| 890 |
##### Class template `lognormal_distribution` <a id="rand.dist.norm.lognormal">[[rand.dist.norm.lognormal]]</a>
|
| 891 |
|
| 892 |
A `lognormal_distribution` random number distribution produces random
|
| 893 |
numbers x > 0 distributed according to the probability density function
|
| 894 |
-
|
| 895 |
-
\cdot \exp{\left(-\frac{(\ln{x} - m)^2}{2 s^2}\right)}
|
| 896 |
-
\text{ .}$$
|
| 897 |
|
| 898 |
``` cpp
|
| 899 |
namespace std {
|
| 900 |
template<class RealType = double>
|
| 901 |
class lognormal_distribution {
|
|
@@ -963,11 +945,11 @@ constructed.
|
|
| 963 |
|
| 964 |
##### Class template `chi_squared_distribution` <a id="rand.dist.norm.chisq">[[rand.dist.norm.chisq]]</a>
|
| 965 |
|
| 966 |
A `chi_squared_distribution` random number distribution produces random
|
| 967 |
numbers x > 0 distributed according to the probability density function
|
| 968 |
-
|
| 969 |
|
| 970 |
``` cpp
|
| 971 |
namespace std {
|
| 972 |
template<class RealType = double>
|
| 973 |
class chi_squared_distribution {
|
|
@@ -1025,12 +1007,11 @@ RealType n() const;
|
|
| 1025 |
constructed.
|
| 1026 |
|
| 1027 |
##### Class template `cauchy_distribution` <a id="rand.dist.norm.cauchy">[[rand.dist.norm.cauchy]]</a>
|
| 1028 |
|
| 1029 |
A `cauchy_distribution` random number distribution produces random
|
| 1030 |
-
numbers x distributed according to the probability density function
|
| 1031 |
-
$$p(x\,|\,a,b) = \left(\pi b \left(1 + \left(\frac{x-a}{b} \right)^2 \, \right)\right)^{-1} \text{ .}$$
|
| 1032 |
|
| 1033 |
``` cpp
|
| 1034 |
namespace std {
|
| 1035 |
template<class RealType = double>
|
| 1036 |
class cauchy_distribution {
|
|
@@ -1098,15 +1079,11 @@ constructed.
|
|
| 1098 |
|
| 1099 |
##### Class template `fisher_f_distribution` <a id="rand.dist.norm.f">[[rand.dist.norm.f]]</a>
|
| 1100 |
|
| 1101 |
A `fisher_f_distribution` random number distribution produces random
|
| 1102 |
numbers x ≥ 0 distributed according to the probability density function
|
| 1103 |
-
|
| 1104 |
-
\cdot \left(\frac{m}{n}\right)^{m/2}
|
| 1105 |
-
\cdot x^{(m/2)-1}
|
| 1106 |
-
\cdot \left(1 + \frac{m x}{n}\right)^{-(m + n)/2}
|
| 1107 |
-
\text{ .}$$
|
| 1108 |
|
| 1109 |
``` cpp
|
| 1110 |
namespace std {
|
| 1111 |
template<class RealType = double>
|
| 1112 |
class fisher_f_distribution {
|
|
@@ -1173,15 +1150,11 @@ RealType n() const;
|
|
| 1173 |
constructed.
|
| 1174 |
|
| 1175 |
##### Class template `student_t_distribution` <a id="rand.dist.norm.t">[[rand.dist.norm.t]]</a>
|
| 1176 |
|
| 1177 |
A `student_t_distribution` random number distribution produces random
|
| 1178 |
-
numbers x distributed according to the probability density function
|
| 1179 |
-
$$p(x\,|\,n) = \frac{1}{\sqrt{n \pi}}
|
| 1180 |
-
\cdot \frac{\Gamma\big((n+1)/2\big)}{\Gamma(n/2)}
|
| 1181 |
-
\cdot \left(1 + \frac{x^2}{n} \right)^{-(n+1)/2}
|
| 1182 |
-
\text{ .}$$
|
| 1183 |
|
| 1184 |
``` cpp
|
| 1185 |
namespace std {
|
| 1186 |
template<class RealType = double>
|
| 1187 |
class student_t_distribution {
|
|
@@ -1242,11 +1215,11 @@ constructed.
|
|
| 1242 |
|
| 1243 |
##### Class template `discrete_distribution` <a id="rand.dist.samp.discrete">[[rand.dist.samp.discrete]]</a>
|
| 1244 |
|
| 1245 |
A `discrete_distribution` random number distribution produces random
|
| 1246 |
integers i, 0 ≤ i < n, distributed according to the discrete probability
|
| 1247 |
-
function
|
| 1248 |
|
| 1249 |
Unless specified otherwise, the distribution parameters are calculated
|
| 1250 |
as: pₖ = {wₖ / S} for k = 0, …, n - 1, in which the values wₖ, commonly
|
| 1251 |
known as the *weights* , shall be non-negative, non-NaN, and
|
| 1252 |
non-infinity. Moreover, the following relation shall hold:
|
|
@@ -1321,11 +1294,11 @@ is `true`.
|
|
| 1321 |
requirements [[input.iterators]]. If `firstW == lastW`, let n = 1 and
|
| 1322 |
w₀ = 1. Otherwise, [`firstW`, `lastW`) forms a sequence w of length
|
| 1323 |
n > 0.
|
| 1324 |
|
| 1325 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 1326 |
-
probabilities given by the
|
| 1327 |
|
| 1328 |
``` cpp
|
| 1329 |
discrete_distribution(initializer_list<double> wl);
|
| 1330 |
```
|
| 1331 |
|
|
@@ -1360,12 +1333,11 @@ k = 0, …, n - 1.
|
|
| 1360 |
##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
|
| 1361 |
|
| 1362 |
A `piecewise_constant_distribution` random number distribution produces
|
| 1363 |
random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
|
| 1364 |
subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
|
| 1365 |
-
|
| 1366 |
-
\text{ , for $b_i \le x < b_{i+1}$.}$$
|
| 1367 |
|
| 1368 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 1369 |
*interval boundaries* , shall satisfy the relation $b_i < b_{i + 1}$ for
|
| 1370 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n
|
| 1371 |
distribution parameters are calculated as:
|
|
@@ -1507,15 +1479,11 @@ k = 0, …, n - 1.
|
|
| 1507 |
|
| 1508 |
##### Class template `piecewise_linear_distribution` <a id="rand.dist.samp.plinear">[[rand.dist.samp.plinear]]</a>
|
| 1509 |
|
| 1510 |
A `piecewise_linear_distribution` random number distribution produces
|
| 1511 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 1512 |
-
[bᵢ, bᵢ₊₁) according to the probability density function
|
| 1513 |
-
$$p(x \,|\, b_0, \dotsc, b_n, \; \rho_0, \dotsc, \rho_n)
|
| 1514 |
-
= \rho_{i} \cdot {\frac{b_{i+1} - x}{b_{i+1} - b_i}}
|
| 1515 |
-
+ \rho_{i+1} \cdot {\frac{x - b_i}{b_{i+1} - b_i}}
|
| 1516 |
-
\text{ , for $b_i \le x < b_{i+1}$.}$$
|
| 1517 |
|
| 1518 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 1519 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 1520 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n + 1
|
| 1521 |
distribution parameters are calculated as ρₖ = {wₖ / S} for k = 0, …, n,
|
|
@@ -1585,12 +1553,16 @@ n = 1, ρ₀ = ρ₁ = 1, b₀ = 0, and b₁ = 1.
|
|
| 1585 |
template<class InputIteratorB, class InputIteratorW>
|
| 1586 |
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 1587 |
InputIteratorW firstW);
|
| 1588 |
```
|
| 1589 |
|
| 1590 |
-
*Mandates:*
|
| 1591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1592 |
|
| 1593 |
*Preconditions:* `InputIteratorB` and `InputIteratorW` each meet the
|
| 1594 |
*Cpp17InputIterator* requirements [[input.iterators]]. If
|
| 1595 |
`firstB == lastB` or `++firstB == lastB`, let n = 1, ρ₀ = ρ₁ = 1,
|
| 1596 |
b₀ = 0, and b₁ = 1. Otherwise, [`firstB`, `lastB`) forms a sequence b of
|
|
|
|
| 1 |
### Random number distribution class templates <a id="rand.dist">[[rand.dist]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="rand.dist.general">[[rand.dist.general]]</a>
|
| 4 |
|
| 5 |
+
Each type instantiated from a class template specified in [[rand.dist]]
|
| 6 |
+
meets the requirements of a random number distribution [[rand.req.dist]]
|
| 7 |
+
type.
|
| 8 |
|
| 9 |
+
Descriptions are provided in [[rand.dist]] only for distribution
|
| 10 |
+
operations that are not described in [[rand.req.dist]] or for operations
|
| 11 |
+
where there is additional semantic information. In particular,
|
| 12 |
+
declarations for copy constructors, for copy assignment operators, for
|
| 13 |
+
streaming operators, and for equality and inequality operators are not
|
| 14 |
+
shown in the synopses.
|
| 15 |
|
| 16 |
The algorithms for producing each of the specified distributions are
|
| 17 |
*implementation-defined*.
|
| 18 |
|
| 19 |
The value of each probability density function p(z) and of each discrete
|
|
|
|
| 24 |
|
| 25 |
##### Class template `uniform_int_distribution` <a id="rand.dist.uni.int">[[rand.dist.uni.int]]</a>
|
| 26 |
|
| 27 |
A `uniform_int_distribution` random number distribution produces random
|
| 28 |
integers i, a ≤ i ≤ b, distributed according to the constant discrete
|
| 29 |
+
probability function in .
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
namespace std {
|
| 33 |
template<class IntType = int>
|
| 34 |
class uniform_int_distribution {
|
|
|
|
| 61 |
result_type max() const;
|
| 62 |
|
| 63 |
// inserters and extractors
|
| 64 |
template<class charT, class traits>
|
| 65 |
friend basic_ostream<charT, traits>&
|
| 66 |
+
operator<<(basic_ostream<charT, traits>& os, // hosted
|
| 67 |
+
const uniform_int_distribution& x);
|
| 68 |
template<class charT, class traits>
|
| 69 |
friend basic_istream<charT, traits>&
|
| 70 |
+
operator>>(basic_istream<charT, traits>& is, // hosted
|
| 71 |
+
uniform_int_distribution& x);
|
| 72 |
};
|
| 73 |
}
|
| 74 |
```
|
| 75 |
|
| 76 |
``` cpp
|
|
|
|
| 98 |
|
| 99 |
##### Class template `uniform_real_distribution` <a id="rand.dist.uni.real">[[rand.dist.uni.real]]</a>
|
| 100 |
|
| 101 |
A `uniform_real_distribution` random number distribution produces random
|
| 102 |
numbers x, a ≤ x < b, distributed according to the constant probability
|
| 103 |
+
density function in .
|
| 104 |
|
| 105 |
[*Note 1*: This implies that p(x | a,b) is undefined when
|
| 106 |
`a == b`. — *end note*]
|
| 107 |
|
| 108 |
``` cpp
|
|
|
|
| 176 |
#### Bernoulli distributions <a id="rand.dist.bern">[[rand.dist.bern]]</a>
|
| 177 |
|
| 178 |
##### Class `bernoulli_distribution` <a id="rand.dist.bern.bernoulli">[[rand.dist.bern.bernoulli]]</a>
|
| 179 |
|
| 180 |
A `bernoulli_distribution` random number distribution produces `bool`
|
| 181 |
+
values b distributed according to the discrete probability function in .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
``` cpp
|
| 184 |
namespace std {
|
| 185 |
class bernoulli_distribution {
|
| 186 |
public:
|
|
|
|
| 238 |
|
| 239 |
##### Class template `binomial_distribution` <a id="rand.dist.bern.bin">[[rand.dist.bern.bin]]</a>
|
| 240 |
|
| 241 |
A `binomial_distribution` random number distribution produces integer
|
| 242 |
values i ≥ 0 distributed according to the discrete probability function
|
| 243 |
+
in .
|
| 244 |
|
| 245 |
``` cpp
|
| 246 |
namespace std {
|
| 247 |
template<class IntType = int>
|
| 248 |
class binomial_distribution {
|
|
|
|
| 310 |
|
| 311 |
##### Class template `geometric_distribution` <a id="rand.dist.bern.geo">[[rand.dist.bern.geo]]</a>
|
| 312 |
|
| 313 |
A `geometric_distribution` random number distribution produces integer
|
| 314 |
values i ≥ 0 distributed according to the discrete probability function
|
| 315 |
+
in .
|
| 316 |
|
| 317 |
``` cpp
|
| 318 |
namespace std {
|
| 319 |
template<class IntType = int>
|
| 320 |
class geometric_distribution {
|
|
|
|
| 373 |
|
| 374 |
##### Class template `negative_binomial_distribution` <a id="rand.dist.bern.negbin">[[rand.dist.bern.negbin]]</a>
|
| 375 |
|
| 376 |
A `negative_binomial_distribution` random number distribution produces
|
| 377 |
random integers i ≥ 0 distributed according to the discrete probability
|
| 378 |
+
function in .
|
|
|
|
| 379 |
|
| 380 |
[*Note 1*: This implies that P(i | k,p) is undefined when
|
| 381 |
`p == 1`. — *end note*]
|
| 382 |
|
| 383 |
``` cpp
|
|
|
|
| 451 |
|
| 452 |
##### Class template `poisson_distribution` <a id="rand.dist.pois.poisson">[[rand.dist.pois.poisson]]</a>
|
| 453 |
|
| 454 |
A `poisson_distribution` random number distribution produces integer
|
| 455 |
values i ≥ 0 distributed according to the discrete probability function
|
| 456 |
+
in .
|
| 457 |
+
|
| 458 |
+
The distribution parameter μ is also known as this distribution’s
|
| 459 |
+
*mean*.
|
| 460 |
|
| 461 |
``` cpp
|
| 462 |
+
namespace std {
|
| 463 |
template<class IntType = int>
|
| 464 |
+
class poisson_distribution {
|
|
|
|
| 465 |
public:
|
| 466 |
// types
|
| 467 |
using result_type = IntType;
|
| 468 |
using param_type = unspecified;
|
| 469 |
|
|
|
|
| 495 |
operator<<(basic_ostream<charT, traits>& os, const poisson_distribution& x);
|
| 496 |
template<class charT, class traits>
|
| 497 |
friend basic_istream<charT, traits>&
|
| 498 |
operator>>(basic_istream<charT, traits>& is, poisson_distribution& x);
|
| 499 |
};
|
| 500 |
+
}
|
| 501 |
```
|
| 502 |
|
| 503 |
``` cpp
|
| 504 |
explicit poisson_distribution(double mean);
|
| 505 |
```
|
|
|
|
| 517 |
|
| 518 |
##### Class template `exponential_distribution` <a id="rand.dist.pois.exp">[[rand.dist.pois.exp]]</a>
|
| 519 |
|
| 520 |
An `exponential_distribution` random number distribution produces random
|
| 521 |
numbers x > 0 distributed according to the probability density function
|
| 522 |
+
in .
|
| 523 |
|
| 524 |
``` cpp
|
| 525 |
namespace std {
|
| 526 |
template<class RealType = double>
|
| 527 |
class exponential_distribution {
|
|
|
|
| 580 |
|
| 581 |
##### Class template `gamma_distribution` <a id="rand.dist.pois.gamma">[[rand.dist.pois.gamma]]</a>
|
| 582 |
|
| 583 |
A `gamma_distribution` random number distribution produces random
|
| 584 |
numbers x > 0 distributed according to the probability density function
|
| 585 |
+
in .
|
|
|
|
|
|
|
| 586 |
|
| 587 |
``` cpp
|
| 588 |
namespace std {
|
| 589 |
template<class RealType = double>
|
| 590 |
class gamma_distribution {
|
|
|
|
| 652 |
|
| 653 |
##### Class template `weibull_distribution` <a id="rand.dist.pois.weibull">[[rand.dist.pois.weibull]]</a>
|
| 654 |
|
| 655 |
A `weibull_distribution` random number distribution produces random
|
| 656 |
numbers x ≥ 0 distributed according to the probability density function
|
| 657 |
+
in .
|
|
|
|
|
|
|
|
|
|
| 658 |
|
| 659 |
``` cpp
|
| 660 |
namespace std {
|
| 661 |
template<class RealType = double>
|
| 662 |
class weibull_distribution {
|
|
|
|
| 724 |
|
| 725 |
##### Class template `extreme_value_distribution` <a id="rand.dist.pois.extreme">[[rand.dist.pois.extreme]]</a>
|
| 726 |
|
| 727 |
An `extreme_value_distribution` random number distribution produces
|
| 728 |
random numbers x distributed according to the probability density
|
| 729 |
+
function in .[^7]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
|
| 731 |
``` cpp
|
| 732 |
namespace std {
|
| 733 |
template<class RealType = double>
|
| 734 |
class extreme_value_distribution {
|
|
|
|
| 798 |
#### Normal distributions <a id="rand.dist.norm">[[rand.dist.norm]]</a>
|
| 799 |
|
| 800 |
##### Class template `normal_distribution` <a id="rand.dist.norm.normal">[[rand.dist.norm.normal]]</a>
|
| 801 |
|
| 802 |
A `normal_distribution` random number distribution produces random
|
| 803 |
+
numbers x distributed according to the probability density function in .
|
| 804 |
+
|
| 805 |
+
The distribution parameters μ and σ are also known as this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
distribution’s *mean* and *standard deviation*.
|
| 807 |
|
| 808 |
``` cpp
|
| 809 |
namespace std {
|
| 810 |
template<class RealType = double>
|
|
|
|
| 873 |
|
| 874 |
##### Class template `lognormal_distribution` <a id="rand.dist.norm.lognormal">[[rand.dist.norm.lognormal]]</a>
|
| 875 |
|
| 876 |
A `lognormal_distribution` random number distribution produces random
|
| 877 |
numbers x > 0 distributed according to the probability density function
|
| 878 |
+
in .
|
|
|
|
|
|
|
| 879 |
|
| 880 |
``` cpp
|
| 881 |
namespace std {
|
| 882 |
template<class RealType = double>
|
| 883 |
class lognormal_distribution {
|
|
|
|
| 945 |
|
| 946 |
##### Class template `chi_squared_distribution` <a id="rand.dist.norm.chisq">[[rand.dist.norm.chisq]]</a>
|
| 947 |
|
| 948 |
A `chi_squared_distribution` random number distribution produces random
|
| 949 |
numbers x > 0 distributed according to the probability density function
|
| 950 |
+
in .
|
| 951 |
|
| 952 |
``` cpp
|
| 953 |
namespace std {
|
| 954 |
template<class RealType = double>
|
| 955 |
class chi_squared_distribution {
|
|
|
|
| 1007 |
constructed.
|
| 1008 |
|
| 1009 |
##### Class template `cauchy_distribution` <a id="rand.dist.norm.cauchy">[[rand.dist.norm.cauchy]]</a>
|
| 1010 |
|
| 1011 |
A `cauchy_distribution` random number distribution produces random
|
| 1012 |
+
numbers x distributed according to the probability density function in .
|
|
|
|
| 1013 |
|
| 1014 |
``` cpp
|
| 1015 |
namespace std {
|
| 1016 |
template<class RealType = double>
|
| 1017 |
class cauchy_distribution {
|
|
|
|
| 1079 |
|
| 1080 |
##### Class template `fisher_f_distribution` <a id="rand.dist.norm.f">[[rand.dist.norm.f]]</a>
|
| 1081 |
|
| 1082 |
A `fisher_f_distribution` random number distribution produces random
|
| 1083 |
numbers x ≥ 0 distributed according to the probability density function
|
| 1084 |
+
in .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1085 |
|
| 1086 |
``` cpp
|
| 1087 |
namespace std {
|
| 1088 |
template<class RealType = double>
|
| 1089 |
class fisher_f_distribution {
|
|
|
|
| 1150 |
constructed.
|
| 1151 |
|
| 1152 |
##### Class template `student_t_distribution` <a id="rand.dist.norm.t">[[rand.dist.norm.t]]</a>
|
| 1153 |
|
| 1154 |
A `student_t_distribution` random number distribution produces random
|
| 1155 |
+
numbers x distributed according to the probability density function in .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1156 |
|
| 1157 |
``` cpp
|
| 1158 |
namespace std {
|
| 1159 |
template<class RealType = double>
|
| 1160 |
class student_t_distribution {
|
|
|
|
| 1215 |
|
| 1216 |
##### Class template `discrete_distribution` <a id="rand.dist.samp.discrete">[[rand.dist.samp.discrete]]</a>
|
| 1217 |
|
| 1218 |
A `discrete_distribution` random number distribution produces random
|
| 1219 |
integers i, 0 ≤ i < n, distributed according to the discrete probability
|
| 1220 |
+
function in .
|
| 1221 |
|
| 1222 |
Unless specified otherwise, the distribution parameters are calculated
|
| 1223 |
as: pₖ = {wₖ / S} for k = 0, …, n - 1, in which the values wₖ, commonly
|
| 1224 |
known as the *weights* , shall be non-negative, non-NaN, and
|
| 1225 |
non-infinity. Moreover, the following relation shall hold:
|
|
|
|
| 1294 |
requirements [[input.iterators]]. If `firstW == lastW`, let n = 1 and
|
| 1295 |
w₀ = 1. Otherwise, [`firstW`, `lastW`) forms a sequence w of length
|
| 1296 |
n > 0.
|
| 1297 |
|
| 1298 |
*Effects:* Constructs a `discrete_distribution` object with
|
| 1299 |
+
probabilities given by the .
|
| 1300 |
|
| 1301 |
``` cpp
|
| 1302 |
discrete_distribution(initializer_list<double> wl);
|
| 1303 |
```
|
| 1304 |
|
|
|
|
| 1333 |
##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
|
| 1334 |
|
| 1335 |
A `piecewise_constant_distribution` random number distribution produces
|
| 1336 |
random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
|
| 1337 |
subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
|
| 1338 |
+
in .
|
|
|
|
| 1339 |
|
| 1340 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 1341 |
*interval boundaries* , shall satisfy the relation $b_i < b_{i + 1}$ for
|
| 1342 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n
|
| 1343 |
distribution parameters are calculated as:
|
|
|
|
| 1479 |
|
| 1480 |
##### Class template `piecewise_linear_distribution` <a id="rand.dist.samp.plinear">[[rand.dist.samp.plinear]]</a>
|
| 1481 |
|
| 1482 |
A `piecewise_linear_distribution` random number distribution produces
|
| 1483 |
random numbers x, b₀ ≤ x < bₙ, distributed over each subinterval
|
| 1484 |
+
[bᵢ, bᵢ₊₁) according to the probability density function in .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1485 |
|
| 1486 |
The n + 1 distribution parameters bᵢ, also known as this distribution’s
|
| 1487 |
*interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
|
| 1488 |
i = 0, …, n - 1. Unless specified otherwise, the remaining n + 1
|
| 1489 |
distribution parameters are calculated as ρₖ = {wₖ / S} for k = 0, …, n,
|
|
|
|
| 1553 |
template<class InputIteratorB, class InputIteratorW>
|
| 1554 |
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
|
| 1555 |
InputIteratorW firstW);
|
| 1556 |
```
|
| 1557 |
|
| 1558 |
+
*Mandates:* Both of
|
| 1559 |
+
|
| 1560 |
+
- `is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>`
|
| 1561 |
+
- `is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>`
|
| 1562 |
+
|
| 1563 |
+
are `true`.
|
| 1564 |
|
| 1565 |
*Preconditions:* `InputIteratorB` and `InputIteratorW` each meet the
|
| 1566 |
*Cpp17InputIterator* requirements [[input.iterators]]. If
|
| 1567 |
`firstB == lastB` or `++firstB == lastB`, let n = 1, ρ₀ = ρ₁ = 1,
|
| 1568 |
b₀ = 0, and b₁ = 1. Otherwise, [`firstB`, `lastB`) forms a sequence b of
|