From Jason Turner

[rand.dist.bern]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpo82mrrcd/{from.md → to.md} +31 -39
tmp/tmpo82mrrcd/{from.md → to.md} RENAMED
@@ -1,27 +1,26 @@
1
  #### Bernoulli distributions <a id="rand.dist.bern">[[rand.dist.bern]]</a>
2
 
3
  ##### Class `bernoulli_distribution` <a id="rand.dist.bern.bernoulli">[[rand.dist.bern.bernoulli]]</a>
4
 
5
  A `bernoulli_distribution` random number distribution produces `bool`
6
- values b distributed according to the discrete probability function $$%
7
- P(b\,|\,p)
8
- = \left\{ \begin{array}{lcl}
9
- p & \mbox{if} & b = \tcode{true} \\
10
- 1-p & \mbox{if} & b = \tcode{false}
11
- \end{array}\right.
12
- \; \mbox{.}$$
13
 
14
  ``` cpp
15
  class bernoulli_distribution {
16
  public:
17
  // types
18
  using result_type = bool;
19
  using param_type = unspecified;
20
 
21
  // constructors and reset functions
22
- explicit bernoulli_distribution(double p = 0.5);
 
23
  explicit bernoulli_distribution(const param_type& parm);
24
  void reset();
25
 
26
  // generating functions
27
  template<class URBG>
@@ -37,17 +36,16 @@ public:
37
  result_type max() const;
38
  };
39
  ```
40
 
41
  ``` cpp
42
- explicit bernoulli_distribution(double p = 0.5);
43
  ```
44
 
45
- *Requires:* 0 ≤ `p` ≤ 1.
46
 
47
- *Effects:* Constructs a `bernoulli_distribution` object; `p` corresponds
48
- to the parameter of the distribution.
49
 
50
  ``` cpp
51
  double p() const;
52
  ```
53
 
@@ -56,25 +54,23 @@ constructed.
56
 
57
  ##### Class template `binomial_distribution` <a id="rand.dist.bern.bin">[[rand.dist.bern.bin]]</a>
58
 
59
  A `binomial_distribution` random number distribution produces integer
60
  values i ≥ 0 distributed according to the discrete probability function
61
- $$%
62
- P(i\,|\,t,p)
63
- = \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i}
64
- \; \mbox{.}$$
65
 
66
  ``` cpp
67
  template<class IntType = int>
68
  class binomial_distribution {
69
  public:
70
  // types
71
  using result_type = IntType;
72
  using param_type = unspecified;
73
 
74
  // constructors and reset functions
75
- explicit binomial_distribution(IntType t = 1, double p = 0.5);
 
76
  explicit binomial_distribution(const param_type& parm);
77
  void reset();
78
 
79
  // generating functions
80
  template<class URBG>
@@ -91,17 +87,17 @@ template<class IntType = int>
91
  result_type max() const;
92
  };
93
  ```
94
 
95
  ``` cpp
96
- explicit binomial_distribution(IntType t = 1, double p = 0.5);
97
  ```
98
 
99
- *Requires:* 0 ≤ `p` ≤ 1 and 0 ≤ `t`.
100
 
101
- *Effects:* Constructs a `binomial_distribution` object; `t` and `p`
102
- correspond to the respective parameters of the distribution.
103
 
104
  ``` cpp
105
  IntType t() const;
106
  ```
107
 
@@ -117,25 +113,23 @@ constructed.
117
 
118
  ##### Class template `geometric_distribution` <a id="rand.dist.bern.geo">[[rand.dist.bern.geo]]</a>
119
 
120
  A `geometric_distribution` random number distribution produces integer
121
  values i ≥ 0 distributed according to the discrete probability function
122
- $$%
123
- P(i\,|\,p)
124
- = p \cdot (1-p)^{i}
125
- \; \mbox{.}$$
126
 
127
  ``` cpp
128
  template<class IntType = int>
129
  class geometric_distribution {
130
  public:
131
  // types
132
  using result_type = IntType;
133
  using param_type = unspecified;
134
 
135
  // constructors and reset functions
136
- explicit geometric_distribution(double p = 0.5);
 
137
  explicit geometric_distribution(const param_type& parm);
138
  void reset();
139
 
140
  // generating functions
141
  template<class URBG>
@@ -151,17 +145,16 @@ template<class IntType = int>
151
  result_type max() const;
152
  };
153
  ```
154
 
155
  ``` cpp
156
- explicit geometric_distribution(double p = 0.5);
157
  ```
158
 
159
- *Requires:* 0 < `p` < 1.
160
 
161
- *Effects:* Constructs a `geometric_distribution` object; `p` corresponds
162
- to the parameter of the distribution.
163
 
164
  ``` cpp
165
  double p() const;
166
  ```
167
 
@@ -170,14 +163,12 @@ constructed.
170
 
171
  ##### Class template `negative_binomial_distribution` <a id="rand.dist.bern.negbin">[[rand.dist.bern.negbin]]</a>
172
 
173
  A `negative_binomial_distribution` random number distribution produces
174
  random integers i ≥ 0 distributed according to the discrete probability
175
- function $$%
176
- P(i\,|\,k,p)
177
- = \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i
178
- \; \mbox{.}$$
179
 
180
  [*Note 1*: This implies that P(i | k,p) is undefined when
181
  `p == 1`. — *end note*]
182
 
183
  ``` cpp
@@ -187,11 +178,12 @@ template<class IntType = int>
187
  // types
188
  using result_type = IntType;
189
  using param_type = unspecified;
190
 
191
  // constructor and reset functions
192
- explicit negative_binomial_distribution(IntType k = 1, double p = 0.5);
 
193
  explicit negative_binomial_distribution(const param_type& parm);
194
  void reset();
195
 
196
  // generating functions
197
  template<class URBG>
@@ -208,17 +200,17 @@ template<class IntType = int>
208
  result_type max() const;
209
  };
210
  ```
211
 
212
  ``` cpp
213
- explicit negative_binomial_distribution(IntType k = 1, double p = 0.5);
214
  ```
215
 
216
- *Requires:* 0 < `p` ≤ 1 and 0 < `k`.
217
 
218
- *Effects:* Constructs a `negative_binomial_distribution` object; `k` and
219
- `p` correspond to the respective parameters of the distribution.
220
 
221
  ``` cpp
222
  IntType k() const;
223
  ```
224
 
 
1
  #### Bernoulli distributions <a id="rand.dist.bern">[[rand.dist.bern]]</a>
2
 
3
  ##### Class `bernoulli_distribution` <a id="rand.dist.bern.bernoulli">[[rand.dist.bern.bernoulli]]</a>
4
 
5
  A `bernoulli_distribution` random number distribution produces `bool`
6
+ values b distributed according to the discrete probability function
7
+ $$P(b\,|\,p) = \left\{ \begin{array}{ll}
8
+ p & \text{ if $b = \tcode{true}$, or} \\
9
+ 1 - p & \text{ if $b = \tcode{false}$.}
10
+ \end{array}\right.$$
 
 
11
 
12
  ``` cpp
13
  class bernoulli_distribution {
14
  public:
15
  // types
16
  using result_type = bool;
17
  using param_type = unspecified;
18
 
19
  // constructors and reset functions
20
+ bernoulli_distribution() : bernoulli_distribution(0.5) {}
21
+ explicit bernoulli_distribution(double p);
22
  explicit bernoulli_distribution(const param_type& parm);
23
  void reset();
24
 
25
  // generating functions
26
  template<class URBG>
 
36
  result_type max() const;
37
  };
38
  ```
39
 
40
  ``` cpp
41
+ explicit bernoulli_distribution(double p);
42
  ```
43
 
44
+ *Preconditions:* 0 ≤ `p` ≤ 1.
45
 
46
+ *Remarks:* `p` corresponds to the parameter of the distribution.
 
47
 
48
  ``` cpp
49
  double p() const;
50
  ```
51
 
 
54
 
55
  ##### Class template `binomial_distribution` <a id="rand.dist.bern.bin">[[rand.dist.bern.bin]]</a>
56
 
57
  A `binomial_distribution` random number distribution produces integer
58
  values i ≥ 0 distributed according to the discrete probability function
59
+ $$P(i\,|\,t,p) = \binom{t}{i} \cdot p^i \cdot (1-p)^{t-i} \text{ .}$$
 
 
 
60
 
61
  ``` cpp
62
  template<class IntType = int>
63
  class binomial_distribution {
64
  public:
65
  // types
66
  using result_type = IntType;
67
  using param_type = unspecified;
68
 
69
  // constructors and reset functions
70
+ binomial_distribution() : binomial_distribution(1) {}
71
+ explicit binomial_distribution(IntType t, double p = 0.5);
72
  explicit binomial_distribution(const param_type& parm);
73
  void reset();
74
 
75
  // generating functions
76
  template<class URBG>
 
87
  result_type max() const;
88
  };
89
  ```
90
 
91
  ``` cpp
92
+ explicit binomial_distribution(IntType t, double p = 0.5);
93
  ```
94
 
95
+ *Preconditions:* 0 ≤ `p` ≤ 1 and 0 ≤ `t`.
96
 
97
+ *Remarks:* `t` and `p` correspond to the respective parameters of the
98
+ distribution.
99
 
100
  ``` cpp
101
  IntType t() const;
102
  ```
103
 
 
113
 
114
  ##### Class template `geometric_distribution` <a id="rand.dist.bern.geo">[[rand.dist.bern.geo]]</a>
115
 
116
  A `geometric_distribution` random number distribution produces integer
117
  values i ≥ 0 distributed according to the discrete probability function
118
+ $$P(i\,|\,p) = p \cdot (1-p)^{i} \text{ .}$$
 
 
 
119
 
120
  ``` cpp
121
  template<class IntType = int>
122
  class geometric_distribution {
123
  public:
124
  // types
125
  using result_type = IntType;
126
  using param_type = unspecified;
127
 
128
  // constructors and reset functions
129
+ geometric_distribution() : geometric_distribution(0.5) {}
130
+ explicit geometric_distribution(double p);
131
  explicit geometric_distribution(const param_type& parm);
132
  void reset();
133
 
134
  // generating functions
135
  template<class URBG>
 
145
  result_type max() const;
146
  };
147
  ```
148
 
149
  ``` cpp
150
+ explicit geometric_distribution(double p);
151
  ```
152
 
153
+ *Preconditions:* 0 < `p` < 1.
154
 
155
+ *Remarks:* `p` corresponds to the parameter of the distribution.
 
156
 
157
  ``` cpp
158
  double p() const;
159
  ```
160
 
 
163
 
164
  ##### Class template `negative_binomial_distribution` <a id="rand.dist.bern.negbin">[[rand.dist.bern.negbin]]</a>
165
 
166
  A `negative_binomial_distribution` random number distribution produces
167
  random integers i ≥ 0 distributed according to the discrete probability
168
+ function
169
+ $$P(i\,|\,k,p) = \binom{k+i-1}{i} \cdot p^k \cdot (1-p)^i \text{ .}$$
 
 
170
 
171
  [*Note 1*: This implies that P(i | k,p) is undefined when
172
  `p == 1`. — *end note*]
173
 
174
  ``` cpp
 
178
  // types
179
  using result_type = IntType;
180
  using param_type = unspecified;
181
 
182
  // constructor and reset functions
183
+ negative_binomial_distribution() : negative_binomial_distribution(1) {}
184
+ explicit negative_binomial_distribution(IntType k, double p = 0.5);
185
  explicit negative_binomial_distribution(const param_type& parm);
186
  void reset();
187
 
188
  // generating functions
189
  template<class URBG>
 
200
  result_type max() const;
201
  };
202
  ```
203
 
204
  ``` cpp
205
+ explicit negative_binomial_distribution(IntType k, double p = 0.5);
206
  ```
207
 
208
+ *Preconditions:* 0 < `p` ≤ 1 and 0 < `k`.
209
 
210
+ *Remarks:* `k` and `p` correspond to the respective parameters of the
211
+ distribution.
212
 
213
  ``` cpp
214
  IntType k() const;
215
  ```
216