tmp/tmp0pa953r1/{from.md → to.md}
RENAMED
|
@@ -6,10 +6,11 @@ $$P(b\,|\,p) = \left\{ \begin{array}{ll}
|
|
| 6 |
p & \text{ if $b = \tcode{true}$, or} \\
|
| 7 |
1 - p & \text{ if $b = \tcode{false}$.}
|
| 8 |
\end{array}\right.$$
|
| 9 |
|
| 10 |
``` cpp
|
|
|
|
| 11 |
class bernoulli_distribution {
|
| 12 |
public:
|
| 13 |
// types
|
| 14 |
using result_type = bool;
|
| 15 |
using param_type = unspecified;
|
|
@@ -18,10 +19,13 @@ public:
|
|
| 18 |
bernoulli_distribution() : bernoulli_distribution(0.5) {}
|
| 19 |
explicit bernoulli_distribution(double p);
|
| 20 |
explicit bernoulli_distribution(const param_type& parm);
|
| 21 |
void reset();
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
// generating functions
|
| 24 |
template<class URBG>
|
| 25 |
result_type operator()(URBG& g);
|
| 26 |
template<class URBG>
|
| 27 |
result_type operator()(URBG& g, const param_type& parm);
|
|
@@ -30,11 +34,20 @@ public:
|
|
| 30 |
double p() const;
|
| 31 |
param_type param() const;
|
| 32 |
void param(const param_type& parm);
|
| 33 |
result_type min() const;
|
| 34 |
result_type max() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
};
|
|
|
|
| 36 |
```
|
| 37 |
|
| 38 |
``` cpp
|
| 39 |
explicit bernoulli_distribution(double p);
|
| 40 |
```
|
|
|
|
| 6 |
p & \text{ if $b = \tcode{true}$, or} \\
|
| 7 |
1 - p & \text{ if $b = \tcode{false}$.}
|
| 8 |
\end{array}\right.$$
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
+
namespace std {
|
| 12 |
class bernoulli_distribution {
|
| 13 |
public:
|
| 14 |
// types
|
| 15 |
using result_type = bool;
|
| 16 |
using param_type = unspecified;
|
|
|
|
| 19 |
bernoulli_distribution() : bernoulli_distribution(0.5) {}
|
| 20 |
explicit bernoulli_distribution(double p);
|
| 21 |
explicit bernoulli_distribution(const param_type& parm);
|
| 22 |
void reset();
|
| 23 |
|
| 24 |
+
// equality operators
|
| 25 |
+
friend bool operator==(const bernoulli_distribution& x, const bernoulli_distribution& y);
|
| 26 |
+
|
| 27 |
// generating functions
|
| 28 |
template<class URBG>
|
| 29 |
result_type operator()(URBG& g);
|
| 30 |
template<class URBG>
|
| 31 |
result_type operator()(URBG& g, const param_type& parm);
|
|
|
|
| 34 |
double p() const;
|
| 35 |
param_type param() const;
|
| 36 |
void param(const param_type& parm);
|
| 37 |
result_type min() const;
|
| 38 |
result_type max() const;
|
| 39 |
+
|
| 40 |
+
// inserters and extractors
|
| 41 |
+
template<class charT, class traits>
|
| 42 |
+
friend basic_ostream<charT, traits>&
|
| 43 |
+
operator<<(basic_ostream<charT, traits>& os, const bernoulli_distribution& x);
|
| 44 |
+
template<class charT, class traits>
|
| 45 |
+
friend basic_istream<charT, traits>&
|
| 46 |
+
operator>>(basic_istream<charT, traits>& is, bernoulli_distribution& x);
|
| 47 |
};
|
| 48 |
+
}
|
| 49 |
```
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
explicit bernoulli_distribution(double p);
|
| 53 |
```
|