tmp/tmp8efcawjg/{from.md → to.md}
RENAMED
|
@@ -3,10 +3,11 @@
|
|
| 3 |
A `geometric_distribution` random number distribution produces integer
|
| 4 |
values i ≥ 0 distributed according to the discrete probability function
|
| 5 |
$$P(i\,|\,p) = p \cdot (1-p)^{i} \text{ .}$$
|
| 6 |
|
| 7 |
``` cpp
|
|
|
|
| 8 |
template<class IntType = int>
|
| 9 |
class geometric_distribution {
|
| 10 |
public:
|
| 11 |
// types
|
| 12 |
using result_type = IntType;
|
|
@@ -16,10 +17,13 @@ template<class IntType = int>
|
|
| 16 |
geometric_distribution() : geometric_distribution(0.5) {}
|
| 17 |
explicit geometric_distribution(double p);
|
| 18 |
explicit geometric_distribution(const param_type& parm);
|
| 19 |
void reset();
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
// generating functions
|
| 22 |
template<class URBG>
|
| 23 |
result_type operator()(URBG& g);
|
| 24 |
template<class URBG>
|
| 25 |
result_type operator()(URBG& g, const param_type& parm);
|
|
@@ -28,11 +32,20 @@ template<class IntType = int>
|
|
| 28 |
double p() const;
|
| 29 |
param_type param() const;
|
| 30 |
void param(const param_type& parm);
|
| 31 |
result_type min() const;
|
| 32 |
result_type max() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
};
|
|
|
|
| 34 |
```
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
explicit geometric_distribution(double p);
|
| 38 |
```
|
|
|
|
| 3 |
A `geometric_distribution` random number distribution produces integer
|
| 4 |
values i ≥ 0 distributed according to the discrete probability function
|
| 5 |
$$P(i\,|\,p) = p \cdot (1-p)^{i} \text{ .}$$
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
+
namespace std {
|
| 9 |
template<class IntType = int>
|
| 10 |
class geometric_distribution {
|
| 11 |
public:
|
| 12 |
// types
|
| 13 |
using result_type = IntType;
|
|
|
|
| 17 |
geometric_distribution() : geometric_distribution(0.5) {}
|
| 18 |
explicit geometric_distribution(double p);
|
| 19 |
explicit geometric_distribution(const param_type& parm);
|
| 20 |
void reset();
|
| 21 |
|
| 22 |
+
// equality operators
|
| 23 |
+
friend bool operator==(const geometric_distribution& x, const geometric_distribution& y);
|
| 24 |
+
|
| 25 |
// generating functions
|
| 26 |
template<class URBG>
|
| 27 |
result_type operator()(URBG& g);
|
| 28 |
template<class URBG>
|
| 29 |
result_type operator()(URBG& g, const param_type& parm);
|
|
|
|
| 32 |
double p() const;
|
| 33 |
param_type param() const;
|
| 34 |
void param(const param_type& parm);
|
| 35 |
result_type min() const;
|
| 36 |
result_type max() const;
|
| 37 |
+
|
| 38 |
+
// inserters and extractors
|
| 39 |
+
template<class charT, class traits>
|
| 40 |
+
friend basic_ostream<charT, traits>&
|
| 41 |
+
operator<<(basic_ostream<charT, traits>& os, const geometric_distribution& x);
|
| 42 |
+
template<class charT, class traits>
|
| 43 |
+
friend basic_istream<charT, traits>&
|
| 44 |
+
operator>>(basic_istream<charT, traits>& is, geometric_distribution& x);
|
| 45 |
};
|
| 46 |
+
}
|
| 47 |
```
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
explicit geometric_distribution(double p);
|
| 51 |
```
|