From Jason Turner

[rand.dist.samp.pconst]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpi0t5du5t/{from.md → to.md} +31 -36
tmp/tmpi0t5du5t/{from.md → to.md} RENAMED
@@ -1,27 +1,21 @@
1
  ##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
2
 
3
  A `piecewise_constant_distribution` random number distribution produces
4
  random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
5
  subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
6
- $$%
7
- p(x\,|\,b_0,\ldots,b_n,\;\rho_0,\ldots,\rho_{n-1})
8
- = \rho_i
9
- \; \mbox{,}
10
- \mbox{ for } b_i \le x < b_{i+1}
11
- \; \mbox{.}$$
12
 
13
  The n + 1 distribution parameters bᵢ, also known as this distribution’s
14
- *interval boundaries* , shall satisfy the relation bᵢ < bᵢ₊₁ for
15
- i = 0, …, n-1. Unless specified otherwise, the remaining n distribution
16
- parameters are calculated as: $$%
17
- \rho_k = \;
18
- \frac{w_k}{S \cdot (b_{k+1}-b_k)}
19
- \; \mbox{ for } k = 0, \ldots, n\!-\!1,$$ in which the values wₖ,
20
- commonly known as the *weights* , shall be non-negative, non-NaN, and
21
- non-infinity. Moreover, the following relation shall hold:
22
- 0 < S = w₀ + ⋯ + wₙ₋₁.
23
 
24
  ``` cpp
25
  template<class RealType = double>
26
  class piecewise_constant_distribution {
27
  public:
@@ -69,59 +63,60 @@ n = 1, ρ₀ = 1, b₀ = 0, and b₁ = 1.
69
  template<class InputIteratorB, class InputIteratorW>
70
  piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
71
  InputIteratorW firstW);
72
  ```
73
 
74
- *Requires:* `InputIteratorB` and `InputIteratorW` shall each satisfy the
75
- requirements of an input iterator
76
- (Table  [[tab:iterator.input.requirements]]) type. Moreover,
77
- `iterator_traits<InputIteratorB>::value_type` and
78
- `iterator_traits<InputIteratorW>::value_type` shall each denote a type
79
- that is convertible to `double`. If `firstB == lastB` or
80
- `++firstB == lastB`, let n = 1, w₀ = 1, b₀ = 0, and b₁ = 1. Otherwise,
81
- [`firstB`, `lastB`) shall form a sequence b of length n+1, the length of
82
- the sequence w starting from `firstW` shall be at least n, and any wₖ
83
- for k n shall be ignored by the distribution.
 
 
 
84
 
85
  *Effects:* Constructs a `piecewise_constant_distribution` object with
86
  parameters as specified above.
87
 
88
  ``` cpp
89
  template<class UnaryOperation>
90
  piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
91
  ```
92
 
93
- *Requires:* Each instance of type `UnaryOperation` shall be a function
94
- object ([[function.objects]]) whose return type shall be convertible to
95
- `double`. Moreover, `double` shall be convertible to the type of
96
- `UnaryOperation`’s sole parameter.
97
 
98
  *Effects:* Constructs a `piecewise_constant_distribution` object with
99
  parameters taken or calculated from the following values: If
100
  `bl.size()` < 2, let n = 1, w₀ = 1, b₀ = 0, and b₁ = 1. Otherwise, let
101
  [`bl.begin()`, `bl.end()`) form a sequence b₀, …, bₙ, and let
102
  wₖ = `fw`((bₖ₊₁ + bₖ) / 2) for k = 0, …, n - 1.
103
 
104
- *Complexity:* The number of invocations of `fw` shall not exceed n.
105
 
106
  ``` cpp
107
  template<class UnaryOperation>
108
  piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
109
  ```
110
 
111
- *Requires:* Each instance of type `UnaryOperation` shall be a function
112
- object ([[function.objects]]) whose return type shall be convertible to
113
- `double`. Moreover, `double` shall be convertible to the type of
114
- `UnaryOperation`’s sole parameter. If `nw` = 0, let n = 1, otherwise let
115
- n = `nw`. The relation 0 < δ = (`xmax` - `xmin`) / n shall hold.
116
 
117
  *Effects:* Constructs a `piecewise_constant_distribution` object with
118
  parameters taken or calculated from the following values: Let
119
  bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ + δ / 2) for
120
  k = 0, …, n - 1.
121
 
122
- *Complexity:* The number of invocations of `fw` shall not exceed n.
123
 
124
  ``` cpp
125
  vector<result_type> intervals() const;
126
  ```
127
 
 
1
  ##### Class template `piecewise_constant_distribution` <a id="rand.dist.samp.pconst">[[rand.dist.samp.pconst]]</a>
2
 
3
  A `piecewise_constant_distribution` random number distribution produces
4
  random numbers x, b₀ ≤ x < bₙ, uniformly distributed over each
5
  subinterval [ bᵢ, bᵢ₊₁ ) according to the probability density function
6
+ $$p(x \,|\, b_0, \dotsc, b_n, \; \rho_0, \dotsc, \rho_{n-1}) = \rho_i
7
+ \text{ , for $b_i \le x < b_{i+1}$.}$$
 
 
 
 
8
 
9
  The n + 1 distribution parameters bᵢ, also known as this distribution’s
10
+ *interval boundaries* , shall satisfy the relation $b_i < b_{i + 1}$ for
11
+ i = 0, …, n - 1. Unless specified otherwise, the remaining n
12
+ distribution parameters are calculated as:
13
+ $$\rho_k = \frac{w_k}{S \cdot (b_{k+1}-b_k)} \text{ for } k = 0, \dotsc, n - 1 \text{ ,}$$
14
+ in which the values wₖ, commonly known as the *weights* , shall be
15
+ non-negative, non-NaN, and non-infinity. Moreover, the following
16
+ relation shall hold: 0 < S = w₀ + + wₙ₋₁.
 
 
17
 
18
  ``` cpp
19
  template<class RealType = double>
20
  class piecewise_constant_distribution {
21
  public:
 
63
  template<class InputIteratorB, class InputIteratorW>
64
  piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
65
  InputIteratorW firstW);
66
  ```
67
 
68
+ *Mandates:* Both of
69
+
70
+ - `is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>`
71
+ - `is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>`
72
+
73
+ are `true`.
74
+
75
+ *Preconditions:* `InputIteratorB` and `InputIteratorW` each meet the
76
+ *Cpp17InputIterator* requirements [[input.iterators]]. If
77
+ `firstB == lastB` or `++firstB == lastB`, let n = 1, w₀ = 1, b₀ = 0, and
78
+ b₁ = 1. Otherwise, [`firstB`, `lastB`) forms a sequence b of length n+1,
79
+ the length of the sequence w starting from `firstW` is at least n, and
80
+ any wₖ for k ≥ n are ignored by the distribution.
81
 
82
  *Effects:* Constructs a `piecewise_constant_distribution` object with
83
  parameters as specified above.
84
 
85
  ``` cpp
86
  template<class UnaryOperation>
87
  piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
88
  ```
89
 
90
+ *Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
91
+ `true`.
 
 
92
 
93
  *Effects:* Constructs a `piecewise_constant_distribution` object with
94
  parameters taken or calculated from the following values: If
95
  `bl.size()` < 2, let n = 1, w₀ = 1, b₀ = 0, and b₁ = 1. Otherwise, let
96
  [`bl.begin()`, `bl.end()`) form a sequence b₀, …, bₙ, and let
97
  wₖ = `fw`((bₖ₊₁ + bₖ) / 2) for k = 0, …, n - 1.
98
 
99
+ *Complexity:* The number of invocations of `fw` does not exceed n.
100
 
101
  ``` cpp
102
  template<class UnaryOperation>
103
  piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
104
  ```
105
 
106
+ *Mandates:* `is_invocable_r_v<double, UnaryOperation&, double>` is
107
+ `true`.
108
+
109
+ *Preconditions:* If `nw` = 0, let n = 1, otherwise let n = `nw`. The
110
+ relation 0 < δ = (`xmax` - `xmin`) / n holds.
111
 
112
  *Effects:* Constructs a `piecewise_constant_distribution` object with
113
  parameters taken or calculated from the following values: Let
114
  bₖ = `xmin` + k ⋅ δ for k = 0, …, n, and wₖ = `fw`(bₖ + δ / 2) for
115
  k = 0, …, n - 1.
116
 
117
+ *Complexity:* The number of invocations of `fw` does not exceed n.
118
 
119
  ``` cpp
120
  vector<result_type> intervals() const;
121
  ```
122