From Jason Turner

[rand.dist.samp.plinear]

Diff to HTML by rtfpessoa

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