From Jason Turner

[rand]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyef0bgen/{from.md → to.md} +419 -67
tmp/tmpyef0bgen/{from.md → to.md} RENAMED
@@ -1,8 +1,10 @@
1
  ## Random number generation <a id="rand">[[rand]]</a>
2
 
3
- This subclause defines a facility for generating (pseudo-)random
 
 
4
  numbers.
5
 
6
  In addition to a few utilities, four categories of entities are
7
  described: *uniform random bit generators*, *random number engines*,
8
  *random number engine adaptors*, and *random number distributions*.
@@ -14,39 +16,39 @@ to templates producing such types when instantiated.
14
  binding of any uniform random bit generator object `e` as the argument
15
  to any random number distribution object `d`, thus producing a
16
  zero-argument function object such as given by
17
  `bind(d,e)`. — *end note*]
18
 
19
- Each of the entities specified via this subclause has an associated
20
- arithmetic type [[basic.fundamental]] identified as `result_type`. With
21
- `T` as the `result_type` thus associated with such an entity, that
22
- entity is characterized:
23
 
24
  - as *boolean* or equivalently as *boolean-valued*, if `T` is `bool`;
25
  - otherwise as *integral* or equivalently as *integer-valued*, if
26
  `numeric_limits<T>::is_integer` is `true`;
27
  - otherwise as *floating-point* or equivalently as *real-valued*.
28
 
29
  If integer-valued, an entity may optionally be further characterized as
30
  *signed* or *unsigned*, according to `numeric_limits<T>::is_signed`.
31
 
32
- Unless otherwise specified, all descriptions of calculations in this
33
- subclause use mathematical real numbers.
34
 
35
- Throughout this subclause, the operators , , and \xor denote the
36
- respective conventional bitwise operations. Further:
37
 
38
  - the operator \rightshift denotes a bitwise right shift with
39
  zero-valued bits appearing in the high bits of the result, and
40
  - the operator denotes a bitwise left shift with zero-valued bits
41
  appearing in the low bits of the result, and whose result is always
42
  taken modulo 2ʷ.
43
 
44
  ### Header `<random>` synopsis <a id="rand.synopsis">[[rand.synopsis]]</a>
45
 
46
  ``` cpp
47
- #include <initializer_list>
48
 
49
  namespace std {
50
  // [rand.req.urng], uniform random bit generator requirements
51
  template<class G>
52
  concept uniform_random_bit_generator = see below;
@@ -235,17 +237,18 @@ shown in [[rand.req.seedseq]] are valid and have the indicated
235
  semantics, and if `S` also meets all other requirements of this
236
  subclause [[rand.req.seedseq]]. In that Table and throughout this
237
  subclause:
238
 
239
  - `T` is the type named by `S`’s associated `result_type`;
240
- - `q` is a value of `S` and `r` is a possibly const value of `S`;
 
241
  - `ib` and `ie` are input iterators with an unsigned integer
242
  `value_type` of at least 32 bits;
243
  - `rb` and `re` are mutable random access iterators with an unsigned
244
  integer `value_type` of at least 32 bits;
245
  - `ob` is an output iterator; and
246
- - `il` is a value of `initializer_list<T>`.
247
 
248
  #### Uniform random bit generator requirements <a id="rand.req.urng">[[rand.req.urng]]</a>
249
 
250
  A *uniform random bit generator* `g` of type `G` is a function object
251
  returning unsigned integer values such that each value in the range of
@@ -306,22 +309,22 @@ and have the indicated semantics, and if `E` also meets all other
306
  requirements of this subclause [[rand.req.eng]]. In that Table and
307
  throughout this subclause:
308
 
309
  - `T` is the type named by `E`’s associated `result_type`;
310
  - `e` is a value of `E`, `v` is an lvalue of `E`, `x` and `y` are
311
- (possibly `const`) values of `E`;
312
  - `s` is a value of `T`;
313
  - `q` is an lvalue meeting the requirements of a seed sequence
314
  [[rand.req.seedseq]];
315
  - `z` is a value of type `unsigned long long`;
316
  - `os` is an lvalue of the type of some class template specialization
317
  `basic_ostream<charT,` `traits>`; and
318
  - `is` is an lvalue of the type of some class template specialization
319
  `basic_istream<charT,` `traits>`;
320
 
321
  where `charT` and `traits` are constrained according to [[strings]] and
322
- [[input.output]].
323
 
324
  `E` shall meet the *Cpp17CopyConstructible* (
325
  [[cpp17.copyconstructible]]) and *Cpp17CopyAssignable* (
326
  [[cpp17.copyassignable]]) requirements. These operations shall each be
327
  of complexity no worse than 𝑂(\text{size of state}).
@@ -417,17 +420,17 @@ indicated semantics, and if `D` and its associated types also meet all
417
  other requirements of this subclause [[rand.req.dist]]. In that Table
418
  and throughout this subclause,
419
 
420
  - `T` is the type named by `D`’s associated `result_type`;
421
  - `P` is the type named by `D`’s associated `param_type`;
422
- - `d` is a value of `D`, and `x` and `y` are (possibly `const`) values
423
- of `D`;
424
  - `glb` and `lub` are values of `T` respectively corresponding to the
425
  greatest lower bound and the least upper bound on the values
426
  potentially returned by `d`’s `operator()`, as determined by the
427
  current values of `d`’s parameters;
428
- - `p` is a (possibly `const`) value of `P`;
429
  - `g`, `g1`, and `g2` are lvalues of a type meeting the requirements of
430
  a uniform random bit generator [[rand.req.urng]];
431
  - `os` is an lvalue of the type of some class template specialization
432
  `basic_ostream<charT,` `traits>`; and
433
  - `is` is an lvalue of the type of some class template specialization
@@ -440,11 +443,11 @@ where `charT` and `traits` are constrained according to [[strings]] and
440
  [[cpp17.copyconstructible]]) and *Cpp17CopyAssignable* (
441
  [[cpp17.copyassignable]]) requirements.
442
 
443
  The sequence of numbers produced by repeated invocations of `d(g)` shall
444
  be independent of any invocation of `os << d` or of any `const` member
445
- function of `D` between any of the invocations `d(g)`.
446
 
447
  If a textual representation is written using `os << x` and that
448
  representation is restored into the same or a different object `y` of
449
  the same type using `is >> y`, repeated invocations of `y(g)` shall
450
  produce the same sequence of numbers as would repeated invocations of
@@ -474,40 +477,39 @@ the identical name, type, and semantics.
474
  using distribution_type = D;
475
  ```
476
 
477
  ### Random number engine class templates <a id="rand.eng">[[rand.eng]]</a>
478
 
479
- Each type instantiated from a class template specified in this
480
- subclause  [[rand.eng]] meets the requirements of a random number engine
481
- [[rand.req.eng]] type.
 
482
 
483
  Except where specified otherwise, the complexity of each function
484
- specified in this subclause  [[rand.eng]] is constant.
485
 
486
- Except where specified otherwise, no function described in this
487
- subclause  [[rand.eng]] throws an exception.
488
 
489
- Every function described in this subclause  [[rand.eng]] that has a
490
- function parameter `q` of type `Sseq&` for a template type parameter
491
- named `Sseq` that is different from type `seed_seq` throws what and when
492
- the invocation of `q.generate` throws.
493
 
494
- Descriptions are provided in this subclause  [[rand.eng]] only for
495
- engine operations that are not described in [[rand.req.eng]] or for
496
- operations where there is additional semantic information. In
497
- particular, declarations for copy constructors, for copy assignment
498
- operators, for streaming operators, and for equality and inequality
499
- operators are not shown in the synopses.
500
 
501
- Each template specified in this subclause  [[rand.eng]] requires one or
502
- more relationships, involving the value(s) of its non-type template
503
  parameter(s), to hold. A program instantiating any of these templates is
504
  ill-formed if any such required relationship fails to hold.
505
 
506
  For every random number engine and for every random number engine
507
- adaptor `X` defined in this subclause [[rand.eng]] and in subclause 
508
- [[rand.adapt]]:
509
 
510
  - if the constructor
511
  ``` cpp
512
  template<class Sseq> explicit X(Sseq& q);
513
  ```
@@ -535,10 +537,11 @@ object `x` is of size 1 and consists of a single integer. The transition
535
  algorithm is a modular linear function of the form
536
  TA(xᵢ) = (a ⋅ xᵢ + c) mod m; the generation algorithm is
537
  GA(xᵢ) = xᵢ₊₁.
538
 
539
  ``` cpp
 
540
  template<class UIntType, UIntType a, UIntType c, UIntType m>
541
  class linear_congruential_engine {
542
  public:
543
  // types
544
  using result_type = UIntType;
@@ -556,14 +559,27 @@ template<class UIntType, UIntType a, UIntType c, UIntType m>
556
  explicit linear_congruential_engine(result_type s);
557
  template<class Sseq> explicit linear_congruential_engine(Sseq& q);
558
  void seed(result_type s = default_seed);
559
  template<class Sseq> void seed(Sseq& q);
560
 
 
 
 
 
561
  // generating functions
562
  result_type operator()();
563
  void discard(unsigned long long z);
 
 
 
 
 
 
 
 
564
  };
 
565
  ```
566
 
567
  If the template parameter `m` is 0, the modulus m used throughout this
568
  subclause  [[rand.eng.lcong]] is `numeric_limits<result_type>::max()`
569
  plus 1.
@@ -594,15 +610,16 @@ $S = \left(\sum_{j = 0}^{k - 1} a_{j + 3} \cdot 2^{32j} \right) \bmod m$.
594
  If c mod m is 0 and S is 0, sets the engine’s state to 1, else sets
595
  the engine’s state to S.
596
 
597
  #### Class template `mersenne_twister_engine` <a id="rand.eng.mers">[[rand.eng.mers]]</a>
598
 
599
- A `mersenne_twister_engine` random number engine[^2] produces unsigned
600
- integer random numbers in the closed interval [0,2ʷ-1]. The state xᵢ of
601
- a `mersenne_twister_engine` object `x` is of size n and consists of a
602
- sequence X of n values of the type delivered by `x`; all subscripts
603
- applied to X are to be taken modulo n.
 
604
 
605
  The transition algorithm employs a twisted generalized feedback shift
606
  register defined by shift values n and m, a twist value r, and a
607
  conditional xor-mask a. To improve the uniformity of the result, the
608
  bits of the raw shift register are additionally *tempered* (i.e.,
@@ -626,10 +643,11 @@ z₁, z₂, z₃, z₄ as follows, then delivers z₄ as its result:
626
  - Let $z_2 = z_1 \xor \bigl( (z_1 \leftshift{w} s) \bitand b \bigr)$.
627
  - Let $z_3 = z_2 \xor \bigl( (z_2 \leftshift{w} t) \bitand c \bigr)$.
628
  - Let $z_4 = z_3 \xor ( z_3 \rightshift \ell )$.
629
 
630
  ``` cpp
 
631
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
632
  UIntType a, size_t u, UIntType d, size_t s,
633
  UIntType b, size_t t,
634
  UIntType c, size_t l, UIntType f>
635
  class mersenne_twister_engine {
@@ -660,14 +678,26 @@ template<class UIntType, size_t w, size_t n, size_t m, size_t r,
660
  explicit mersenne_twister_engine(result_type value);
661
  template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
662
  void seed(result_type value = default_seed);
663
  template<class Sseq> void seed(Sseq& q);
664
 
 
 
 
665
  // generating functions
666
  result_type operator()();
667
  void discard(unsigned long long z);
 
 
 
 
 
 
 
 
668
  };
 
669
  ```
670
 
671
  The following relations shall hold: `0 < m`, `m <= n`, `2u < w`,
672
  `r <= w`, `u <= w`, `s <= w`, `t <= w`, `l <= w`,
673
  `w <= numeric_limits<UIntType>::digits`, `a <= (1u<<w) - 1u`,
@@ -725,10 +755,11 @@ and a = b - (b - 1) / m. — *end note*]
725
 
726
  The generation algorithm is given by GA(xᵢ) = y, where y is the value
727
  produced as a result of advancing the engine’s state as described above.
728
 
729
  ``` cpp
 
730
  template<class UIntType, size_t w, size_t s, size_t r>
731
  class subtract_with_carry_engine {
732
  public:
733
  // types
734
  using result_type = UIntType;
@@ -746,14 +777,27 @@ template<class UIntType, size_t w, size_t s, size_t r>
746
  explicit subtract_with_carry_engine(result_type value);
747
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
748
  void seed(result_type value = default_seed);
749
  template<class Sseq> void seed(Sseq& q);
750
 
 
 
 
 
751
  // generating functions
752
  result_type operator()();
753
  void discard(unsigned long long z);
 
 
 
 
 
 
 
 
754
  };
 
755
  ```
756
 
757
  The following relations shall hold: `0u < s`, `s < r`, `0 < w`, and
758
  `w <= numeric_limits<UIntType>::digits`.
759
 
@@ -774,11 +818,11 @@ To set the values Xₖ, first construct `e`, a
774
  linear_congruential_engine<result_type,
775
  40014u,0u,2147483563u> e(value == 0u ? default_seed : value);
776
  ```
777
 
778
  Then, to set each Xₖ, obtain new values z₀, …, zₙ₋₁ from n = ⌈ w/32 ⌉
779
- successive invocations of `e` taken modulo 2³². Set Xₖ to
780
  $\left( \sum_{j=0}^{n-1} z_j \cdot 2^{32j}\right) \bmod m$.
781
 
782
  *Complexity:* Exactly n ⋅ `r` invocations of `e`.
783
 
784
  ``` cpp
@@ -838,10 +882,11 @@ state eⱼ to eⱼ₊₁.
838
 
839
  The generation algorithm yields the value returned by the last
840
  invocation of `e()` while advancing `e`’s state as described above.
841
 
842
  ``` cpp
 
843
  template<class Engine, size_t p, size_t r>
844
  class discard_block_engine {
845
  public:
846
  // types
847
  using result_type = typename Engine::result_type;
@@ -860,21 +905,33 @@ template<class Engine, size_t p, size_t r>
860
  template<class Sseq> explicit discard_block_engine(Sseq& q);
861
  void seed();
862
  void seed(result_type s);
863
  template<class Sseq> void seed(Sseq& q);
864
 
 
 
 
865
  // generating functions
866
  result_type operator()();
867
  void discard(unsigned long long z);
868
 
869
  // property functions
870
- const Engine& base() const noexcept { return e; };
 
 
 
 
 
 
 
 
871
 
872
  private:
873
  Engine e; // exposition only
874
- int n; // exposition only
875
  };
 
876
  ```
877
 
878
  The following relations shall hold: `0 < r` and `r <= p`.
879
 
880
  The textual representation consists of the textual representation of `e`
@@ -944,16 +1001,27 @@ template<class Engine, size_t w, class UIntType>
944
  template<class Sseq> explicit independent_bits_engine(Sseq& q);
945
  void seed();
946
  void seed(result_type s);
947
  template<class Sseq> void seed(Sseq& q);
948
 
 
 
 
949
  // generating functions
950
  result_type operator()();
951
  void discard(unsigned long long z);
952
 
953
  // property functions
954
- const Engine& base() const noexcept { return e; };
 
 
 
 
 
 
 
 
955
 
956
  private:
957
  Engine e; // exposition only
958
  };
959
  ```
@@ -984,10 +1052,11 @@ transition is performed as follows:
984
 
985
  The generation algorithm yields the last value of `Y` produced while
986
  advancing `e`’s state as described above.
987
 
988
  ``` cpp
 
989
  template<class Engine, size_t k>
990
  class shuffle_order_engine {
991
  public:
992
  // types
993
  using result_type = typename Engine::result_type;
@@ -1005,22 +1074,34 @@ template<class Engine, size_t k>
1005
  template<class Sseq> explicit shuffle_order_engine(Sseq& q);
1006
  void seed();
1007
  void seed(result_type s);
1008
  template<class Sseq> void seed(Sseq& q);
1009
 
 
 
 
1010
  // generating functions
1011
  result_type operator()();
1012
  void discard(unsigned long long z);
1013
 
1014
  // property functions
1015
- const Engine& base() const noexcept { return e; };
 
 
 
 
 
 
 
 
1016
 
1017
  private:
1018
  Engine e; // exposition only
1019
  result_type V[k]; // exposition only
1020
  result_type Y; // exposition only
1021
  };
 
1022
  ```
1023
 
1024
  The following relation shall hold: `0 < k`.
1025
 
1026
  The textual representation consists of the textual representation of
@@ -1119,14 +1200,14 @@ using default_random_engine = implementation-defined;
1119
  ```
1120
 
1121
  *Remarks:* The choice of engine type named by this `typedef` is
1122
  *implementation-defined*.
1123
 
1124
- [*Note 1*: The implementation may select this type on the basis of
1125
  performance, size, quality, or any combination of such factors, so as to
1126
  provide at least acceptable engine behavior for relatively casual,
1127
- inexpert, and/or lightweight use. Because different implementations may
1128
  select different underlying engine types, code that uses this `typedef`
1129
  need not generate identical sequences across
1130
  implementations. — *end note*]
1131
 
1132
  ### Class `random_device` <a id="rand.device">[[rand.device]]</a>
@@ -1136,10 +1217,11 @@ random numbers.
1136
 
1137
  If implementation limitations prevent generating nondeterministic random
1138
  numbers, the implementation may employ a random number engine.
1139
 
1140
  ``` cpp
 
1141
  class random_device {
1142
  public:
1143
  // types
1144
  using result_type = unsigned int;
1145
 
@@ -1159,53 +1241,57 @@ public:
1159
 
1160
  // no copy functions
1161
  random_device(const random_device&) = delete;
1162
  void operator=(const random_device&) = delete;
1163
  };
 
1164
  ```
1165
 
1166
  ``` cpp
1167
  explicit random_device(const string& token);
1168
  ```
1169
 
 
 
 
1170
  *Remarks:* The semantics of the `token` parameter and the token value
1171
- used by the default constructor are *implementation-defined*. [^3]
1172
-
1173
- *Throws:* A value of an *implementation-defined* type derived from
1174
- `exception` if the `random_device` could not be initialized.
1175
 
1176
  ``` cpp
1177
  double entropy() const noexcept;
1178
  ```
1179
 
1180
  *Returns:* If the implementation employs a random number engine, returns
1181
- 0.0. Otherwise, returns an entropy estimate[^4] for the random numbers
1182
- returned by `operator()`, in the range `min()` to log₂( `max()`+1).
 
 
1183
 
1184
  ``` cpp
1185
  result_type operator()();
1186
  ```
1187
 
1188
  *Returns:* A nondeterministic random value, uniformly distributed
1189
  between `min()` and `max()` (inclusive). It is *implementation-defined*
1190
  how these values are generated.
1191
 
1192
  *Throws:* A value of an *implementation-defined* type derived from
1193
- `exception` if a random number could not be obtained.
1194
 
1195
  ### Utilities <a id="rand.util">[[rand.util]]</a>
1196
 
1197
  #### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
1198
 
1199
  ``` cpp
 
1200
  class seed_seq {
1201
  public:
1202
  // types
1203
  using result_type = uint_least32_t;
1204
 
1205
  // constructors
1206
- seed_seq();
1207
  template<class T>
1208
  seed_seq(initializer_list<T> il);
1209
  template<class InputIterator>
1210
  seed_seq(InputIterator begin, InputIterator end);
1211
 
@@ -1223,26 +1309,25 @@ public:
1223
  void operator=(const seed_seq&) = delete;
1224
 
1225
  private:
1226
  vector<result_type> v; // exposition only
1227
  };
 
1228
  ```
1229
 
1230
  ``` cpp
1231
- seed_seq();
1232
  ```
1233
 
1234
  *Ensures:* `v.empty()` is `true`.
1235
 
1236
- *Throws:* Nothing.
1237
-
1238
  ``` cpp
1239
  template<class T>
1240
  seed_seq(initializer_list<T> il);
1241
  ```
1242
 
1243
- *Mandates:* `T` is an integer type.
1244
 
1245
  *Effects:* Same as `seed_seq(il.begin(), il.end())`.
1246
 
1247
  ``` cpp
1248
  template<class InputIterator>
@@ -1358,14 +1443,10 @@ copy(v.begin(), v.end(), dest);
1358
  ``` cpp
1359
  template<class RealType, size_t bits, class URBG>
1360
  RealType generate_canonical(URBG& g);
1361
  ```
1362
 
1363
- *Complexity:* Exactly k = max(1, ⌈ b / log₂ R ⌉) invocations of `g`,
1364
- where b[^5] is the lesser of `numeric_limits<RealType>::digits` and
1365
- `bits`, and R is the value of `g.max()` - `g.min()` + 1.
1366
-
1367
  *Effects:* Invokes `g()` k times to obtain values g₀, …, gₖ₋₁,
1368
  respectively. Calculates a quantity
1369
  $$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
1370
  \cdot R^i$$ using arithmetic of type `RealType`.
1371
 
@@ -1373,10 +1454,16 @@ $$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
1373
 
1374
  [*Note 1*: 0 ≤ S / Rᵏ < 1. — *end note*]
1375
 
1376
  *Throws:* What and when `g` throws.
1377
 
 
 
 
 
 
 
1378
  [*Note 2*: If the values gᵢ produced by `g` are uniformly distributed,
1379
  the instantiation’s results are distributed as uniformly as possible.
1380
  Obtaining a value in this way can be a useful step in the process of
1381
  transforming a value generated by a uniform random bit generator into a
1382
  value that can be delivered by a random number
@@ -1411,10 +1498,11 @@ outside its stated domain.
1411
  A `uniform_int_distribution` random number distribution produces random
1412
  integers i, a ≤ i ≤ b, distributed according to the constant discrete
1413
  probability function $$P(i\,|\,a,b) = 1 / (b - a + 1) \text{ .}$$
1414
 
1415
  ``` cpp
 
1416
  template<class IntType = int>
1417
  class uniform_int_distribution {
1418
  public:
1419
  // types
1420
  using result_type = IntType;
@@ -1424,10 +1512,13 @@ template<class IntType = int>
1424
  uniform_int_distribution() : uniform_int_distribution(0) {}
1425
  explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
1426
  explicit uniform_int_distribution(const param_type& parm);
1427
  void reset();
1428
 
 
 
 
1429
  // generating functions
1430
  template<class URBG>
1431
  result_type operator()(URBG& g);
1432
  template<class URBG>
1433
  result_type operator()(URBG& g, const param_type& parm);
@@ -1437,11 +1528,20 @@ template<class IntType = int>
1437
  result_type b() const;
1438
  param_type param() const;
1439
  void param(const param_type& parm);
1440
  result_type min() const;
1441
  result_type max() const;
 
 
 
 
 
 
 
 
1442
  };
 
1443
  ```
1444
 
1445
  ``` cpp
1446
  explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
1447
  ```
@@ -1473,10 +1573,11 @@ density function $$p(x\,|\,a,b) = 1 / (b - a) \text{ .}$$
1473
 
1474
  [*Note 1*: This implies that p(x | a,b) is undefined when
1475
  `a == b`. — *end note*]
1476
 
1477
  ``` cpp
 
1478
  template<class RealType = double>
1479
  class uniform_real_distribution {
1480
  public:
1481
  // types
1482
  using result_type = RealType;
@@ -1486,10 +1587,14 @@ template<class RealType = double>
1486
  uniform_real_distribution() : uniform_real_distribution(0.0) {}
1487
  explicit uniform_real_distribution(RealType a, RealType b = 1.0);
1488
  explicit uniform_real_distribution(const param_type& parm);
1489
  void reset();
1490
 
 
 
 
 
1491
  // generating functions
1492
  template<class URBG>
1493
  result_type operator()(URBG& g);
1494
  template<class URBG>
1495
  result_type operator()(URBG& g, const param_type& parm);
@@ -1499,11 +1604,20 @@ template<class RealType = double>
1499
  result_type b() const;
1500
  param_type param() const;
1501
  void param(const param_type& parm);
1502
  result_type min() const;
1503
  result_type max() const;
 
 
 
 
 
 
 
 
1504
  };
 
1505
  ```
1506
 
1507
  ``` cpp
1508
  explicit uniform_real_distribution(RealType a, RealType b = 1.0);
1509
  ```
@@ -1538,10 +1652,11 @@ $$P(b\,|\,p) = \left\{ \begin{array}{ll}
1538
  p & \text{ if $b = \tcode{true}$, or} \\
1539
  1 - p & \text{ if $b = \tcode{false}$.}
1540
  \end{array}\right.$$
1541
 
1542
  ``` cpp
 
1543
  class bernoulli_distribution {
1544
  public:
1545
  // types
1546
  using result_type = bool;
1547
  using param_type = unspecified;
@@ -1550,10 +1665,13 @@ public:
1550
  bernoulli_distribution() : bernoulli_distribution(0.5) {}
1551
  explicit bernoulli_distribution(double p);
1552
  explicit bernoulli_distribution(const param_type& parm);
1553
  void reset();
1554
 
 
 
 
1555
  // generating functions
1556
  template<class URBG>
1557
  result_type operator()(URBG& g);
1558
  template<class URBG>
1559
  result_type operator()(URBG& g, const param_type& parm);
@@ -1562,11 +1680,20 @@ public:
1562
  double p() const;
1563
  param_type param() const;
1564
  void param(const param_type& parm);
1565
  result_type min() const;
1566
  result_type max() const;
 
 
 
 
 
 
 
 
1567
  };
 
1568
  ```
1569
 
1570
  ``` cpp
1571
  explicit bernoulli_distribution(double p);
1572
  ```
@@ -1587,10 +1714,11 @@ constructed.
1587
  A `binomial_distribution` random number distribution produces integer
1588
  values i ≥ 0 distributed according to the discrete probability function
1589
  $$P(i\,|\,t,p) = \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i} \text{ .}$$
1590
 
1591
  ``` cpp
 
1592
  template<class IntType = int>
1593
  class binomial_distribution {
1594
  public:
1595
  // types
1596
  using result_type = IntType;
@@ -1600,10 +1728,13 @@ template<class IntType = int>
1600
  binomial_distribution() : binomial_distribution(1) {}
1601
  explicit binomial_distribution(IntType t, double p = 0.5);
1602
  explicit binomial_distribution(const param_type& parm);
1603
  void reset();
1604
 
 
 
 
1605
  // generating functions
1606
  template<class URBG>
1607
  result_type operator()(URBG& g);
1608
  template<class URBG>
1609
  result_type operator()(URBG& g, const param_type& parm);
@@ -1613,11 +1744,20 @@ template<class IntType = int>
1613
  double p() const;
1614
  param_type param() const;
1615
  void param(const param_type& parm);
1616
  result_type min() const;
1617
  result_type max() const;
 
 
 
 
 
 
 
 
1618
  };
 
1619
  ```
1620
 
1621
  ``` cpp
1622
  explicit binomial_distribution(IntType t, double p = 0.5);
1623
  ```
@@ -1646,10 +1786,11 @@ constructed.
1646
  A `geometric_distribution` random number distribution produces integer
1647
  values i ≥ 0 distributed according to the discrete probability function
1648
  $$P(i\,|\,p) = p \cdot (1-p)^{i} \text{ .}$$
1649
 
1650
  ``` cpp
 
1651
  template<class IntType = int>
1652
  class geometric_distribution {
1653
  public:
1654
  // types
1655
  using result_type = IntType;
@@ -1659,10 +1800,13 @@ template<class IntType = int>
1659
  geometric_distribution() : geometric_distribution(0.5) {}
1660
  explicit geometric_distribution(double p);
1661
  explicit geometric_distribution(const param_type& parm);
1662
  void reset();
1663
 
 
 
 
1664
  // generating functions
1665
  template<class URBG>
1666
  result_type operator()(URBG& g);
1667
  template<class URBG>
1668
  result_type operator()(URBG& g, const param_type& parm);
@@ -1671,11 +1815,20 @@ template<class IntType = int>
1671
  double p() const;
1672
  param_type param() const;
1673
  void param(const param_type& parm);
1674
  result_type min() const;
1675
  result_type max() const;
 
 
 
 
 
 
 
 
1676
  };
 
1677
  ```
1678
 
1679
  ``` cpp
1680
  explicit geometric_distribution(double p);
1681
  ```
@@ -1700,10 +1853,11 @@ $$P(i\,|\,k,p) = \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i \text{ .}$$
1700
 
1701
  [*Note 1*: This implies that P(i | k,p) is undefined when
1702
  `p == 1`. — *end note*]
1703
 
1704
  ``` cpp
 
1705
  template<class IntType = int>
1706
  class negative_binomial_distribution {
1707
  public:
1708
  // types
1709
  using result_type = IntType;
@@ -1713,10 +1867,14 @@ template<class IntType = int>
1713
  negative_binomial_distribution() : negative_binomial_distribution(1) {}
1714
  explicit negative_binomial_distribution(IntType k, double p = 0.5);
1715
  explicit negative_binomial_distribution(const param_type& parm);
1716
  void reset();
1717
 
 
 
 
 
1718
  // generating functions
1719
  template<class URBG>
1720
  result_type operator()(URBG& g);
1721
  template<class URBG>
1722
  result_type operator()(URBG& g, const param_type& parm);
@@ -1726,11 +1884,20 @@ template<class IntType = int>
1726
  double p() const;
1727
  param_type param() const;
1728
  void param(const param_type& parm);
1729
  result_type min() const;
1730
  result_type max() const;
 
 
 
 
 
 
 
 
1731
  };
 
1732
  ```
1733
 
1734
  ``` cpp
1735
  explicit negative_binomial_distribution(IntType k, double p = 0.5);
1736
  ```
@@ -1776,10 +1943,13 @@ template<class IntType = int>
1776
  poisson_distribution() : poisson_distribution(1.0) {}
1777
  explicit poisson_distribution(double mean);
1778
  explicit poisson_distribution(const param_type& parm);
1779
  void reset();
1780
 
 
 
 
1781
  // generating functions
1782
  template<class URBG>
1783
  result_type operator()(URBG& g);
1784
  template<class URBG>
1785
  result_type operator()(URBG& g, const param_type& parm);
@@ -1788,10 +1958,18 @@ template<class IntType = int>
1788
  double mean() const;
1789
  param_type param() const;
1790
  void param(const param_type& parm);
1791
  result_type min() const;
1792
  result_type max() const;
 
 
 
 
 
 
 
 
1793
  };
1794
  ```
1795
 
1796
  ``` cpp
1797
  explicit poisson_distribution(double mean);
@@ -1813,10 +1991,11 @@ constructed.
1813
  An `exponential_distribution` random number distribution produces random
1814
  numbers x > 0 distributed according to the probability density function
1815
  $$p(x\,|\,\lambda) = \lambda e^{-\lambda x} \text{ .}$$
1816
 
1817
  ``` cpp
 
1818
  template<class RealType = double>
1819
  class exponential_distribution {
1820
  public:
1821
  // types
1822
  using result_type = RealType;
@@ -1826,10 +2005,13 @@ template<class RealType = double>
1826
  exponential_distribution() : exponential_distribution(1.0) {}
1827
  explicit exponential_distribution(RealType lambda);
1828
  explicit exponential_distribution(const param_type& parm);
1829
  void reset();
1830
 
 
 
 
1831
  // generating functions
1832
  template<class URBG>
1833
  result_type operator()(URBG& g);
1834
  template<class URBG>
1835
  result_type operator()(URBG& g, const param_type& parm);
@@ -1838,11 +2020,20 @@ template<class RealType = double>
1838
  RealType lambda() const;
1839
  param_type param() const;
1840
  void param(const param_type& parm);
1841
  result_type min() const;
1842
  result_type max() const;
 
 
 
 
 
 
 
 
1843
  };
 
1844
  ```
1845
 
1846
  ``` cpp
1847
  explicit exponential_distribution(RealType lambda);
1848
  ```
@@ -1865,10 +2056,11 @@ numbers x > 0 distributed according to the probability density function
1865
  $$p(x\,|\,\alpha,\beta) =
1866
  \frac{e^{-x/\beta}}{\beta^{\alpha} \cdot \Gamma(\alpha)} \, \cdot \, x^{\, \alpha-1}
1867
  \text{ .}$$
1868
 
1869
  ``` cpp
 
1870
  template<class RealType = double>
1871
  class gamma_distribution {
1872
  public:
1873
  // types
1874
  using result_type = RealType;
@@ -1878,10 +2070,13 @@ template<class RealType = double>
1878
  gamma_distribution() : gamma_distribution(1.0) {}
1879
  explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
1880
  explicit gamma_distribution(const param_type& parm);
1881
  void reset();
1882
 
 
 
 
1883
  // generating functions
1884
  template<class URBG>
1885
  result_type operator()(URBG& g);
1886
  template<class URBG>
1887
  result_type operator()(URBG& g, const param_type& parm);
@@ -1891,11 +2086,20 @@ template<class RealType = double>
1891
  RealType beta() const;
1892
  param_type param() const;
1893
  void param(const param_type& parm);
1894
  result_type min() const;
1895
  result_type max() const;
 
 
 
 
 
 
 
 
1896
  };
 
1897
  ```
1898
 
1899
  ``` cpp
1900
  explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
1901
  ```
@@ -1927,10 +2131,11 @@ $$p(x\,|\,a,b) = \frac{a}{b}
1927
  \cdot \left(\frac{x}{b}\right)^{a-1}
1928
  \cdot \, \exp\left( -\left(\frac{x}{b}\right)^a\right)
1929
  \text{ .}$$
1930
 
1931
  ``` cpp
 
1932
  template<class RealType = double>
1933
  class weibull_distribution {
1934
  public:
1935
  // types
1936
  using result_type = RealType;
@@ -1940,10 +2145,13 @@ template<class RealType = double>
1940
  weibull_distribution() : weibull_distribution(1.0) {}
1941
  explicit weibull_distribution(RealType a, RealType b = 1.0);
1942
  explicit weibull_distribution(const param_type& parm);
1943
  void reset();
1944
 
 
 
 
1945
  // generating functions
1946
  template<class URBG>
1947
  result_type operator()(URBG& g);
1948
  template<class URBG>
1949
  result_type operator()(URBG& g, const param_type& parm);
@@ -1953,11 +2161,20 @@ template<class RealType = double>
1953
  RealType b() const;
1954
  param_type param() const;
1955
  void param(const param_type& parm);
1956
  result_type min() const;
1957
  result_type max() const;
 
 
 
 
 
 
 
 
1958
  };
 
1959
  ```
1960
 
1961
  ``` cpp
1962
  explicit weibull_distribution(RealType a, RealType b = 1.0);
1963
  ```
@@ -1983,15 +2200,18 @@ constructed.
1983
 
1984
  ##### Class template `extreme_value_distribution` <a id="rand.dist.pois.extreme">[[rand.dist.pois.extreme]]</a>
1985
 
1986
  An `extreme_value_distribution` random number distribution produces
1987
  random numbers x distributed according to the probability density
1988
- function[^6] $$p(x\,|\,a,b) = \frac{1}{b}
 
 
1989
  \cdot \exp\left(\frac{a-x}{b} - \exp\left(\frac{a-x}{b}\right)\right)
1990
  \text{ .}$$
1991
 
1992
  ``` cpp
 
1993
  template<class RealType = double>
1994
  class extreme_value_distribution {
1995
  public:
1996
  // types
1997
  using result_type = RealType;
@@ -2001,10 +2221,14 @@ template<class RealType = double>
2001
  extreme_value_distribution() : extreme_value_distribution(0.0) {}
2002
  explicit extreme_value_distribution(RealType a, RealType b = 1.0);
2003
  explicit extreme_value_distribution(const param_type& parm);
2004
  void reset();
2005
 
 
 
 
 
2006
  // generating functions
2007
  template<class URBG>
2008
  result_type operator()(URBG& g);
2009
  template<class URBG>
2010
  result_type operator()(URBG& g, const param_type& parm);
@@ -2014,11 +2238,20 @@ template<class RealType = double>
2014
  RealType b() const;
2015
  param_type param() const;
2016
  void param(const param_type& parm);
2017
  result_type min() const;
2018
  result_type max() const;
 
 
 
 
 
 
 
 
2019
  };
 
2020
  ```
2021
 
2022
  ``` cpp
2023
  explicit extreme_value_distribution(RealType a, RealType b = 1.0);
2024
  ```
@@ -2058,10 +2291,11 @@ numbers x distributed according to the probability density function $$%
2058
  }
2059
  \text{ .}$$ The distribution parameters μ and σ are also known as this
2060
  distribution’s *mean* and *standard deviation*.
2061
 
2062
  ``` cpp
 
2063
  template<class RealType = double>
2064
  class normal_distribution {
2065
  public:
2066
  // types
2067
  using result_type = RealType;
@@ -2071,10 +2305,13 @@ template<class RealType = double>
2071
  normal_distribution() : normal_distribution(0.0) {}
2072
  explicit normal_distribution(RealType mean, RealType stddev = 1.0);
2073
  explicit normal_distribution(const param_type& parm);
2074
  void reset();
2075
 
 
 
 
2076
  // generating functions
2077
  template<class URBG>
2078
  result_type operator()(URBG& g);
2079
  template<class URBG>
2080
  result_type operator()(URBG& g, const param_type& parm);
@@ -2084,11 +2321,20 @@ template<class RealType = double>
2084
  RealType stddev() const;
2085
  param_type param() const;
2086
  void param(const param_type& parm);
2087
  result_type min() const;
2088
  result_type max() const;
 
 
 
 
 
 
 
 
2089
  };
 
2090
  ```
2091
 
2092
  ``` cpp
2093
  explicit normal_distribution(RealType mean, RealType stddev = 1.0);
2094
  ```
@@ -2119,10 +2365,11 @@ numbers x > 0 distributed according to the probability density function
2119
  $$p(x\,|\,m,s) = \frac{1}{s x \sqrt{2 \pi}}
2120
  \cdot \exp{\left(-\frac{(\ln{x} - m)^2}{2 s^2}\right)}
2121
  \text{ .}$$
2122
 
2123
  ``` cpp
 
2124
  template<class RealType = double>
2125
  class lognormal_distribution {
2126
  public:
2127
  // types
2128
  using result_type = RealType;
@@ -2132,10 +2379,13 @@ template<class RealType = double>
2132
  lognormal_distribution() : lognormal_distribution(0.0) {}
2133
  explicit lognormal_distribution(RealType m, RealType s = 1.0);
2134
  explicit lognormal_distribution(const param_type& parm);
2135
  void reset();
2136
 
 
 
 
2137
  // generating functions
2138
  template<class URBG>
2139
  result_type operator()(URBG& g);
2140
  template<class URBG>
2141
  result_type operator()(URBG& g, const param_type& parm);
@@ -2145,11 +2395,20 @@ template<class RealType = double>
2145
  RealType s() const;
2146
  param_type param() const;
2147
  void param(const param_type& parm);
2148
  result_type min() const;
2149
  result_type max() const;
 
 
 
 
 
 
 
 
2150
  };
 
2151
  ```
2152
 
2153
  ``` cpp
2154
  explicit lognormal_distribution(RealType m, RealType s = 1.0);
2155
  ```
@@ -2178,10 +2437,11 @@ constructed.
2178
  A `chi_squared_distribution` random number distribution produces random
2179
  numbers x > 0 distributed according to the probability density function
2180
  $$p(x\,|\,n) = \frac{x^{(n/2)-1} \cdot e^{-x/2}}{\Gamma(n/2) \cdot 2^{n/2}} \text{ .}$$
2181
 
2182
  ``` cpp
 
2183
  template<class RealType = double>
2184
  class chi_squared_distribution {
2185
  public:
2186
  // types
2187
  using result_type = RealType;
@@ -2191,10 +2451,13 @@ template<class RealType = double>
2191
  chi_squared_distribution() : chi_squared_distribution(1.0) {}
2192
  explicit chi_squared_distribution(RealType n);
2193
  explicit chi_squared_distribution(const param_type& parm);
2194
  void reset();
2195
 
 
 
 
2196
  // generating functions
2197
  template<class URBG>
2198
  result_type operator()(URBG& g);
2199
  template<class URBG>
2200
  result_type operator()(URBG& g, const param_type& parm);
@@ -2203,11 +2466,20 @@ template<class RealType = double>
2203
  RealType n() const;
2204
  param_type param() const;
2205
  void param(const param_type& parm);
2206
  result_type min() const;
2207
  result_type max() const;
 
 
 
 
 
 
 
 
2208
  };
 
2209
  ```
2210
 
2211
  ``` cpp
2212
  explicit chi_squared_distribution(RealType n);
2213
  ```
@@ -2228,10 +2500,11 @@ constructed.
2228
  A `cauchy_distribution` random number distribution produces random
2229
  numbers x distributed according to the probability density function
2230
  $$p(x\,|\,a,b) = \left(\pi b \left(1 + \left(\frac{x-a}{b} \right)^2 \, \right)\right)^{-1} \text{ .}$$
2231
 
2232
  ``` cpp
 
2233
  template<class RealType = double>
2234
  class cauchy_distribution {
2235
  public:
2236
  // types
2237
  using result_type = RealType;
@@ -2241,10 +2514,13 @@ template<class RealType = double>
2241
  cauchy_distribution() : cauchy_distribution(0.0) {}
2242
  explicit cauchy_distribution(RealType a, RealType b = 1.0);
2243
  explicit cauchy_distribution(const param_type& parm);
2244
  void reset();
2245
 
 
 
 
2246
  // generating functions
2247
  template<class URBG>
2248
  result_type operator()(URBG& g);
2249
  template<class URBG>
2250
  result_type operator()(URBG& g, const param_type& parm);
@@ -2254,11 +2530,20 @@ template<class RealType = double>
2254
  RealType b() const;
2255
  param_type param() const;
2256
  void param(const param_type& parm);
2257
  result_type min() const;
2258
  result_type max() const;
 
 
 
 
 
 
 
 
2259
  };
 
2260
  ```
2261
 
2262
  ``` cpp
2263
  explicit cauchy_distribution(RealType a, RealType b = 1.0);
2264
  ```
@@ -2291,10 +2576,11 @@ $$p(x\,|\,m,n) = \frac{\Gamma\big((m+n)/2\big)}{\Gamma(m/2) \; \Gamma(n/2)}
2291
  \cdot x^{(m/2)-1}
2292
  \cdot \left(1 + \frac{m x}{n}\right)^{-(m + n)/2}
2293
  \text{ .}$$
2294
 
2295
  ``` cpp
 
2296
  template<class RealType = double>
2297
  class fisher_f_distribution {
2298
  public:
2299
  // types
2300
  using result_type = RealType;
@@ -2304,10 +2590,13 @@ template<class RealType = double>
2304
  fisher_f_distribution() : fisher_f_distribution(1.0) {}
2305
  explicit fisher_f_distribution(RealType m, RealType n = 1.0);
2306
  explicit fisher_f_distribution(const param_type& parm);
2307
  void reset();
2308
 
 
 
 
2309
  // generating functions
2310
  template<class URBG>
2311
  result_type operator()(URBG& g);
2312
  template<class URBG>
2313
  result_type operator()(URBG& g, const param_type& parm);
@@ -2317,11 +2606,20 @@ template<class RealType = double>
2317
  RealType n() const;
2318
  param_type param() const;
2319
  void param(const param_type& parm);
2320
  result_type min() const;
2321
  result_type max() const;
 
 
 
 
 
 
 
 
2322
  };
 
2323
  ```
2324
 
2325
  ``` cpp
2326
  explicit fisher_f_distribution(RealType m, RealType n = 1);
2327
  ```
@@ -2353,10 +2651,11 @@ $$p(x\,|\,n) = \frac{1}{\sqrt{n \pi}}
2353
  \cdot \frac{\Gamma\big((n+1)/2\big)}{\Gamma(n/2)}
2354
  \cdot \left(1 + \frac{x^2}{n} \right)^{-(n+1)/2}
2355
  \text{ .}$$
2356
 
2357
  ``` cpp
 
2358
  template<class RealType = double>
2359
  class student_t_distribution {
2360
  public:
2361
  // types
2362
  using result_type = RealType;
@@ -2366,10 +2665,13 @@ template<class RealType = double>
2366
  student_t_distribution() : student_t_distribution(1.0) {}
2367
  explicit student_t_distribution(RealType n);
2368
  explicit student_t_distribution(const param_type& parm);
2369
  void reset();
2370
 
 
 
 
2371
  // generating functions
2372
  template<class URBG>
2373
  result_type operator()(URBG& g);
2374
  template<class URBG>
2375
  result_type operator()(URBG& g, const param_type& parm);
@@ -2378,11 +2680,20 @@ template<class RealType = double>
2378
  RealType n() const;
2379
  param_type param() const;
2380
  void param(const param_type& parm);
2381
  result_type min() const;
2382
  result_type max() const;
 
 
 
 
 
 
 
 
2383
  };
 
2384
  ```
2385
 
2386
  ``` cpp
2387
  explicit student_t_distribution(RealType n);
2388
  ```
@@ -2411,10 +2722,11 @@ as: pₖ = {wₖ / S} for k = 0, …, n - 1, in which the values wₖ, commonly
2411
  known as the *weights* , shall be non-negative, non-NaN, and
2412
  non-infinity. Moreover, the following relation shall hold:
2413
  $0 < S = w_0 + \dotsb + w_{n - 1}$.
2414
 
2415
  ``` cpp
 
2416
  template<class IntType = int>
2417
  class discrete_distribution {
2418
  public:
2419
  // types
2420
  using result_type = IntType;
@@ -2428,10 +2740,13 @@ template<class IntType = int>
2428
  template<class UnaryOperation>
2429
  discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
2430
  explicit discrete_distribution(const param_type& parm);
2431
  void reset();
2432
 
 
 
 
2433
  // generating functions
2434
  template<class URBG>
2435
  result_type operator()(URBG& g);
2436
  template<class URBG>
2437
  result_type operator()(URBG& g, const param_type& parm);
@@ -2440,11 +2755,20 @@ template<class IntType = int>
2440
  vector<double> probabilities() const;
2441
  param_type param() const;
2442
  void param(const param_type& parm);
2443
  result_type min() const;
2444
  result_type max() const;
 
 
 
 
 
 
 
 
2445
  };
 
2446
  ```
2447
 
2448
  ``` cpp
2449
  discrete_distribution();
2450
  ```
@@ -2520,10 +2844,11 @@ $$\rho_k = \frac{w_k}{S \cdot (b_{k+1}-b_k)} \text{ for } k = 0, \dotsc, n - 1 \
2520
  in which the values wₖ, commonly known as the *weights* , shall be
2521
  non-negative, non-NaN, and non-infinity. Moreover, the following
2522
  relation shall hold: 0 < S = w₀ + … + wₙ₋₁.
2523
 
2524
  ``` cpp
 
2525
  template<class RealType = double>
2526
  class piecewise_constant_distribution {
2527
  public:
2528
  // types
2529
  using result_type = RealType;
@@ -2540,10 +2865,14 @@ template<class RealType = double>
2540
  piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax,
2541
  UnaryOperation fw);
2542
  explicit piecewise_constant_distribution(const param_type& parm);
2543
  void reset();
2544
 
 
 
 
 
2545
  // generating functions
2546
  template<class URBG>
2547
  result_type operator()(URBG& g);
2548
  template<class URBG>
2549
  result_type operator()(URBG& g, const param_type& parm);
@@ -2553,11 +2882,20 @@ template<class RealType = double>
2553
  vector<result_type> densities() const;
2554
  param_type param() const;
2555
  void param(const param_type& parm);
2556
  result_type min() const;
2557
  result_type max() const;
 
 
 
 
 
 
 
 
2558
  };
 
2559
  ```
2560
 
2561
  ``` cpp
2562
  piecewise_constant_distribution();
2563
  ```
@@ -2656,10 +2994,11 @@ in which the values wₖ, commonly known as the *weights at boundaries* ,
2656
  shall be non-negative, non-NaN, and non-infinity. Moreover, the
2657
  following relation shall hold:
2658
  $$0 < S = \frac{1}{2} \cdot \sum_{k=0}^{n-1} (w_k + w_{k+1}) \cdot (b_{k+1} - b_k) \text{ .}$$
2659
 
2660
  ``` cpp
 
2661
  template<class RealType = double>
2662
  class piecewise_linear_distribution {
2663
  public:
2664
  // types
2665
  using result_type = RealType;
@@ -2675,10 +3014,14 @@ template<class RealType = double>
2675
  template<class UnaryOperation>
2676
  piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
2677
  explicit piecewise_linear_distribution(const param_type& parm);
2678
  void reset();
2679
 
 
 
 
 
2680
  // generating functions
2681
  template<class URBG>
2682
  result_type operator()(URBG& g);
2683
  template<class URBG>
2684
  result_type operator()(URBG& g, const param_type& parm);
@@ -2688,11 +3031,20 @@ template<class RealType = double>
2688
  vector<result_type> densities() const;
2689
  param_type param() const;
2690
  void param(const param_type& parm);
2691
  result_type min() const;
2692
  result_type max() const;
 
 
 
 
 
 
 
 
2693
  };
 
2694
  ```
2695
 
2696
  ``` cpp
2697
  piecewise_linear_distribution();
2698
  ```
 
1
  ## Random number generation <a id="rand">[[rand]]</a>
2
 
3
+ ### General <a id="rand.general">[[rand.general]]</a>
4
+
5
+ Subclause [[rand]] defines a facility for generating (pseudo-)random
6
  numbers.
7
 
8
  In addition to a few utilities, four categories of entities are
9
  described: *uniform random bit generators*, *random number engines*,
10
  *random number engine adaptors*, and *random number distributions*.
 
16
  binding of any uniform random bit generator object `e` as the argument
17
  to any random number distribution object `d`, thus producing a
18
  zero-argument function object such as given by
19
  `bind(d,e)`. — *end note*]
20
 
21
+ Each of the entities specified in [[rand]] has an associated arithmetic
22
+ type [[basic.fundamental]] identified as `result_type`. With `T` as the
23
+ `result_type` thus associated with such an entity, that entity is
24
+ characterized:
25
 
26
  - as *boolean* or equivalently as *boolean-valued*, if `T` is `bool`;
27
  - otherwise as *integral* or equivalently as *integer-valued*, if
28
  `numeric_limits<T>::is_integer` is `true`;
29
  - otherwise as *floating-point* or equivalently as *real-valued*.
30
 
31
  If integer-valued, an entity may optionally be further characterized as
32
  *signed* or *unsigned*, according to `numeric_limits<T>::is_signed`.
33
 
34
+ Unless otherwise specified, all descriptions of calculations in [[rand]]
35
+ use mathematical real numbers.
36
 
37
+ Throughout [[rand]], the operators , , and \xor denote the respective
38
+ conventional bitwise operations. Further:
39
 
40
  - the operator \rightshift denotes a bitwise right shift with
41
  zero-valued bits appearing in the high bits of the result, and
42
  - the operator denotes a bitwise left shift with zero-valued bits
43
  appearing in the low bits of the result, and whose result is always
44
  taken modulo 2ʷ.
45
 
46
  ### Header `<random>` synopsis <a id="rand.synopsis">[[rand.synopsis]]</a>
47
 
48
  ``` cpp
49
+ #include <initializer_list> // see [initializer.list.syn]
50
 
51
  namespace std {
52
  // [rand.req.urng], uniform random bit generator requirements
53
  template<class G>
54
  concept uniform_random_bit_generator = see below;
 
237
  semantics, and if `S` also meets all other requirements of this
238
  subclause [[rand.req.seedseq]]. In that Table and throughout this
239
  subclause:
240
 
241
  - `T` is the type named by `S`’s associated `result_type`;
242
+ - `q` is a value of type `S` and `r` is a value of type `S` or
243
+ `const S`;
244
  - `ib` and `ie` are input iterators with an unsigned integer
245
  `value_type` of at least 32 bits;
246
  - `rb` and `re` are mutable random access iterators with an unsigned
247
  integer `value_type` of at least 32 bits;
248
  - `ob` is an output iterator; and
249
+ - `il` is a value of type `initializer_list<T>`.
250
 
251
  #### Uniform random bit generator requirements <a id="rand.req.urng">[[rand.req.urng]]</a>
252
 
253
  A *uniform random bit generator* `g` of type `G` is a function object
254
  returning unsigned integer values such that each value in the range of
 
309
  requirements of this subclause [[rand.req.eng]]. In that Table and
310
  throughout this subclause:
311
 
312
  - `T` is the type named by `E`’s associated `result_type`;
313
  - `e` is a value of `E`, `v` is an lvalue of `E`, `x` and `y` are
314
+ (possibly const) values of `E`;
315
  - `s` is a value of `T`;
316
  - `q` is an lvalue meeting the requirements of a seed sequence
317
  [[rand.req.seedseq]];
318
  - `z` is a value of type `unsigned long long`;
319
  - `os` is an lvalue of the type of some class template specialization
320
  `basic_ostream<charT,` `traits>`; and
321
  - `is` is an lvalue of the type of some class template specialization
322
  `basic_istream<charT,` `traits>`;
323
 
324
  where `charT` and `traits` are constrained according to [[strings]] and
325
+ [[input.output]].[^2]
326
 
327
  `E` shall meet the *Cpp17CopyConstructible* (
328
  [[cpp17.copyconstructible]]) and *Cpp17CopyAssignable* (
329
  [[cpp17.copyassignable]]) requirements. These operations shall each be
330
  of complexity no worse than 𝑂(\text{size of state}).
 
420
  other requirements of this subclause [[rand.req.dist]]. In that Table
421
  and throughout this subclause,
422
 
423
  - `T` is the type named by `D`’s associated `result_type`;
424
  - `P` is the type named by `D`’s associated `param_type`;
425
+ - `d` is a value of `D`, and `x` and `y` are (possibly const) values of
426
+ `D`;
427
  - `glb` and `lub` are values of `T` respectively corresponding to the
428
  greatest lower bound and the least upper bound on the values
429
  potentially returned by `d`’s `operator()`, as determined by the
430
  current values of `d`’s parameters;
431
+ - `p` is a (possibly const) value of `P`;
432
  - `g`, `g1`, and `g2` are lvalues of a type meeting the requirements of
433
  a uniform random bit generator [[rand.req.urng]];
434
  - `os` is an lvalue of the type of some class template specialization
435
  `basic_ostream<charT,` `traits>`; and
436
  - `is` is an lvalue of the type of some class template specialization
 
443
  [[cpp17.copyconstructible]]) and *Cpp17CopyAssignable* (
444
  [[cpp17.copyassignable]]) requirements.
445
 
446
  The sequence of numbers produced by repeated invocations of `d(g)` shall
447
  be independent of any invocation of `os << d` or of any `const` member
448
+ function of `D` between any of the invocations of `d(g)`.
449
 
450
  If a textual representation is written using `os << x` and that
451
  representation is restored into the same or a different object `y` of
452
  the same type using `is >> y`, repeated invocations of `y(g)` shall
453
  produce the same sequence of numbers as would repeated invocations of
 
477
  using distribution_type = D;
478
  ```
479
 
480
  ### Random number engine class templates <a id="rand.eng">[[rand.eng]]</a>
481
 
482
+ #### General <a id="rand.eng.general">[[rand.eng.general]]</a>
483
+
484
+ Each type instantiated from a class template specified in [[rand.eng]]
485
+ meets the requirements of a random number engine [[rand.req.eng]] type.
486
 
487
  Except where specified otherwise, the complexity of each function
488
+ specified in [[rand.eng]] is constant.
489
 
490
+ Except where specified otherwise, no function described in [[rand.eng]]
491
+ throws an exception.
492
 
493
+ Every function described in [[rand.eng]] that has a function parameter
494
+ `q` of type `Sseq&` for a template type parameter named `Sseq` that is
495
+ different from type `seed_seq` throws what and when the invocation of
496
+ `q.generate` throws.
497
 
498
+ Descriptions are provided in [[rand.eng]] only for engine operations
499
+ that are not described in [[rand.req.eng]] or for operations where there
500
+ is additional semantic information. In particular, declarations for copy
501
+ constructors, for copy assignment operators, for streaming operators,
502
+ and for equality and inequality operators are not shown in the synopses.
 
503
 
504
+ Each template specified in [[rand.eng]] requires one or more
505
+ relationships, involving the value(s) of its non-type template
506
  parameter(s), to hold. A program instantiating any of these templates is
507
  ill-formed if any such required relationship fails to hold.
508
 
509
  For every random number engine and for every random number engine
510
+ adaptor `X` defined in [[rand.eng]] and in [[rand.adapt]]:
 
511
 
512
  - if the constructor
513
  ``` cpp
514
  template<class Sseq> explicit X(Sseq& q);
515
  ```
 
537
  algorithm is a modular linear function of the form
538
  TA(xᵢ) = (a ⋅ xᵢ + c) mod m; the generation algorithm is
539
  GA(xᵢ) = xᵢ₊₁.
540
 
541
  ``` cpp
542
+ namespace std {
543
  template<class UIntType, UIntType a, UIntType c, UIntType m>
544
  class linear_congruential_engine {
545
  public:
546
  // types
547
  using result_type = UIntType;
 
559
  explicit linear_congruential_engine(result_type s);
560
  template<class Sseq> explicit linear_congruential_engine(Sseq& q);
561
  void seed(result_type s = default_seed);
562
  template<class Sseq> void seed(Sseq& q);
563
 
564
+ // equality operators
565
+ friend bool operator==(const linear_congruential_engine& x,
566
+ const linear_congruential_engine& y);
567
+
568
  // generating functions
569
  result_type operator()();
570
  void discard(unsigned long long z);
571
+
572
+ // inserters and extractors
573
+ template<class charT, class traits>
574
+ friend basic_ostream<charT, traits>&
575
+ operator<<(basic_ostream<charT, traits>& os, const linear_congruential_engine& x);
576
+ template<class charT, class traits>
577
+ friend basic_istream<charT, traits>&
578
+ operator>>(basic_istream<charT, traits>& is, linear_congruential_engine& x);
579
  };
580
+ }
581
  ```
582
 
583
  If the template parameter `m` is 0, the modulus m used throughout this
584
  subclause  [[rand.eng.lcong]] is `numeric_limits<result_type>::max()`
585
  plus 1.
 
610
  If c mod m is 0 and S is 0, sets the engine’s state to 1, else sets
611
  the engine’s state to S.
612
 
613
  #### Class template `mersenne_twister_engine` <a id="rand.eng.mers">[[rand.eng.mers]]</a>
614
 
615
+ A `mersenne_twister_engine` random number engine[^3]
616
+
617
+ produces unsigned integer random numbers in the closed interval
618
+ [0,2ʷ-1]. The state xᵢ of a `mersenne_twister_engine` object `x` is of
619
+ size n and consists of a sequence X of n values of the type delivered by
620
+ `x`; all subscripts applied to X are to be taken modulo n.
621
 
622
  The transition algorithm employs a twisted generalized feedback shift
623
  register defined by shift values n and m, a twist value r, and a
624
  conditional xor-mask a. To improve the uniformity of the result, the
625
  bits of the raw shift register are additionally *tempered* (i.e.,
 
643
  - Let $z_2 = z_1 \xor \bigl( (z_1 \leftshift{w} s) \bitand b \bigr)$.
644
  - Let $z_3 = z_2 \xor \bigl( (z_2 \leftshift{w} t) \bitand c \bigr)$.
645
  - Let $z_4 = z_3 \xor ( z_3 \rightshift \ell )$.
646
 
647
  ``` cpp
648
+ namespace std {
649
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
650
  UIntType a, size_t u, UIntType d, size_t s,
651
  UIntType b, size_t t,
652
  UIntType c, size_t l, UIntType f>
653
  class mersenne_twister_engine {
 
678
  explicit mersenne_twister_engine(result_type value);
679
  template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
680
  void seed(result_type value = default_seed);
681
  template<class Sseq> void seed(Sseq& q);
682
 
683
+ // equality operators
684
+ friend bool operator==(const mersenne_twister_engine& x, const mersenne_twister_engine& y);
685
+
686
  // generating functions
687
  result_type operator()();
688
  void discard(unsigned long long z);
689
+
690
+ // inserters and extractors
691
+ template<class charT, class traits>
692
+ friend basic_ostream<charT, traits>&
693
+ operator<<(basic_ostream<charT, traits>& os, const mersenne_twister_engine& x);
694
+ template<class charT, class traits>
695
+ friend basic_istream<charT, traits>&
696
+ operator>>(basic_istream<charT, traits>& is, mersenne_twister_engine& x);
697
  };
698
+ }
699
  ```
700
 
701
  The following relations shall hold: `0 < m`, `m <= n`, `2u < w`,
702
  `r <= w`, `u <= w`, `s <= w`, `t <= w`, `l <= w`,
703
  `w <= numeric_limits<UIntType>::digits`, `a <= (1u<<w) - 1u`,
 
755
 
756
  The generation algorithm is given by GA(xᵢ) = y, where y is the value
757
  produced as a result of advancing the engine’s state as described above.
758
 
759
  ``` cpp
760
+ namespace std {
761
  template<class UIntType, size_t w, size_t s, size_t r>
762
  class subtract_with_carry_engine {
763
  public:
764
  // types
765
  using result_type = UIntType;
 
777
  explicit subtract_with_carry_engine(result_type value);
778
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
779
  void seed(result_type value = default_seed);
780
  template<class Sseq> void seed(Sseq& q);
781
 
782
+ // equality operators
783
+ friend bool operator==(const subtract_with_carry_engine& x,
784
+ const subtract_with_carry_engine& y);
785
+
786
  // generating functions
787
  result_type operator()();
788
  void discard(unsigned long long z);
789
+
790
+ // inserters and extractors
791
+ template<class charT, class traits>
792
+ friend basic_ostream<charT, traits>&
793
+ operator<<(basic_ostream<charT, traits>& os, const subtract_with_carry_engine& x);
794
+ template<class charT, class traits>
795
+ friend basic_istream<charT, traits>&
796
+ operator>>(basic_istream<charT, traits>& is, subtract_with_carry_engine& x);
797
  };
798
+ }
799
  ```
800
 
801
  The following relations shall hold: `0u < s`, `s < r`, `0 < w`, and
802
  `w <= numeric_limits<UIntType>::digits`.
803
 
 
818
  linear_congruential_engine<result_type,
819
  40014u,0u,2147483563u> e(value == 0u ? default_seed : value);
820
  ```
821
 
822
  Then, to set each Xₖ, obtain new values z₀, …, zₙ₋₁ from n = ⌈ w/32 ⌉
823
+ successive invocations of `e`. Set Xₖ to
824
  $\left( \sum_{j=0}^{n-1} z_j \cdot 2^{32j}\right) \bmod m$.
825
 
826
  *Complexity:* Exactly n ⋅ `r` invocations of `e`.
827
 
828
  ``` cpp
 
882
 
883
  The generation algorithm yields the value returned by the last
884
  invocation of `e()` while advancing `e`’s state as described above.
885
 
886
  ``` cpp
887
+ namespace std {
888
  template<class Engine, size_t p, size_t r>
889
  class discard_block_engine {
890
  public:
891
  // types
892
  using result_type = typename Engine::result_type;
 
905
  template<class Sseq> explicit discard_block_engine(Sseq& q);
906
  void seed();
907
  void seed(result_type s);
908
  template<class Sseq> void seed(Sseq& q);
909
 
910
+ // equality operators
911
+ friend bool operator==(const discard_block_engine& x, const discard_block_engine& y);
912
+
913
  // generating functions
914
  result_type operator()();
915
  void discard(unsigned long long z);
916
 
917
  // property functions
918
+ const Engine& base() const noexcept { return e; }
919
+
920
+ // inserters and extractors
921
+ template<class charT, class traits>
922
+ friend basic_ostream<charT, traits>&
923
+ operator<<(basic_ostream<charT, traits>& os, const discard_block_engine& x);
924
+ template<class charT, class traits>
925
+ friend basic_istream<charT, traits>&
926
+ operator>>(basic_istream<charT, traits>& is, discard_block_engine& x);
927
 
928
  private:
929
  Engine e; // exposition only
930
+ size_t n; // exposition only
931
  };
932
+ }
933
  ```
934
 
935
  The following relations shall hold: `0 < r` and `r <= p`.
936
 
937
  The textual representation consists of the textual representation of `e`
 
1001
  template<class Sseq> explicit independent_bits_engine(Sseq& q);
1002
  void seed();
1003
  void seed(result_type s);
1004
  template<class Sseq> void seed(Sseq& q);
1005
 
1006
+ // equality operators
1007
+ friend bool operator==(const independent_bits_engine& x, const independent_bits_engine& y);
1008
+
1009
  // generating functions
1010
  result_type operator()();
1011
  void discard(unsigned long long z);
1012
 
1013
  // property functions
1014
+ const Engine& base() const noexcept { return e; }
1015
+
1016
+ // inserters and extractors
1017
+ template<class charT, class traits>
1018
+ friend basic_ostream<charT, traits>&
1019
+ operator<<(basic_ostream<charT, traits>& os, const independent_bits_engine& x);
1020
+ template<class charT, class traits>
1021
+ friend basic_istream<charT, traits>&
1022
+ operator>>(basic_istream<charT, traits>& is, independent_bits_engine& x);
1023
 
1024
  private:
1025
  Engine e; // exposition only
1026
  };
1027
  ```
 
1052
 
1053
  The generation algorithm yields the last value of `Y` produced while
1054
  advancing `e`’s state as described above.
1055
 
1056
  ``` cpp
1057
+ namespace std {
1058
  template<class Engine, size_t k>
1059
  class shuffle_order_engine {
1060
  public:
1061
  // types
1062
  using result_type = typename Engine::result_type;
 
1074
  template<class Sseq> explicit shuffle_order_engine(Sseq& q);
1075
  void seed();
1076
  void seed(result_type s);
1077
  template<class Sseq> void seed(Sseq& q);
1078
 
1079
+ // equality operators
1080
+ friend bool operator==(const shuffle_order_engine& x, const shuffle_order_engine& y);
1081
+
1082
  // generating functions
1083
  result_type operator()();
1084
  void discard(unsigned long long z);
1085
 
1086
  // property functions
1087
+ const Engine& base() const noexcept { return e; }
1088
+
1089
+ // inserters and extractors
1090
+ template<class charT, class traits>
1091
+ friend basic_ostream<charT, traits>&
1092
+ operator<<(basic_ostream<charT, traits>& os, const shuffle_order_engine& x);
1093
+ template<class charT, class traits>
1094
+ friend basic_istream<charT, traits>&
1095
+ operator>>(basic_istream<charT, traits>& is, shuffle_order_engine& x);
1096
 
1097
  private:
1098
  Engine e; // exposition only
1099
  result_type V[k]; // exposition only
1100
  result_type Y; // exposition only
1101
  };
1102
+ }
1103
  ```
1104
 
1105
  The following relation shall hold: `0 < k`.
1106
 
1107
  The textual representation consists of the textual representation of
 
1200
  ```
1201
 
1202
  *Remarks:* The choice of engine type named by this `typedef` is
1203
  *implementation-defined*.
1204
 
1205
+ [*Note 1*: The implementation can select this type on the basis of
1206
  performance, size, quality, or any combination of such factors, so as to
1207
  provide at least acceptable engine behavior for relatively casual,
1208
+ inexpert, and/or lightweight use. Because different implementations can
1209
  select different underlying engine types, code that uses this `typedef`
1210
  need not generate identical sequences across
1211
  implementations. — *end note*]
1212
 
1213
  ### Class `random_device` <a id="rand.device">[[rand.device]]</a>
 
1217
 
1218
  If implementation limitations prevent generating nondeterministic random
1219
  numbers, the implementation may employ a random number engine.
1220
 
1221
  ``` cpp
1222
+ namespace std {
1223
  class random_device {
1224
  public:
1225
  // types
1226
  using result_type = unsigned int;
1227
 
 
1241
 
1242
  // no copy functions
1243
  random_device(const random_device&) = delete;
1244
  void operator=(const random_device&) = delete;
1245
  };
1246
+ }
1247
  ```
1248
 
1249
  ``` cpp
1250
  explicit random_device(const string& token);
1251
  ```
1252
 
1253
+ *Throws:* A value of an *implementation-defined* type derived from
1254
+ `exception` if the `random_device` cannot be initialized.
1255
+
1256
  *Remarks:* The semantics of the `token` parameter and the token value
1257
+ used by the default constructor are *implementation-defined*.[^4]
 
 
 
1258
 
1259
  ``` cpp
1260
  double entropy() const noexcept;
1261
  ```
1262
 
1263
  *Returns:* If the implementation employs a random number engine, returns
1264
+ 0.0. Otherwise, returns an entropy estimate[^5]
1265
+
1266
+ for the random numbers returned by `operator()`, in the range `min()` to
1267
+ log₂( `max()`+1).
1268
 
1269
  ``` cpp
1270
  result_type operator()();
1271
  ```
1272
 
1273
  *Returns:* A nondeterministic random value, uniformly distributed
1274
  between `min()` and `max()` (inclusive). It is *implementation-defined*
1275
  how these values are generated.
1276
 
1277
  *Throws:* A value of an *implementation-defined* type derived from
1278
+ `exception` if a random number cannot be obtained.
1279
 
1280
  ### Utilities <a id="rand.util">[[rand.util]]</a>
1281
 
1282
  #### Class `seed_seq` <a id="rand.util.seedseq">[[rand.util.seedseq]]</a>
1283
 
1284
  ``` cpp
1285
+ namespace std {
1286
  class seed_seq {
1287
  public:
1288
  // types
1289
  using result_type = uint_least32_t;
1290
 
1291
  // constructors
1292
+ seed_seq() noexcept;
1293
  template<class T>
1294
  seed_seq(initializer_list<T> il);
1295
  template<class InputIterator>
1296
  seed_seq(InputIterator begin, InputIterator end);
1297
 
 
1309
  void operator=(const seed_seq&) = delete;
1310
 
1311
  private:
1312
  vector<result_type> v; // exposition only
1313
  };
1314
+ }
1315
  ```
1316
 
1317
  ``` cpp
1318
+ seed_seq() noexcept;
1319
  ```
1320
 
1321
  *Ensures:* `v.empty()` is `true`.
1322
 
 
 
1323
  ``` cpp
1324
  template<class T>
1325
  seed_seq(initializer_list<T> il);
1326
  ```
1327
 
1328
+ *Constraints:* `T` is an integer type.
1329
 
1330
  *Effects:* Same as `seed_seq(il.begin(), il.end())`.
1331
 
1332
  ``` cpp
1333
  template<class InputIterator>
 
1443
  ``` cpp
1444
  template<class RealType, size_t bits, class URBG>
1445
  RealType generate_canonical(URBG& g);
1446
  ```
1447
 
 
 
 
 
1448
  *Effects:* Invokes `g()` k times to obtain values g₀, …, gₖ₋₁,
1449
  respectively. Calculates a quantity
1450
  $$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
1451
  \cdot R^i$$ using arithmetic of type `RealType`.
1452
 
 
1454
 
1455
  [*Note 1*: 0 ≤ S / Rᵏ < 1. — *end note*]
1456
 
1457
  *Throws:* What and when `g` throws.
1458
 
1459
+ *Complexity:* Exactly k = max(1, ⌈ b / log₂ R ⌉) invocations of `g`,
1460
+ where b[^6]
1461
+
1462
+ is the lesser of `numeric_limits<RealType>::digits` and `bits`, and R is
1463
+ the value of `g.max()` - `g.min()` + 1.
1464
+
1465
  [*Note 2*: If the values gᵢ produced by `g` are uniformly distributed,
1466
  the instantiation’s results are distributed as uniformly as possible.
1467
  Obtaining a value in this way can be a useful step in the process of
1468
  transforming a value generated by a uniform random bit generator into a
1469
  value that can be delivered by a random number
 
1498
  A `uniform_int_distribution` random number distribution produces random
1499
  integers i, a ≤ i ≤ b, distributed according to the constant discrete
1500
  probability function $$P(i\,|\,a,b) = 1 / (b - a + 1) \text{ .}$$
1501
 
1502
  ``` cpp
1503
+ namespace std {
1504
  template<class IntType = int>
1505
  class uniform_int_distribution {
1506
  public:
1507
  // types
1508
  using result_type = IntType;
 
1512
  uniform_int_distribution() : uniform_int_distribution(0) {}
1513
  explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
1514
  explicit uniform_int_distribution(const param_type& parm);
1515
  void reset();
1516
 
1517
+ // equality operators
1518
+ friend bool operator==(const uniform_int_distribution& x, const uniform_int_distribution& y);
1519
+
1520
  // generating functions
1521
  template<class URBG>
1522
  result_type operator()(URBG& g);
1523
  template<class URBG>
1524
  result_type operator()(URBG& g, const param_type& parm);
 
1528
  result_type b() const;
1529
  param_type param() const;
1530
  void param(const param_type& parm);
1531
  result_type min() const;
1532
  result_type max() const;
1533
+
1534
+ // inserters and extractors
1535
+ template<class charT, class traits>
1536
+ friend basic_ostream<charT, traits>&
1537
+ operator<<(basic_ostream<charT, traits>& os, const uniform_int_distribution& x);
1538
+ template<class charT, class traits>
1539
+ friend basic_istream<charT, traits>&
1540
+ operator>>(basic_istream<charT, traits>& is, uniform_int_distribution& x);
1541
  };
1542
+ }
1543
  ```
1544
 
1545
  ``` cpp
1546
  explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
1547
  ```
 
1573
 
1574
  [*Note 1*: This implies that p(x | a,b) is undefined when
1575
  `a == b`. — *end note*]
1576
 
1577
  ``` cpp
1578
+ namespace std {
1579
  template<class RealType = double>
1580
  class uniform_real_distribution {
1581
  public:
1582
  // types
1583
  using result_type = RealType;
 
1587
  uniform_real_distribution() : uniform_real_distribution(0.0) {}
1588
  explicit uniform_real_distribution(RealType a, RealType b = 1.0);
1589
  explicit uniform_real_distribution(const param_type& parm);
1590
  void reset();
1591
 
1592
+ // equality operators
1593
+ friend bool operator==(const uniform_real_distribution& x,
1594
+ const uniform_real_distribution& y);
1595
+
1596
  // generating functions
1597
  template<class URBG>
1598
  result_type operator()(URBG& g);
1599
  template<class URBG>
1600
  result_type operator()(URBG& g, const param_type& parm);
 
1604
  result_type b() const;
1605
  param_type param() const;
1606
  void param(const param_type& parm);
1607
  result_type min() const;
1608
  result_type max() const;
1609
+
1610
+ // inserters and extractors
1611
+ template<class charT, class traits>
1612
+ friend basic_ostream<charT, traits>&
1613
+ operator<<(basic_ostream<charT, traits>& os, const uniform_real_distribution& x);
1614
+ template<class charT, class traits>
1615
+ friend basic_istream<charT, traits>&
1616
+ operator>>(basic_istream<charT, traits>& is, uniform_real_distribution& x);
1617
  };
1618
+ }
1619
  ```
1620
 
1621
  ``` cpp
1622
  explicit uniform_real_distribution(RealType a, RealType b = 1.0);
1623
  ```
 
1652
  p & \text{ if $b = \tcode{true}$, or} \\
1653
  1 - p & \text{ if $b = \tcode{false}$.}
1654
  \end{array}\right.$$
1655
 
1656
  ``` cpp
1657
+ namespace std {
1658
  class bernoulli_distribution {
1659
  public:
1660
  // types
1661
  using result_type = bool;
1662
  using param_type = unspecified;
 
1665
  bernoulli_distribution() : bernoulli_distribution(0.5) {}
1666
  explicit bernoulli_distribution(double p);
1667
  explicit bernoulli_distribution(const param_type& parm);
1668
  void reset();
1669
 
1670
+ // equality operators
1671
+ friend bool operator==(const bernoulli_distribution& x, const bernoulli_distribution& y);
1672
+
1673
  // generating functions
1674
  template<class URBG>
1675
  result_type operator()(URBG& g);
1676
  template<class URBG>
1677
  result_type operator()(URBG& g, const param_type& parm);
 
1680
  double p() const;
1681
  param_type param() const;
1682
  void param(const param_type& parm);
1683
  result_type min() const;
1684
  result_type max() const;
1685
+
1686
+ // inserters and extractors
1687
+ template<class charT, class traits>
1688
+ friend basic_ostream<charT, traits>&
1689
+ operator<<(basic_ostream<charT, traits>& os, const bernoulli_distribution& x);
1690
+ template<class charT, class traits>
1691
+ friend basic_istream<charT, traits>&
1692
+ operator>>(basic_istream<charT, traits>& is, bernoulli_distribution& x);
1693
  };
1694
+ }
1695
  ```
1696
 
1697
  ``` cpp
1698
  explicit bernoulli_distribution(double p);
1699
  ```
 
1714
  A `binomial_distribution` random number distribution produces integer
1715
  values i ≥ 0 distributed according to the discrete probability function
1716
  $$P(i\,|\,t,p) = \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i} \text{ .}$$
1717
 
1718
  ``` cpp
1719
+ namespace std {
1720
  template<class IntType = int>
1721
  class binomial_distribution {
1722
  public:
1723
  // types
1724
  using result_type = IntType;
 
1728
  binomial_distribution() : binomial_distribution(1) {}
1729
  explicit binomial_distribution(IntType t, double p = 0.5);
1730
  explicit binomial_distribution(const param_type& parm);
1731
  void reset();
1732
 
1733
+ // equality operators
1734
+ friend bool operator==(const binomial_distribution& x, const binomial_distribution& y);
1735
+
1736
  // generating functions
1737
  template<class URBG>
1738
  result_type operator()(URBG& g);
1739
  template<class URBG>
1740
  result_type operator()(URBG& g, const param_type& parm);
 
1744
  double p() const;
1745
  param_type param() const;
1746
  void param(const param_type& parm);
1747
  result_type min() const;
1748
  result_type max() const;
1749
+
1750
+ // inserters and extractors
1751
+ template<class charT, class traits>
1752
+ friend basic_ostream<charT, traits>&
1753
+ operator<<(basic_ostream<charT, traits>& os, const binomial_distribution& x);
1754
+ template<class charT, class traits>
1755
+ friend basic_istream<charT, traits>&
1756
+ operator>>(basic_istream<charT, traits>& is, binomial_distribution& x);
1757
  };
1758
+ }
1759
  ```
1760
 
1761
  ``` cpp
1762
  explicit binomial_distribution(IntType t, double p = 0.5);
1763
  ```
 
1786
  A `geometric_distribution` random number distribution produces integer
1787
  values i ≥ 0 distributed according to the discrete probability function
1788
  $$P(i\,|\,p) = p \cdot (1-p)^{i} \text{ .}$$
1789
 
1790
  ``` cpp
1791
+ namespace std {
1792
  template<class IntType = int>
1793
  class geometric_distribution {
1794
  public:
1795
  // types
1796
  using result_type = IntType;
 
1800
  geometric_distribution() : geometric_distribution(0.5) {}
1801
  explicit geometric_distribution(double p);
1802
  explicit geometric_distribution(const param_type& parm);
1803
  void reset();
1804
 
1805
+ // equality operators
1806
+ friend bool operator==(const geometric_distribution& x, const geometric_distribution& y);
1807
+
1808
  // generating functions
1809
  template<class URBG>
1810
  result_type operator()(URBG& g);
1811
  template<class URBG>
1812
  result_type operator()(URBG& g, const param_type& parm);
 
1815
  double p() const;
1816
  param_type param() const;
1817
  void param(const param_type& parm);
1818
  result_type min() const;
1819
  result_type max() const;
1820
+
1821
+ // inserters and extractors
1822
+ template<class charT, class traits>
1823
+ friend basic_ostream<charT, traits>&
1824
+ operator<<(basic_ostream<charT, traits>& os, const geometric_distribution& x);
1825
+ template<class charT, class traits>
1826
+ friend basic_istream<charT, traits>&
1827
+ operator>>(basic_istream<charT, traits>& is, geometric_distribution& x);
1828
  };
1829
+ }
1830
  ```
1831
 
1832
  ``` cpp
1833
  explicit geometric_distribution(double p);
1834
  ```
 
1853
 
1854
  [*Note 1*: This implies that P(i | k,p) is undefined when
1855
  `p == 1`. — *end note*]
1856
 
1857
  ``` cpp
1858
+ namespace std {
1859
  template<class IntType = int>
1860
  class negative_binomial_distribution {
1861
  public:
1862
  // types
1863
  using result_type = IntType;
 
1867
  negative_binomial_distribution() : negative_binomial_distribution(1) {}
1868
  explicit negative_binomial_distribution(IntType k, double p = 0.5);
1869
  explicit negative_binomial_distribution(const param_type& parm);
1870
  void reset();
1871
 
1872
+ // equality operators
1873
+ friend bool operator==(const negative_binomial_distribution& x,
1874
+ const negative_binomial_distribution& y);
1875
+
1876
  // generating functions
1877
  template<class URBG>
1878
  result_type operator()(URBG& g);
1879
  template<class URBG>
1880
  result_type operator()(URBG& g, const param_type& parm);
 
1884
  double p() const;
1885
  param_type param() const;
1886
  void param(const param_type& parm);
1887
  result_type min() const;
1888
  result_type max() const;
1889
+
1890
+ // inserters and extractors
1891
+ template<class charT, class traits>
1892
+ friend basic_ostream<charT, traits>&
1893
+ operator<<(basic_ostream<charT, traits>& os, const negative_binomial_distribution& x);
1894
+ template<class charT, class traits>
1895
+ friend basic_istream<charT, traits>&
1896
+ operator>>(basic_istream<charT, traits>& is, negative_binomial_distribution& x);
1897
  };
1898
+ }
1899
  ```
1900
 
1901
  ``` cpp
1902
  explicit negative_binomial_distribution(IntType k, double p = 0.5);
1903
  ```
 
1943
  poisson_distribution() : poisson_distribution(1.0) {}
1944
  explicit poisson_distribution(double mean);
1945
  explicit poisson_distribution(const param_type& parm);
1946
  void reset();
1947
 
1948
+ // equality operators
1949
+ friend bool operator==(const poisson_distribution& x, const poisson_distribution& y);
1950
+
1951
  // generating functions
1952
  template<class URBG>
1953
  result_type operator()(URBG& g);
1954
  template<class URBG>
1955
  result_type operator()(URBG& g, const param_type& parm);
 
1958
  double mean() const;
1959
  param_type param() const;
1960
  void param(const param_type& parm);
1961
  result_type min() const;
1962
  result_type max() const;
1963
+
1964
+ // inserters and extractors
1965
+ template<class charT, class traits>
1966
+ friend basic_ostream<charT, traits>&
1967
+ operator<<(basic_ostream<charT, traits>& os, const poisson_distribution& x);
1968
+ template<class charT, class traits>
1969
+ friend basic_istream<charT, traits>&
1970
+ operator>>(basic_istream<charT, traits>& is, poisson_distribution& x);
1971
  };
1972
  ```
1973
 
1974
  ``` cpp
1975
  explicit poisson_distribution(double mean);
 
1991
  An `exponential_distribution` random number distribution produces random
1992
  numbers x > 0 distributed according to the probability density function
1993
  $$p(x\,|\,\lambda) = \lambda e^{-\lambda x} \text{ .}$$
1994
 
1995
  ``` cpp
1996
+ namespace std {
1997
  template<class RealType = double>
1998
  class exponential_distribution {
1999
  public:
2000
  // types
2001
  using result_type = RealType;
 
2005
  exponential_distribution() : exponential_distribution(1.0) {}
2006
  explicit exponential_distribution(RealType lambda);
2007
  explicit exponential_distribution(const param_type& parm);
2008
  void reset();
2009
 
2010
+ // equality operators
2011
+ friend bool operator==(const exponential_distribution& x, const exponential_distribution& y);
2012
+
2013
  // generating functions
2014
  template<class URBG>
2015
  result_type operator()(URBG& g);
2016
  template<class URBG>
2017
  result_type operator()(URBG& g, const param_type& parm);
 
2020
  RealType lambda() const;
2021
  param_type param() const;
2022
  void param(const param_type& parm);
2023
  result_type min() const;
2024
  result_type max() const;
2025
+
2026
+ // inserters and extractors
2027
+ template<class charT, class traits>
2028
+ friend basic_ostream<charT, traits>&
2029
+ operator<<(basic_ostream<charT, traits>& os, const exponential_distribution& x);
2030
+ template<class charT, class traits>
2031
+ friend basic_istream<charT, traits>&
2032
+ operator>>(basic_istream<charT, traits>& is, exponential_distribution& x);
2033
  };
2034
+ }
2035
  ```
2036
 
2037
  ``` cpp
2038
  explicit exponential_distribution(RealType lambda);
2039
  ```
 
2056
  $$p(x\,|\,\alpha,\beta) =
2057
  \frac{e^{-x/\beta}}{\beta^{\alpha} \cdot \Gamma(\alpha)} \, \cdot \, x^{\, \alpha-1}
2058
  \text{ .}$$
2059
 
2060
  ``` cpp
2061
+ namespace std {
2062
  template<class RealType = double>
2063
  class gamma_distribution {
2064
  public:
2065
  // types
2066
  using result_type = RealType;
 
2070
  gamma_distribution() : gamma_distribution(1.0) {}
2071
  explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
2072
  explicit gamma_distribution(const param_type& parm);
2073
  void reset();
2074
 
2075
+ // equality operators
2076
+ friend bool operator==(const gamma_distribution& x, const gamma_distribution& y);
2077
+
2078
  // generating functions
2079
  template<class URBG>
2080
  result_type operator()(URBG& g);
2081
  template<class URBG>
2082
  result_type operator()(URBG& g, const param_type& parm);
 
2086
  RealType beta() const;
2087
  param_type param() const;
2088
  void param(const param_type& parm);
2089
  result_type min() const;
2090
  result_type max() const;
2091
+
2092
+ // inserters and extractors
2093
+ template<class charT, class traits>
2094
+ friend basic_ostream<charT, traits>&
2095
+ operator<<(basic_ostream<charT, traits>& os, const gamma_distribution& x);
2096
+ template<class charT, class traits>
2097
+ friend basic_istream<charT, traits>&
2098
+ operator>>(basic_istream<charT, traits>& is, gamma_distribution& x);
2099
  };
2100
+ }
2101
  ```
2102
 
2103
  ``` cpp
2104
  explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
2105
  ```
 
2131
  \cdot \left(\frac{x}{b}\right)^{a-1}
2132
  \cdot \, \exp\left( -\left(\frac{x}{b}\right)^a\right)
2133
  \text{ .}$$
2134
 
2135
  ``` cpp
2136
+ namespace std {
2137
  template<class RealType = double>
2138
  class weibull_distribution {
2139
  public:
2140
  // types
2141
  using result_type = RealType;
 
2145
  weibull_distribution() : weibull_distribution(1.0) {}
2146
  explicit weibull_distribution(RealType a, RealType b = 1.0);
2147
  explicit weibull_distribution(const param_type& parm);
2148
  void reset();
2149
 
2150
+ // equality operators
2151
+ friend bool operator==(const weibull_distribution& x, const weibull_distribution& y);
2152
+
2153
  // generating functions
2154
  template<class URBG>
2155
  result_type operator()(URBG& g);
2156
  template<class URBG>
2157
  result_type operator()(URBG& g, const param_type& parm);
 
2161
  RealType b() const;
2162
  param_type param() const;
2163
  void param(const param_type& parm);
2164
  result_type min() const;
2165
  result_type max() const;
2166
+
2167
+ // inserters and extractors
2168
+ template<class charT, class traits>
2169
+ friend basic_ostream<charT, traits>&
2170
+ operator<<(basic_ostream<charT, traits>& os, const weibull_distribution& x);
2171
+ template<class charT, class traits>
2172
+ friend basic_istream<charT, traits>&
2173
+ operator>>(basic_istream<charT, traits>& is, weibull_distribution& x);
2174
  };
2175
+ }
2176
  ```
2177
 
2178
  ``` cpp
2179
  explicit weibull_distribution(RealType a, RealType b = 1.0);
2180
  ```
 
2200
 
2201
  ##### Class template `extreme_value_distribution` <a id="rand.dist.pois.extreme">[[rand.dist.pois.extreme]]</a>
2202
 
2203
  An `extreme_value_distribution` random number distribution produces
2204
  random numbers x distributed according to the probability density
2205
+ function[^7]
2206
+
2207
+ $$p(x\,|\,a,b) = \frac{1}{b}
2208
  \cdot \exp\left(\frac{a-x}{b} - \exp\left(\frac{a-x}{b}\right)\right)
2209
  \text{ .}$$
2210
 
2211
  ``` cpp
2212
+ namespace std {
2213
  template<class RealType = double>
2214
  class extreme_value_distribution {
2215
  public:
2216
  // types
2217
  using result_type = RealType;
 
2221
  extreme_value_distribution() : extreme_value_distribution(0.0) {}
2222
  explicit extreme_value_distribution(RealType a, RealType b = 1.0);
2223
  explicit extreme_value_distribution(const param_type& parm);
2224
  void reset();
2225
 
2226
+ // equality operators
2227
+ friend bool operator==(const extreme_value_distribution& x,
2228
+ const extreme_value_distribution& y);
2229
+
2230
  // generating functions
2231
  template<class URBG>
2232
  result_type operator()(URBG& g);
2233
  template<class URBG>
2234
  result_type operator()(URBG& g, const param_type& parm);
 
2238
  RealType b() const;
2239
  param_type param() const;
2240
  void param(const param_type& parm);
2241
  result_type min() const;
2242
  result_type max() const;
2243
+
2244
+ // inserters and extractors
2245
+ template<class charT, class traits>
2246
+ friend basic_ostream<charT, traits>&
2247
+ operator<<(basic_ostream<charT, traits>& os, const extreme_value_distribution& x);
2248
+ template<class charT, class traits>
2249
+ friend basic_istream<charT, traits>&
2250
+ operator>>(basic_istream<charT, traits>& is, extreme_value_distribution& x);
2251
  };
2252
+ }
2253
  ```
2254
 
2255
  ``` cpp
2256
  explicit extreme_value_distribution(RealType a, RealType b = 1.0);
2257
  ```
 
2291
  }
2292
  \text{ .}$$ The distribution parameters μ and σ are also known as this
2293
  distribution’s *mean* and *standard deviation*.
2294
 
2295
  ``` cpp
2296
+ namespace std {
2297
  template<class RealType = double>
2298
  class normal_distribution {
2299
  public:
2300
  // types
2301
  using result_type = RealType;
 
2305
  normal_distribution() : normal_distribution(0.0) {}
2306
  explicit normal_distribution(RealType mean, RealType stddev = 1.0);
2307
  explicit normal_distribution(const param_type& parm);
2308
  void reset();
2309
 
2310
+ // equality operators
2311
+ friend bool operator==(const normal_distribution& x, const normal_distribution& y);
2312
+
2313
  // generating functions
2314
  template<class URBG>
2315
  result_type operator()(URBG& g);
2316
  template<class URBG>
2317
  result_type operator()(URBG& g, const param_type& parm);
 
2321
  RealType stddev() const;
2322
  param_type param() const;
2323
  void param(const param_type& parm);
2324
  result_type min() const;
2325
  result_type max() const;
2326
+
2327
+ // inserters and extractors
2328
+ template<class charT, class traits>
2329
+ friend basic_ostream<charT, traits>&
2330
+ operator<<(basic_ostream<charT, traits>& os, const normal_distribution& x);
2331
+ template<class charT, class traits>
2332
+ friend basic_istream<charT, traits>&
2333
+ operator>>(basic_istream<charT, traits>& is, normal_distribution& x);
2334
  };
2335
+ }
2336
  ```
2337
 
2338
  ``` cpp
2339
  explicit normal_distribution(RealType mean, RealType stddev = 1.0);
2340
  ```
 
2365
  $$p(x\,|\,m,s) = \frac{1}{s x \sqrt{2 \pi}}
2366
  \cdot \exp{\left(-\frac{(\ln{x} - m)^2}{2 s^2}\right)}
2367
  \text{ .}$$
2368
 
2369
  ``` cpp
2370
+ namespace std {
2371
  template<class RealType = double>
2372
  class lognormal_distribution {
2373
  public:
2374
  // types
2375
  using result_type = RealType;
 
2379
  lognormal_distribution() : lognormal_distribution(0.0) {}
2380
  explicit lognormal_distribution(RealType m, RealType s = 1.0);
2381
  explicit lognormal_distribution(const param_type& parm);
2382
  void reset();
2383
 
2384
+ // equality operators
2385
+ friend bool operator==(const lognormal_distribution& x, const lognormal_distribution& y);
2386
+
2387
  // generating functions
2388
  template<class URBG>
2389
  result_type operator()(URBG& g);
2390
  template<class URBG>
2391
  result_type operator()(URBG& g, const param_type& parm);
 
2395
  RealType s() const;
2396
  param_type param() const;
2397
  void param(const param_type& parm);
2398
  result_type min() const;
2399
  result_type max() const;
2400
+
2401
+ // inserters and extractors
2402
+ template<class charT, class traits>
2403
+ friend basic_ostream<charT, traits>&
2404
+ operator<<(basic_ostream<charT, traits>& os, const lognormal_distribution& x);
2405
+ template<class charT, class traits>
2406
+ friend basic_istream<charT, traits>&
2407
+ operator>>(basic_istream<charT, traits>& is, lognormal_distribution& x);
2408
  };
2409
+ }
2410
  ```
2411
 
2412
  ``` cpp
2413
  explicit lognormal_distribution(RealType m, RealType s = 1.0);
2414
  ```
 
2437
  A `chi_squared_distribution` random number distribution produces random
2438
  numbers x > 0 distributed according to the probability density function
2439
  $$p(x\,|\,n) = \frac{x^{(n/2)-1} \cdot e^{-x/2}}{\Gamma(n/2) \cdot 2^{n/2}} \text{ .}$$
2440
 
2441
  ``` cpp
2442
+ namespace std {
2443
  template<class RealType = double>
2444
  class chi_squared_distribution {
2445
  public:
2446
  // types
2447
  using result_type = RealType;
 
2451
  chi_squared_distribution() : chi_squared_distribution(1.0) {}
2452
  explicit chi_squared_distribution(RealType n);
2453
  explicit chi_squared_distribution(const param_type& parm);
2454
  void reset();
2455
 
2456
+ // equality operators
2457
+ friend bool operator==(const chi_squared_distribution& x, const chi_squared_distribution& y);
2458
+
2459
  // generating functions
2460
  template<class URBG>
2461
  result_type operator()(URBG& g);
2462
  template<class URBG>
2463
  result_type operator()(URBG& g, const param_type& parm);
 
2466
  RealType n() const;
2467
  param_type param() const;
2468
  void param(const param_type& parm);
2469
  result_type min() const;
2470
  result_type max() const;
2471
+
2472
+ // inserters and extractors
2473
+ template<class charT, class traits>
2474
+ friend basic_ostream<charT, traits>&
2475
+ operator<<(basic_ostream<charT, traits>& os, const chi_squared_distribution& x);
2476
+ template<class charT, class traits>
2477
+ friend basic_istream<charT, traits>&
2478
+ operator>>(basic_istream<charT, traits>& is, chi_squared_distribution& x);
2479
  };
2480
+ }
2481
  ```
2482
 
2483
  ``` cpp
2484
  explicit chi_squared_distribution(RealType n);
2485
  ```
 
2500
  A `cauchy_distribution` random number distribution produces random
2501
  numbers x distributed according to the probability density function
2502
  $$p(x\,|\,a,b) = \left(\pi b \left(1 + \left(\frac{x-a}{b} \right)^2 \, \right)\right)^{-1} \text{ .}$$
2503
 
2504
  ``` cpp
2505
+ namespace std {
2506
  template<class RealType = double>
2507
  class cauchy_distribution {
2508
  public:
2509
  // types
2510
  using result_type = RealType;
 
2514
  cauchy_distribution() : cauchy_distribution(0.0) {}
2515
  explicit cauchy_distribution(RealType a, RealType b = 1.0);
2516
  explicit cauchy_distribution(const param_type& parm);
2517
  void reset();
2518
 
2519
+ // equality operators
2520
+ friend bool operator==(const cauchy_distribution& x, const cauchy_distribution& y);
2521
+
2522
  // generating functions
2523
  template<class URBG>
2524
  result_type operator()(URBG& g);
2525
  template<class URBG>
2526
  result_type operator()(URBG& g, const param_type& parm);
 
2530
  RealType b() const;
2531
  param_type param() const;
2532
  void param(const param_type& parm);
2533
  result_type min() const;
2534
  result_type max() const;
2535
+
2536
+ // inserters and extractors
2537
+ template<class charT, class traits>
2538
+ friend basic_ostream<charT, traits>&
2539
+ operator<<(basic_ostream<charT, traits>& os, const cauchy_distribution& x);
2540
+ template<class charT, class traits>
2541
+ friend basic_istream<charT, traits>&
2542
+ operator>>(basic_istream<charT, traits>& is, cauchy_distribution& x);
2543
  };
2544
+ }
2545
  ```
2546
 
2547
  ``` cpp
2548
  explicit cauchy_distribution(RealType a, RealType b = 1.0);
2549
  ```
 
2576
  \cdot x^{(m/2)-1}
2577
  \cdot \left(1 + \frac{m x}{n}\right)^{-(m + n)/2}
2578
  \text{ .}$$
2579
 
2580
  ``` cpp
2581
+ namespace std {
2582
  template<class RealType = double>
2583
  class fisher_f_distribution {
2584
  public:
2585
  // types
2586
  using result_type = RealType;
 
2590
  fisher_f_distribution() : fisher_f_distribution(1.0) {}
2591
  explicit fisher_f_distribution(RealType m, RealType n = 1.0);
2592
  explicit fisher_f_distribution(const param_type& parm);
2593
  void reset();
2594
 
2595
+ // equality operators
2596
+ friend bool operator==(const fisher_f_distribution& x, const fisher_f_distribution& y);
2597
+
2598
  // generating functions
2599
  template<class URBG>
2600
  result_type operator()(URBG& g);
2601
  template<class URBG>
2602
  result_type operator()(URBG& g, const param_type& parm);
 
2606
  RealType n() const;
2607
  param_type param() const;
2608
  void param(const param_type& parm);
2609
  result_type min() const;
2610
  result_type max() const;
2611
+
2612
+ // inserters and extractors
2613
+ template<class charT, class traits>
2614
+ friend basic_ostream<charT, traits>&
2615
+ operator<<(basic_ostream<charT, traits>& os, const fisher_f_distribution& x);
2616
+ template<class charT, class traits>
2617
+ friend basic_istream<charT, traits>&
2618
+ operator>>(basic_istream<charT, traits>& is, fisher_f_distribution& x);
2619
  };
2620
+ }
2621
  ```
2622
 
2623
  ``` cpp
2624
  explicit fisher_f_distribution(RealType m, RealType n = 1);
2625
  ```
 
2651
  \cdot \frac{\Gamma\big((n+1)/2\big)}{\Gamma(n/2)}
2652
  \cdot \left(1 + \frac{x^2}{n} \right)^{-(n+1)/2}
2653
  \text{ .}$$
2654
 
2655
  ``` cpp
2656
+ namespace std {
2657
  template<class RealType = double>
2658
  class student_t_distribution {
2659
  public:
2660
  // types
2661
  using result_type = RealType;
 
2665
  student_t_distribution() : student_t_distribution(1.0) {}
2666
  explicit student_t_distribution(RealType n);
2667
  explicit student_t_distribution(const param_type& parm);
2668
  void reset();
2669
 
2670
+ // equality operators
2671
+ friend bool operator==(const student_t_distribution& x, const student_t_distribution& y);
2672
+
2673
  // generating functions
2674
  template<class URBG>
2675
  result_type operator()(URBG& g);
2676
  template<class URBG>
2677
  result_type operator()(URBG& g, const param_type& parm);
 
2680
  RealType n() const;
2681
  param_type param() const;
2682
  void param(const param_type& parm);
2683
  result_type min() const;
2684
  result_type max() const;
2685
+
2686
+ // inserters and extractors
2687
+ template<class charT, class traits>
2688
+ friend basic_ostream<charT, traits>&
2689
+ operator<<(basic_ostream<charT, traits>& os, const student_t_distribution& x);
2690
+ template<class charT, class traits>
2691
+ friend basic_istream<charT, traits>&
2692
+ operator>>(basic_istream<charT, traits>& is, student_t_distribution& x);
2693
  };
2694
+ }
2695
  ```
2696
 
2697
  ``` cpp
2698
  explicit student_t_distribution(RealType n);
2699
  ```
 
2722
  known as the *weights* , shall be non-negative, non-NaN, and
2723
  non-infinity. Moreover, the following relation shall hold:
2724
  $0 < S = w_0 + \dotsb + w_{n - 1}$.
2725
 
2726
  ``` cpp
2727
+ namespace std {
2728
  template<class IntType = int>
2729
  class discrete_distribution {
2730
  public:
2731
  // types
2732
  using result_type = IntType;
 
2740
  template<class UnaryOperation>
2741
  discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
2742
  explicit discrete_distribution(const param_type& parm);
2743
  void reset();
2744
 
2745
+ // equality operators
2746
+ friend bool operator==(const discrete_distribution& x, const discrete_distribution& y);
2747
+
2748
  // generating functions
2749
  template<class URBG>
2750
  result_type operator()(URBG& g);
2751
  template<class URBG>
2752
  result_type operator()(URBG& g, const param_type& parm);
 
2755
  vector<double> probabilities() const;
2756
  param_type param() const;
2757
  void param(const param_type& parm);
2758
  result_type min() const;
2759
  result_type max() const;
2760
+
2761
+ // inserters and extractors
2762
+ template<class charT, class traits>
2763
+ friend basic_ostream<charT, traits>&
2764
+ operator<<(basic_ostream<charT, traits>& os, const discrete_distribution& x);
2765
+ template<class charT, class traits>
2766
+ friend basic_istream<charT, traits>&
2767
+ operator>>(basic_istream<charT, traits>& is, discrete_distribution& x);
2768
  };
2769
+ }
2770
  ```
2771
 
2772
  ``` cpp
2773
  discrete_distribution();
2774
  ```
 
2844
  in which the values wₖ, commonly known as the *weights* , shall be
2845
  non-negative, non-NaN, and non-infinity. Moreover, the following
2846
  relation shall hold: 0 < S = w₀ + … + wₙ₋₁.
2847
 
2848
  ``` cpp
2849
+ namespace std {
2850
  template<class RealType = double>
2851
  class piecewise_constant_distribution {
2852
  public:
2853
  // types
2854
  using result_type = RealType;
 
2865
  piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax,
2866
  UnaryOperation fw);
2867
  explicit piecewise_constant_distribution(const param_type& parm);
2868
  void reset();
2869
 
2870
+ // equality operators
2871
+ friend bool operator==(const piecewise_constant_distribution& x,
2872
+ const piecewise_constant_distribution& y);
2873
+
2874
  // generating functions
2875
  template<class URBG>
2876
  result_type operator()(URBG& g);
2877
  template<class URBG>
2878
  result_type operator()(URBG& g, const param_type& parm);
 
2882
  vector<result_type> densities() const;
2883
  param_type param() const;
2884
  void param(const param_type& parm);
2885
  result_type min() const;
2886
  result_type max() const;
2887
+
2888
+ // inserters and extractors
2889
+ template<class charT, class traits>
2890
+ friend basic_ostream<charT, traits>&
2891
+ operator<<(basic_ostream<charT, traits>& os, const piecewise_constant_distribution& x);
2892
+ template<class charT, class traits>
2893
+ friend basic_istream<charT, traits>&
2894
+ operator>>(basic_istream<charT, traits>& is, piecewise_constant_distribution& x);
2895
  };
2896
+ }
2897
  ```
2898
 
2899
  ``` cpp
2900
  piecewise_constant_distribution();
2901
  ```
 
2994
  shall be non-negative, non-NaN, and non-infinity. Moreover, the
2995
  following relation shall hold:
2996
  $$0 < S = \frac{1}{2} \cdot \sum_{k=0}^{n-1} (w_k + w_{k+1}) \cdot (b_{k+1} - b_k) \text{ .}$$
2997
 
2998
  ``` cpp
2999
+ namespace std {
3000
  template<class RealType = double>
3001
  class piecewise_linear_distribution {
3002
  public:
3003
  // types
3004
  using result_type = RealType;
 
3014
  template<class UnaryOperation>
3015
  piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
3016
  explicit piecewise_linear_distribution(const param_type& parm);
3017
  void reset();
3018
 
3019
+ // equality operators
3020
+ friend bool operator==(const piecewise_linear_distribution& x,
3021
+ const piecewise_linear_distribution& y);
3022
+
3023
  // generating functions
3024
  template<class URBG>
3025
  result_type operator()(URBG& g);
3026
  template<class URBG>
3027
  result_type operator()(URBG& g, const param_type& parm);
 
3031
  vector<result_type> densities() const;
3032
  param_type param() const;
3033
  void param(const param_type& parm);
3034
  result_type min() const;
3035
  result_type max() const;
3036
+
3037
+ // inserters and extractors
3038
+ template<class charT, class traits>
3039
+ friend basic_ostream<charT, traits>&
3040
+ operator<<(basic_ostream<charT, traits>& os, const piecewise_linear_distribution& x);
3041
+ template<class charT, class traits>
3042
+ friend basic_istream<charT, traits>&
3043
+ operator>>(basic_istream<charT, traits>& is, piecewise_linear_distribution& x);
3044
  };
3045
+ }
3046
  ```
3047
 
3048
  ``` cpp
3049
  piecewise_linear_distribution();
3050
  ```