This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

231
cppdraft/rand/dist/bern.md vendored Normal file
View File

@@ -0,0 +1,231 @@
[rand.dist.bern]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.bern)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#bern)
#### 29.5.9.3 Bernoulli distributions [rand.dist.bern]
#### [29.5.9.3.1](#bernoulli) Class bernoulli_distribution [[rand.dist.bern.bernoulli]](rand.dist.bern.bernoulli)
[1](#bernoulli-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4758)
A bernoulli_distribution random number distribution
produces bool values b distributed according to
the discrete probability function in Formula [29.4](#eq:rand.dist.bern.bernoulli)[.](#bernoulli-1.sentence-1)
P(b|p)={p if b=true1−p if b=false(29.4)
[🔗](#lib:bernoulli_distribution_)
namespace std {class bernoulli_distribution {public:// typesusing result_type = bool; using param_type = *unspecified*; // constructors and reset functions bernoulli_distribution() : bernoulli_distribution(0.5) {}explicit bernoulli_distribution(double p); explicit bernoulli_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const bernoulli_distribution& x, const bernoulli_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const bernoulli_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, bernoulli_distribution& x); };}
[🔗](#lib:bernoulli_distribution,constructor)
`explicit bernoulli_distribution(double p);
`
[2](#bernoulli-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4820)
*Preconditions*: 0 ≤ p ≤ 1[.](#bernoulli-2.sentence-1)
[3](#bernoulli-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4824)
*Remarks*: p corresponds to the parameter of the distribution[.](#bernoulli-3.sentence-1)
[🔗](#lib:p,bernoulli_distribution)
`double p() const;
`
[4](#bernoulli-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4836)
*Returns*: The value of the p parameter
with which the object was constructed[.](#bernoulli-4.sentence-1)
#### [29.5.9.3.2](#bin) Class template binomial_distribution [[rand.dist.bern.bin]](rand.dist.bern.bin)
[1](#bin-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4848)
A binomial_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.5](#eq:rand.dist.bern.bin)[.](#bin-1.sentence-1)
P(i|t,p)=(ti)â‹piâ‹(1−p)t−i(29.5)
[🔗](#lib:binomial_distribution_)
namespace std {template<class IntType = int>class binomial_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions binomial_distribution() : binomial_distribution(1) {}explicit binomial_distribution(IntType t, double p = 0.5); explicit binomial_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const binomial_distribution& x, const binomial_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions IntType t() const; double p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const binomial_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, binomial_distribution& x); };}
[🔗](#lib:binomial_distribution,constructor)
`explicit binomial_distribution(IntType t, double p = 0.5);
`
[2](#bin-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4910)
*Preconditions*: 0 ≤ p ≤ 1 and 0 ≤ t[.](#bin-2.sentence-1)
[3](#bin-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4914)
*Remarks*: t and p correspond to the respective parameters of the distribution[.](#bin-3.sentence-1)
[🔗](#lib:t,binomial_distribution)
`IntType t() const;
`
[4](#bin-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4925)
*Returns*: The value of the t parameter
with which the object was constructed[.](#bin-4.sentence-1)
[🔗](#lib:p,binomial_distribution)
`double p() const;
`
[5](#bin-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4937)
*Returns*: The value of the p parameter
with which the object was constructed[.](#bin-5.sentence-1)
#### [29.5.9.3.3](#geo) Class template geometric_distribution [[rand.dist.bern.geo]](rand.dist.bern.geo)
[1](#geo-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4949)
A geometric_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.6](#eq:rand.dist.bern.geo)[.](#geo-1.sentence-1)
P(i|p)=pâ‹(1−p)i(29.6)
[🔗](#lib:geometric_distribution_)
namespace std {template<class IntType = int>class geometric_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions geometric_distribution() : geometric_distribution(0.5) {}explicit geometric_distribution(double p); explicit geometric_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const geometric_distribution& x, const geometric_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const geometric_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, geometric_distribution& x); };}
[🔗](#lib:geometric_distribution,constructor)
`explicit geometric_distribution(double p);
`
[2](#geo-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5009)
*Preconditions*: 0<p<1[.](#geo-2.sentence-1)
[3](#geo-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5013)
*Remarks*: p corresponds to the parameter of the distribution[.](#geo-3.sentence-1)
[🔗](#lib:p,geometric_distribution)
`double p() const;
`
[4](#geo-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5025)
*Returns*: The value of the p parameter
with which the object was constructed[.](#geo-4.sentence-1)
#### [29.5.9.3.4](#negbin) Class template negative_binomial_distribution [[rand.dist.bern.negbin]](rand.dist.bern.negbin)
[1](#negbin-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5038)
A negative_binomial_distribution random number distribution
produces random integers i ≥ 0 distributed according to
the discrete probability function in Formula [29.7](#eq:rand.dist.bern.negbin)[.](#negbin-1.sentence-1)
P(i|k,p)=(k+ˆ’1i)â‹pkâ‹(ˆ’p)i(29.7)
[*Note [1](#negbin-note-1)*:
This implies that P(i | k,p) is undefined when p == 1[.](#negbin-1.sentence-2)
— *end note*]
[🔗](#lib:negative_binomial_distribution_)
namespace std {template<class IntType = int>class negative_binomial_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructor and reset functions negative_binomial_distribution() : negative_binomial_distribution(1) {}explicit negative_binomial_distribution(IntType k, double p = 0.5); explicit negative_binomial_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const negative_binomial_distribution& x, const negative_binomial_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions IntType k() const; double p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const negative_binomial_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, negative_binomial_distribution& x); };}
[🔗](#lib:negative_binomial_distribution,constructor)
`explicit negative_binomial_distribution(IntType k, double p = 0.5);
`
[2](#negbin-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5103)
*Preconditions*: 0<‰¤1 and 0<k[.](#negbin-2.sentence-1)
[3](#negbin-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5108)
*Remarks*: k and p correspond to the respective parameters of the distribution[.](#negbin-3.sentence-1)
[🔗](#lib:k,negative_binomial_distribution)
`IntType k() const;
`
[4](#negbin-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5120)
*Returns*: The value of the k parameter
with which the object was constructed[.](#negbin-4.sentence-1)
[🔗](#lib:p,negative_binomial_distribution)
`double p() const;
`
[5](#negbin-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5132)
*Returns*: The value of the p parameter
with which the object was constructed[.](#negbin-5.sentence-1)

57
cppdraft/rand/dist/bern/bernoulli.md vendored Normal file
View File

@@ -0,0 +1,57 @@
[rand.dist.bern.bernoulli]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.bern.bernoulli)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#bern.bernoulli)
#### 29.5.9.3 Bernoulli distributions [[rand.dist.bern]](rand.dist.bern#bernoulli)
#### 29.5.9.3.1 Class bernoulli_distribution [rand.dist.bern.bernoulli]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4758)
A bernoulli_distribution random number distribution
produces bool values b distributed according to
the discrete probability function in Formula [29.4](#eq:rand.dist.bern.bernoulli)[.](#1.sentence-1)
P(b|p)={p if b=true1−p if b=false(29.4)
[🔗](#lib:bernoulli_distribution_)
namespace std {class bernoulli_distribution {public:// typesusing result_type = bool; using param_type = *unspecified*; // constructors and reset functions bernoulli_distribution() : bernoulli_distribution(0.5) {}explicit bernoulli_distribution(double p); explicit bernoulli_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const bernoulli_distribution& x, const bernoulli_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const bernoulli_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, bernoulli_distribution& x); };}
[🔗](#lib:bernoulli_distribution,constructor)
`explicit bernoulli_distribution(double p);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4820)
*Preconditions*: 0 ≤ p ≤ 1[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4824)
*Remarks*: p corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:p,bernoulli_distribution)
`double p() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4836)
*Returns*: The value of the p parameter
with which the object was constructed[.](#4.sentence-1)

69
cppdraft/rand/dist/bern/bin.md vendored Normal file
View File

@@ -0,0 +1,69 @@
[rand.dist.bern.bin]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.bern.bin)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#bern.bin)
#### 29.5.9.3 Bernoulli distributions [[rand.dist.bern]](rand.dist.bern#bin)
#### 29.5.9.3.2 Class template binomial_distribution [rand.dist.bern.bin]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4848)
A binomial_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.5](#eq:rand.dist.bern.bin)[.](#1.sentence-1)
P(i|t,p)=(ti)â‹piâ‹(1−p)t−i(29.5)
[🔗](#lib:binomial_distribution_)
namespace std {template<class IntType = int>class binomial_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions binomial_distribution() : binomial_distribution(1) {}explicit binomial_distribution(IntType t, double p = 0.5); explicit binomial_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const binomial_distribution& x, const binomial_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions IntType t() const; double p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const binomial_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, binomial_distribution& x); };}
[🔗](#lib:binomial_distribution,constructor)
`explicit binomial_distribution(IntType t, double p = 0.5);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4910)
*Preconditions*: 0 ≤ p ≤ 1 and 0 ≤ t[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4914)
*Remarks*: t and p correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:t,binomial_distribution)
`IntType t() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4925)
*Returns*: The value of the t parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:p,binomial_distribution)
`double p() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4937)
*Returns*: The value of the p parameter
with which the object was constructed[.](#5.sentence-1)

57
cppdraft/rand/dist/bern/geo.md vendored Normal file
View File

@@ -0,0 +1,57 @@
[rand.dist.bern.geo]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.bern.geo)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#bern.geo)
#### 29.5.9.3 Bernoulli distributions [[rand.dist.bern]](rand.dist.bern#geo)
#### 29.5.9.3.3 Class template geometric_distribution [rand.dist.bern.geo]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4949)
A geometric_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.6](#eq:rand.dist.bern.geo)[.](#1.sentence-1)
P(i|p)=pâ‹(1−p)i(29.6)
[🔗](#lib:geometric_distribution_)
namespace std {template<class IntType = int>class geometric_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions geometric_distribution() : geometric_distribution(0.5) {}explicit geometric_distribution(double p); explicit geometric_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const geometric_distribution& x, const geometric_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const geometric_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, geometric_distribution& x); };}
[🔗](#lib:geometric_distribution,constructor)
`explicit geometric_distribution(double p);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5009)
*Preconditions*: 0<p<1[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5013)
*Remarks*: p corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:p,geometric_distribution)
`double p() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5025)
*Returns*: The value of the p parameter
with which the object was constructed[.](#4.sentence-1)

75
cppdraft/rand/dist/bern/negbin.md vendored Normal file
View File

@@ -0,0 +1,75 @@
[rand.dist.bern.negbin]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.bern.negbin)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#bern.negbin)
#### 29.5.9.3 Bernoulli distributions [[rand.dist.bern]](rand.dist.bern#negbin)
#### 29.5.9.3.4 Class template negative_binomial_distribution [rand.dist.bern.negbin]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5038)
A negative_binomial_distribution random number distribution
produces random integers i ≥ 0 distributed according to
the discrete probability function in Formula [29.7](#eq:rand.dist.bern.negbin)[.](#1.sentence-1)
P(i|k,p)=(k+i−1i)â‹pkâ‹(1−p)i(29.7)
[*Note [1](#note-1)*:
This implies that P(i | k,p) is undefined when p == 1[.](#1.sentence-2)
— *end note*]
[🔗](#lib:negative_binomial_distribution_)
namespace std {template<class IntType = int>class negative_binomial_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructor and reset functions negative_binomial_distribution() : negative_binomial_distribution(1) {}explicit negative_binomial_distribution(IntType k, double p = 0.5); explicit negative_binomial_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const negative_binomial_distribution& x, const negative_binomial_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions IntType k() const; double p() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const negative_binomial_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, negative_binomial_distribution& x); };}
[🔗](#lib:negative_binomial_distribution,constructor)
`explicit negative_binomial_distribution(IntType k, double p = 0.5);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5103)
*Preconditions*: 0<‰¤1 and 0<k[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5108)
*Remarks*: k and p correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:k,negative_binomial_distribution)
`IntType k() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5120)
*Returns*: The value of the k parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:p,negative_binomial_distribution)
`double p() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5132)
*Returns*: The value of the p parameter
with which the object was constructed[.](#5.sentence-1)

45
cppdraft/rand/dist/general.md vendored Normal file
View File

@@ -0,0 +1,45 @@
[rand.dist.general]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.general)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#general)
#### 29.5.9.1 General [rand.dist.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4486)
Each type instantiated
from a class template specified in [[rand.dist]](rand.dist "29.5.9Random number distribution class templates") meets the requirements
of a [random number distribution](rand.req.dist "29.5.3.6Random number distribution requirements[rand.req.dist]") type[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4492)
Descriptions are provided in [[rand.dist]](rand.dist "29.5.9Random number distribution class templates") only for distribution operations
that are not described in [[rand.req.dist]](rand.req.dist "29.5.3.6Random number distribution requirements") or for operations where there is additional semantic information[.](#2.sentence-1)
In particular,
declarations for copy constructors,
for copy assignment operators,
for streaming operators,
and for equality and inequality operators
are not shown in the synopses[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4504)
The algorithms for producing each
of the specified distributions areimplementation-defined[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4509)
The value of each probability density function p(z) and of each discrete probability function P(zi) specified in this subclause
is 0 everywhere outside its stated domain[.](#4.sentence-1)

351
cppdraft/rand/dist/norm.md vendored Normal file
View File

@@ -0,0 +1,351 @@
[rand.dist.norm]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm)
#### 29.5.9.5 Normal distributions [rand.dist.norm]
#### [29.5.9.5.1](#normal) Class template normal_distribution [[rand.dist.norm.normal]](rand.dist.norm.normal)
[1](#normal-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5663)
A normal_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.13](#eq:rand.dist.norm.normal)[.](#normal-1.sentence-1)
p(x|μ,σ)=1σ√€â‹exp(−(x−μ)22σ2)(29.13)
The distribution parameters μ and σ are also known as this distribution's [*mean*](#def:mean) and [*standard deviation*](#def:standard_deviation)[.](#normal-1.sentence-2)
[🔗](#lib:normal_distribution_)
namespace std {template<class RealType = double>class normal_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions normal_distribution() : normal_distribution(0.0) {}explicit normal_distribution(RealType mean, RealType stddev = 1.0); explicit normal_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const normal_distribution& x, const normal_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType mean() const;
RealType stddev() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const normal_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, normal_distribution& x); };}
[🔗](#lib:normal_distribution,constructor)
`explicit normal_distribution(RealType mean, RealType stddev = 1.0);
`
[2](#normal-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5733)
*Preconditions*: 0<stddev[.](#normal-2.sentence-1)
[3](#normal-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5737)
*Remarks*: mean and stddev correspond to the respective parameters of the distribution[.](#normal-3.sentence-1)
[🔗](#lib:mean,normal_distribution)
`RealType mean() const;
`
[4](#normal-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5749)
*Returns*: The value of the mean parameter
with which the object was constructed[.](#normal-4.sentence-1)
[🔗](#lib:stddev,normal_distribution)
`RealType stddev() const;
`
[5](#normal-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5761)
*Returns*: The value of the stddev parameter
with which the object was constructed[.](#normal-5.sentence-1)
#### [29.5.9.5.2](#lognormal) Class template lognormal_distribution [[rand.dist.norm.lognormal]](rand.dist.norm.lognormal)
[1](#lognormal-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5774)
A lognormal_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.14](#eq:rand.dist.norm.lognormal)[.](#lognormal-1.sentence-1)
p(x|m,s)=1sx√€â‹exp(−(lnx−m)22s2)(29.14)
[🔗](#lib:lognormal_distribution_)
namespace std {template<class RealType = double>class lognormal_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions lognormal_distribution() : lognormal_distribution(0.0) {}explicit lognormal_distribution(RealType m, RealType s = 1.0); explicit lognormal_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const lognormal_distribution& x, const lognormal_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType m() const;
RealType s() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const lognormal_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, lognormal_distribution& x); };}
[🔗](#lib:lognormal_distribution,constructor)
`explicit lognormal_distribution(RealType m, RealType s = 1.0);
`
[2](#lognormal-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5836)
*Preconditions*: 0<s[.](#lognormal-2.sentence-1)
[3](#lognormal-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5840)
*Remarks*: m and s correspond to the respective parameters of the distribution[.](#lognormal-3.sentence-1)
[🔗](#lib:m,lognormal_distribution)
`RealType m() const;
`
[4](#lognormal-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5852)
*Returns*: The value of the m parameter
with which the object was constructed[.](#lognormal-4.sentence-1)
[🔗](#lib:s,lognormal_distribution)
`RealType s() const;
`
[5](#lognormal-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5864)
*Returns*: The value of the s parameter
with which the object was constructed[.](#lognormal-5.sentence-1)
#### [29.5.9.5.3](#chisq) Class template chi_squared_distribution [[rand.dist.norm.chisq]](rand.dist.norm.chisq)
[1](#chisq-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5877)
A chi_squared_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.15](#eq:rand.dist.norm.chisq)[.](#chisq-1.sentence-1)
p(x|n)=x(n/2)−‹ˆ’x/2Γ(n/2)â‹2n/2(29.15)
[🔗](#lib:chi_squared_distribution_)
namespace std {template<class RealType = double>class chi_squared_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions chi_squared_distribution() : chi_squared_distribution(1.0) {}explicit chi_squared_distribution(RealType n); explicit chi_squared_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const chi_squared_distribution& x, const chi_squared_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const chi_squared_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, chi_squared_distribution& x); };}
[🔗](#lib:chi_squared_distribution,constructor)
`explicit chi_squared_distribution(RealType n);
`
[2](#chisq-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5936)
*Preconditions*: 0<n[.](#chisq-2.sentence-1)
[3](#chisq-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5940)
*Remarks*: n corresponds to the parameter of the distribution[.](#chisq-3.sentence-1)
[🔗](#lib:n,chi_squared_distribution)
`RealType n() const;
`
[4](#chisq-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5951)
*Returns*: The value of the n parameter
with which the object was constructed[.](#chisq-4.sentence-1)
#### [29.5.9.5.4](#cauchy) Class template cauchy_distribution [[rand.dist.norm.cauchy]](rand.dist.norm.cauchy)
[1](#cauchy-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5964)
A cauchy_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.16](#eq:rand.dist.norm.cauchy)[.](#cauchy-1.sentence-1)
p(x|a,b)=(πb(1+(ˆ’ab)2))−1(29.16)
[🔗](#lib:cauchy_distribution_)
namespace std {template<class RealType = double>class cauchy_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions cauchy_distribution() : cauchy_distribution(0.0) {}explicit cauchy_distribution(RealType a, RealType b = 1.0); explicit cauchy_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const cauchy_distribution& x, const cauchy_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const cauchy_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, cauchy_distribution& x); };}
[🔗](#lib:cauchy_distribution,constructor)
`explicit cauchy_distribution(RealType a, RealType b = 1.0);
`
[2](#cauchy-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6025)
*Preconditions*: 0<b[.](#cauchy-2.sentence-1)
[3](#cauchy-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6029)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#cauchy-3.sentence-1)
[🔗](#lib:a,cauchy_distribution)
`RealType a() const;
`
[4](#cauchy-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6041)
*Returns*: The value of the a parameter
with which the object was constructed[.](#cauchy-4.sentence-1)
[🔗](#lib:b,cauchy_distribution)
`RealType b() const;
`
[5](#cauchy-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6053)
*Returns*: The value of the b parameter
with which the object was constructed[.](#cauchy-5.sentence-1)
#### [29.5.9.5.5](#f) Class template fisher_f_distribution [[rand.dist.norm.f]](rand.dist.norm.f)
[1](#f-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6066)
A fisher_f_distribution random number distribution
produces random numbers x ≥ 0 distributed according to
the probability density function in Formula [29.17](#eq:rand.dist.norm.f)[.](#f-1.sentence-1)
p(x|m,n)=Γ((m+n)/2)Γ(m/2)Γ(n/2)â‹(mn)m/‹x(m/2)−‹(1+mxn)−(m+n)/2(29.17)
[🔗](#lib:fisher_f_distribution_)
namespace std {template<class RealType = double>class fisher_f_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions fisher_f_distribution() : fisher_f_distribution(1.0) {}explicit fisher_f_distribution(RealType m, RealType n = 1.0); explicit fisher_f_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const fisher_f_distribution& x, const fisher_f_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType m() const;
RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const fisher_f_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, fisher_f_distribution& x); };}
[🔗](#lib:fisher_f_distribution,constructor)
`explicit fisher_f_distribution(RealType m, RealType n = 1);
`
[2](#f-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6129)
*Preconditions*: 0<m and 0<n[.](#f-2.sentence-1)
[3](#f-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6133)
*Remarks*: m and n correspond to the respective parameters of the distribution[.](#f-3.sentence-1)
[🔗](#lib:m,fisher_f_distribution)
`RealType m() const;
`
[4](#f-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6145)
*Returns*: The value of the m parameter
with which the object was constructed[.](#f-4.sentence-1)
[🔗](#lib:n,fisher_f_distribution)
`RealType n() const;
`
[5](#f-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6157)
*Returns*: The value of the n parameter
with which the object was constructed[.](#f-5.sentence-1)
#### [29.5.9.5.6](#t) Class template student_t_distribution [[rand.dist.norm.t]](rand.dist.norm.t)
[1](#t-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6170)
A student_t_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.18](#eq:rand.dist.norm.t)[.](#t-1.sentence-1)
p(x|n)=ˆš€â‹Î“((n+1)/2)Γ(n/2)â‹(1+x2n)−(n+1)/2(29.18)
[🔗](#lib:student_t_distribution_)
namespace std {template<class RealType = double>class student_t_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions student_t_distribution() : student_t_distribution(1.0) {}explicit student_t_distribution(RealType n); explicit student_t_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const student_t_distribution& x, const student_t_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const student_t_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, student_t_distribution& x); };}
[🔗](#lib:student_t_distribution,constructor)
`explicit student_t_distribution(RealType n);
`
[2](#t-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6231)
*Preconditions*: 0<n[.](#t-2.sentence-1)
[3](#t-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6235)
*Remarks*: n corresponds to the parameter of the distribution[.](#t-3.sentence-1)
[🔗](#lib:mean,student_t_distribution)
`RealType n() const;
`
[4](#t-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6246)
*Returns*: The value of the n parameter
with which the object was constructed[.](#t-4.sentence-1)

70
cppdraft/rand/dist/norm/cauchy.md vendored Normal file
View File

@@ -0,0 +1,70 @@
[rand.dist.norm.cauchy]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.cauchy)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.cauchy)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#cauchy)
#### 29.5.9.5.4 Class template cauchy_distribution [rand.dist.norm.cauchy]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5964)
A cauchy_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.16](#eq:rand.dist.norm.cauchy)[.](#1.sentence-1)
p(x|a,b)=(πb(1+(x−ab)2))−1(29.16)
[🔗](#lib:cauchy_distribution_)
namespace std {template<class RealType = double>class cauchy_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions cauchy_distribution() : cauchy_distribution(0.0) {}explicit cauchy_distribution(RealType a, RealType b = 1.0); explicit cauchy_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const cauchy_distribution& x, const cauchy_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const cauchy_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, cauchy_distribution& x); };}
[🔗](#lib:cauchy_distribution,constructor)
`explicit cauchy_distribution(RealType a, RealType b = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6025)
*Preconditions*: 0<b[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6029)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:a,cauchy_distribution)
`RealType a() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6041)
*Returns*: The value of the a parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:b,cauchy_distribution)
`RealType b() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6053)
*Returns*: The value of the b parameter
with which the object was constructed[.](#5.sentence-1)

57
cppdraft/rand/dist/norm/chisq.md vendored Normal file
View File

@@ -0,0 +1,57 @@
[rand.dist.norm.chisq]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.chisq)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.chisq)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#chisq)
#### 29.5.9.5.3 Class template chi_squared_distribution [rand.dist.norm.chisq]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5877)
A chi_squared_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.15](#eq:rand.dist.norm.chisq)[.](#1.sentence-1)
p(x|n)=x(n/2)−‹ˆ’x/2Γ(n/2)â‹2n/2(29.15)
[🔗](#lib:chi_squared_distribution_)
namespace std {template<class RealType = double>class chi_squared_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions chi_squared_distribution() : chi_squared_distribution(1.0) {}explicit chi_squared_distribution(RealType n); explicit chi_squared_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const chi_squared_distribution& x, const chi_squared_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const chi_squared_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, chi_squared_distribution& x); };}
[🔗](#lib:chi_squared_distribution,constructor)
`explicit chi_squared_distribution(RealType n);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5936)
*Preconditions*: 0<n[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5940)
*Remarks*: n corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:n,chi_squared_distribution)
`RealType n() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5951)
*Returns*: The value of the n parameter
with which the object was constructed[.](#4.sentence-1)

70
cppdraft/rand/dist/norm/f.md vendored Normal file
View File

@@ -0,0 +1,70 @@
[rand.dist.norm.f]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.f)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.f)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#f)
#### 29.5.9.5.5 Class template fisher_f_distribution [rand.dist.norm.f]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6066)
A fisher_f_distribution random number distribution
produces random numbers x ≥ 0 distributed according to
the probability density function in Formula [29.17](#eq:rand.dist.norm.f)[.](#1.sentence-1)
p(x|m,n)=Γ((m+n)/2)Γ(m/2)Γ(n/2)â‹(mn)m/2â‹x(m/2)−‹(1+mxn)−(m+n)/2(29.17)
[🔗](#lib:fisher_f_distribution_)
namespace std {template<class RealType = double>class fisher_f_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions fisher_f_distribution() : fisher_f_distribution(1.0) {}explicit fisher_f_distribution(RealType m, RealType n = 1.0); explicit fisher_f_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const fisher_f_distribution& x, const fisher_f_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType m() const;
RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const fisher_f_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, fisher_f_distribution& x); };}
[🔗](#lib:fisher_f_distribution,constructor)
`explicit fisher_f_distribution(RealType m, RealType n = 1);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6129)
*Preconditions*: 0<m and 0<n[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6133)
*Remarks*: m and n correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:m,fisher_f_distribution)
`RealType m() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6145)
*Returns*: The value of the m parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:n,fisher_f_distribution)
`RealType n() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6157)
*Returns*: The value of the n parameter
with which the object was constructed[.](#5.sentence-1)

70
cppdraft/rand/dist/norm/lognormal.md vendored Normal file
View File

@@ -0,0 +1,70 @@
[rand.dist.norm.lognormal]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.lognormal)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.lognormal)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#lognormal)
#### 29.5.9.5.2 Class template lognormal_distribution [rand.dist.norm.lognormal]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5774)
A lognormal_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.14](#eq:rand.dist.norm.lognormal)[.](#1.sentence-1)
p(x|m,s)=1sx√€â‹exp(−(lnx−m)22s2)(29.14)
[🔗](#lib:lognormal_distribution_)
namespace std {template<class RealType = double>class lognormal_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions lognormal_distribution() : lognormal_distribution(0.0) {}explicit lognormal_distribution(RealType m, RealType s = 1.0); explicit lognormal_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const lognormal_distribution& x, const lognormal_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType m() const;
RealType s() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const lognormal_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, lognormal_distribution& x); };}
[🔗](#lib:lognormal_distribution,constructor)
`explicit lognormal_distribution(RealType m, RealType s = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5836)
*Preconditions*: 0<s[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5840)
*Remarks*: m and s correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:m,lognormal_distribution)
`RealType m() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5852)
*Returns*: The value of the m parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:s,lognormal_distribution)
`RealType s() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5864)
*Returns*: The value of the s parameter
with which the object was constructed[.](#5.sentence-1)

72
cppdraft/rand/dist/norm/normal.md vendored Normal file
View File

@@ -0,0 +1,72 @@
[rand.dist.norm.normal]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.normal)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.normal)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#normal)
#### 29.5.9.5.1 Class template normal_distribution [rand.dist.norm.normal]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5663)
A normal_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.13](#eq:rand.dist.norm.normal)[.](#1.sentence-1)
p(x|μ,σ)=1σ√€â‹exp(−(x−μ)22σ2)(29.13)
The distribution parameters μ and σ are also known as this distribution's [*mean*](#def:mean) and [*standard deviation*](#def:standard_deviation)[.](#1.sentence-2)
[🔗](#lib:normal_distribution_)
namespace std {template<class RealType = double>class normal_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions normal_distribution() : normal_distribution(0.0) {}explicit normal_distribution(RealType mean, RealType stddev = 1.0); explicit normal_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const normal_distribution& x, const normal_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType mean() const;
RealType stddev() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const normal_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, normal_distribution& x); };}
[🔗](#lib:normal_distribution,constructor)
`explicit normal_distribution(RealType mean, RealType stddev = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5733)
*Preconditions*: 0<stddev[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5737)
*Remarks*: mean and stddev correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:mean,normal_distribution)
`RealType mean() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5749)
*Returns*: The value of the mean parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:stddev,normal_distribution)
`RealType stddev() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5761)
*Returns*: The value of the stddev parameter
with which the object was constructed[.](#5.sentence-1)

57
cppdraft/rand/dist/norm/t.md vendored Normal file
View File

@@ -0,0 +1,57 @@
[rand.dist.norm.t]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.norm.t)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm.t)
#### 29.5.9.5 Normal distributions [[rand.dist.norm]](rand.dist.norm#t)
#### 29.5.9.5.6 Class template student_t_distribution [rand.dist.norm.t]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6170)
A student_t_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.18](#eq:rand.dist.norm.t)[.](#1.sentence-1)
p(x|n)=1√€â‹Î“((n+1)/2)Γ(n/2)â‹(1+x2n)−(n+1)/2(29.18)
[🔗](#lib:student_t_distribution_)
namespace std {template<class RealType = double>class student_t_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions student_t_distribution() : student_t_distribution(1.0) {}explicit student_t_distribution(RealType n); explicit student_t_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const student_t_distribution& x, const student_t_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType n() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const student_t_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, student_t_distribution& x); };}
[🔗](#lib:student_t_distribution,constructor)
`explicit student_t_distribution(RealType n);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6231)
*Preconditions*: 0<n[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6235)
*Remarks*: n corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:mean,student_t_distribution)
`RealType n() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6246)
*Returns*: The value of the n parameter
with which the object was constructed[.](#4.sentence-1)

301
cppdraft/rand/dist/pois.md vendored Normal file
View File

@@ -0,0 +1,301 @@
[rand.dist.pois]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois)
#### 29.5.9.4 Poisson distributions [rand.dist.pois]
#### [29.5.9.4.1](#poisson) Class template poisson_distribution [[rand.dist.pois.poisson]](rand.dist.pois.poisson)
[1](#poisson-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5157)
A poisson_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.8](#eq:rand.dist.pois.poisson)[.](#poisson-1.sentence-1)
P(i|μ)=e−μμii!(29.8)
The distribution parameter μ is also known as this distribution's [*mean*](#def:mean)[.](#poisson-1.sentence-2)
[🔗](#lib:poisson_distribution_)
namespace std {template<class IntType = int>class poisson_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions poisson_distribution() : poisson_distribution(1.0) {}explicit poisson_distribution(double mean); explicit poisson_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const poisson_distribution& x, const poisson_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble mean() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const poisson_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, poisson_distribution& x); };}
[🔗](#lib:poisson_distribution,constructor)
`explicit poisson_distribution(double mean);
`
[2](#poisson-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5218)
*Preconditions*: 0<mean[.](#poisson-2.sentence-1)
[3](#poisson-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5222)
*Remarks*: mean corresponds to the parameter of the distribution[.](#poisson-3.sentence-1)
[🔗](#lib:mean,poisson_distribution)
`double mean() const;
`
[4](#poisson-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5233)
*Returns*: The value of the mean parameter
with which the object was constructed[.](#poisson-4.sentence-1)
#### [29.5.9.4.2](#exp) Class template exponential_distribution [[rand.dist.pois.exp]](rand.dist.pois.exp)
[1](#exp-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5245)
An exponential_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.9](#eq:rand.dist.pois.exp)[.](#exp-1.sentence-1)
p(x|λ)=λe−λx(29.9)
[🔗](#lib:exponential_distribution_)
namespace std {template<class RealType = double>class exponential_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions exponential_distribution() : exponential_distribution(1.0) {}explicit exponential_distribution(RealType lambda); explicit exponential_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const exponential_distribution& x, const exponential_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType lambda() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const exponential_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, exponential_distribution& x); };}
[🔗](#lib:exponential_distribution,constructor)
`explicit exponential_distribution(RealType lambda);
`
[2](#exp-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5305)
*Preconditions*: 0<lambda[.](#exp-2.sentence-1)
[3](#exp-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5309)
*Remarks*: lambda corresponds to the parameter of the distribution[.](#exp-3.sentence-1)
[🔗](#lib:lambda,exponential_distribution)
`RealType lambda() const;
`
[4](#exp-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5320)
*Returns*: The value of the lambda parameter
with which the object was constructed[.](#exp-4.sentence-1)
#### [29.5.9.4.3](#gamma) Class template gamma_distribution [[rand.dist.pois.gamma]](rand.dist.pois.gamma)
[1](#gamma-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5332)
A gamma_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.10](#eq:rand.dist.pois.gamma)[.](#gamma-1.sentence-1)
p(x|α,β)=e−x/ββαâ‹Î“(α)â‹xα−1(29.10)
[🔗](#lib:gamma_distribution_)
namespace std {template<class RealType = double>class gamma_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions gamma_distribution() : gamma_distribution(1.0) {}explicit gamma_distribution(RealType alpha, RealType beta = 1.0); explicit gamma_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const gamma_distribution& x, const gamma_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType alpha() const;
RealType beta() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const gamma_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, gamma_distribution& x); };}
[🔗](#lib:gamma_distribution,constructor)
`explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
`
[2](#gamma-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5394)
*Preconditions*: 0<alpha and 0<beta[.](#gamma-2.sentence-1)
[3](#gamma-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5398)
*Remarks*: alpha and beta correspond to the parameters of the distribution[.](#gamma-3.sentence-1)
[🔗](#lib:alpha,gamma_distribution)
`RealType alpha() const;
`
[4](#gamma-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5410)
*Returns*: The value of the alpha parameter
with which the object was constructed[.](#gamma-4.sentence-1)
[🔗](#lib:beta,gamma_distribution)
`RealType beta() const;
`
[5](#gamma-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5422)
*Returns*: The value of the beta parameter
with which the object was constructed[.](#gamma-5.sentence-1)
#### [29.5.9.4.4](#weibull) Class template weibull_distribution [[rand.dist.pois.weibull]](rand.dist.pois.weibull)
[1](#weibull-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5435)
A weibull_distribution random number distribution
produces random numbers x ≥ 0 distributed according to
the probability density function in Formula [29.11](#eq:rand.dist.pois.weibull)[.](#weibull-1.sentence-1)
p(x|a,b)=abâ‹(xb)ˆ’‹exp(−(xb)a)(29.11)
[🔗](#lib:weibull_distribution_)
namespace std {template<class RealType = double>class weibull_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions weibull_distribution() : weibull_distribution(1.0) {}explicit weibull_distribution(RealType a, RealType b = 1.0); explicit weibull_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const weibull_distribution& x, const weibull_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const weibull_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, weibull_distribution& x); };}
[🔗](#lib:weibull_distribution,constructor)
`explicit weibull_distribution(RealType a, RealType b = 1.0);
`
[2](#weibull-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5497)
*Preconditions*: 0<a and 0<b[.](#weibull-2.sentence-1)
[3](#weibull-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5501)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#weibull-3.sentence-1)
[🔗](#lib:a,weibull_distribution)
`RealType a() const;
`
[4](#weibull-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5513)
*Returns*: The value of the a parameter
with which the object was constructed[.](#weibull-4.sentence-1)
[🔗](#lib:b,weibull_distribution)
`RealType b() const;
`
[5](#weibull-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5525)
*Returns*: The value of the b parameter
with which the object was constructed[.](#weibull-5.sentence-1)
#### [29.5.9.4.5](#extreme) Class template extreme_value_distribution [[rand.dist.pois.extreme]](rand.dist.pois.extreme)
[1](#extreme-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5538)
An extreme_value_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.12](#eq:rand.dist.pois.extreme)[.](#extreme-1.sentence-1)[246](#footnote-246 "The distribution corresponding to this probability density function is also known (with a possible change of variable) as the Gumbel Type I, the log-Weibull, or the Fisher-Tippett Type I distribution.")
p(x|a,b)=1bâ‹exp(ˆ’xb−exp(ˆ’xb))(29.12)
[🔗](#lib:extreme_value_distribution_)
namespace std {template<class RealType = double>class extreme_value_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions extreme_value_distribution() : extreme_value_distribution(0.0) {}explicit extreme_value_distribution(RealType a, RealType b = 1.0); explicit extreme_value_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const extreme_value_distribution& x, const extreme_value_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const extreme_value_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, extreme_value_distribution& x); };}
[🔗](#lib:extreme_value_distribution,constructor)
`explicit extreme_value_distribution(RealType a, RealType b = 1.0);
`
[2](#extreme-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5610)
*Preconditions*: 0<b[.](#extreme-2.sentence-1)
[3](#extreme-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5614)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#extreme-3.sentence-1)
[🔗](#lib:a,extreme_value_distribution)
`RealType a() const;
`
[4](#extreme-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5626)
*Returns*: The value of the a parameter
with which the object was constructed[.](#extreme-4.sentence-1)
[🔗](#lib:b,extreme_value_distribution)
`RealType b() const;
`
[5](#extreme-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5638)
*Returns*: The value of the b parameter
with which the object was constructed[.](#extreme-5.sentence-1)
[246)](#footnote-246)[246)](#footnoteref-246)
The distribution corresponding to
this probability density function
is also known
(with a possible change of variable)
as the Gumbel Type I,
the log-Weibull,
or the Fisher-Tippett Type I
distribution[.](#footnote-246.sentence-1)

57
cppdraft/rand/dist/pois/exp.md vendored Normal file
View File

@@ -0,0 +1,57 @@
[rand.dist.pois.exp]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois.exp)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois.exp)
#### 29.5.9.4 Poisson distributions [[rand.dist.pois]](rand.dist.pois#exp)
#### 29.5.9.4.2 Class template exponential_distribution [rand.dist.pois.exp]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5245)
An exponential_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.9](#eq:rand.dist.pois.exp)[.](#1.sentence-1)
p(x|λ)=λe−λx(29.9)
[🔗](#lib:exponential_distribution_)
namespace std {template<class RealType = double>class exponential_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions exponential_distribution() : exponential_distribution(1.0) {}explicit exponential_distribution(RealType lambda); explicit exponential_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const exponential_distribution& x, const exponential_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType lambda() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const exponential_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, exponential_distribution& x); };}
[🔗](#lib:exponential_distribution,constructor)
`explicit exponential_distribution(RealType lambda);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5305)
*Preconditions*: 0<lambda[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5309)
*Remarks*: lambda corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:lambda,exponential_distribution)
`RealType lambda() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5320)
*Returns*: The value of the lambda parameter
with which the object was constructed[.](#4.sentence-1)

81
cppdraft/rand/dist/pois/extreme.md vendored Normal file
View File

@@ -0,0 +1,81 @@
[rand.dist.pois.extreme]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois.extreme)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois.extreme)
#### 29.5.9.4 Poisson distributions [[rand.dist.pois]](rand.dist.pois#extreme)
#### 29.5.9.4.5 Class template extreme_value_distribution [rand.dist.pois.extreme]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5538)
An extreme_value_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.12](#eq:rand.dist.pois.extreme)[.](#1.sentence-1)[246](#footnote-246 "The distribution corresponding to this probability density function is also known (with a possible change of variable) as the Gumbel Type I, the log-Weibull, or the Fisher-Tippett Type I distribution.")
p(x|a,b)=1bâ‹exp(a−xb−exp(a−xb))(29.12)
[🔗](#lib:extreme_value_distribution_)
namespace std {template<class RealType = double>class extreme_value_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions extreme_value_distribution() : extreme_value_distribution(0.0) {}explicit extreme_value_distribution(RealType a, RealType b = 1.0); explicit extreme_value_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const extreme_value_distribution& x, const extreme_value_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const extreme_value_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, extreme_value_distribution& x); };}
[🔗](#lib:extreme_value_distribution,constructor)
`explicit extreme_value_distribution(RealType a, RealType b = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5610)
*Preconditions*: 0<b[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5614)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:a,extreme_value_distribution)
`RealType a() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5626)
*Returns*: The value of the a parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:b,extreme_value_distribution)
`RealType b() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5638)
*Returns*: The value of the b parameter
with which the object was constructed[.](#5.sentence-1)
[246)](#footnote-246)[246)](#footnoteref-246)
The distribution corresponding to
this probability density function
is also known
(with a possible change of variable)
as the Gumbel Type I,
the log-Weibull,
or the Fisher-Tippett Type I
distribution[.](#footnote-246.sentence-1)

70
cppdraft/rand/dist/pois/gamma.md vendored Normal file
View File

@@ -0,0 +1,70 @@
[rand.dist.pois.gamma]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois.gamma)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois.gamma)
#### 29.5.9.4 Poisson distributions [[rand.dist.pois]](rand.dist.pois#gamma)
#### 29.5.9.4.3 Class template gamma_distribution [rand.dist.pois.gamma]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5332)
A gamma_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.10](#eq:rand.dist.pois.gamma)[.](#1.sentence-1)
p(x|α,β)=e−x/ββαâ‹Î“(α)â‹xα−1(29.10)
[🔗](#lib:gamma_distribution_)
namespace std {template<class RealType = double>class gamma_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions gamma_distribution() : gamma_distribution(1.0) {}explicit gamma_distribution(RealType alpha, RealType beta = 1.0); explicit gamma_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const gamma_distribution& x, const gamma_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType alpha() const;
RealType beta() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const gamma_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, gamma_distribution& x); };}
[🔗](#lib:gamma_distribution,constructor)
`explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5394)
*Preconditions*: 0<alpha and 0<beta[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5398)
*Remarks*: alpha and beta correspond to the parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:alpha,gamma_distribution)
`RealType alpha() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5410)
*Returns*: The value of the alpha parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:beta,gamma_distribution)
`RealType beta() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5422)
*Returns*: The value of the beta parameter
with which the object was constructed[.](#5.sentence-1)

59
cppdraft/rand/dist/pois/poisson.md vendored Normal file
View File

@@ -0,0 +1,59 @@
[rand.dist.pois.poisson]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois.poisson)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois.poisson)
#### 29.5.9.4 Poisson distributions [[rand.dist.pois]](rand.dist.pois#poisson)
#### 29.5.9.4.1 Class template poisson_distribution [rand.dist.pois.poisson]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5157)
A poisson_distribution random number distribution
produces integer values i ≥ 0 distributed according to
the discrete probability function in Formula [29.8](#eq:rand.dist.pois.poisson)[.](#1.sentence-1)
P(i|μ)=e−μμii!(29.8)
The distribution parameter μ is also known as this distribution's [*mean*](#def:mean)[.](#1.sentence-2)
[🔗](#lib:poisson_distribution_)
namespace std {template<class IntType = int>class poisson_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions poisson_distribution() : poisson_distribution(1.0) {}explicit poisson_distribution(double mean); explicit poisson_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const poisson_distribution& x, const poisson_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functionsdouble mean() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const poisson_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, poisson_distribution& x); };}
[🔗](#lib:poisson_distribution,constructor)
`explicit poisson_distribution(double mean);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5218)
*Preconditions*: 0<mean[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5222)
*Remarks*: mean corresponds to the parameter of the distribution[.](#3.sentence-1)
[🔗](#lib:mean,poisson_distribution)
`double mean() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5233)
*Returns*: The value of the mean parameter
with which the object was constructed[.](#4.sentence-1)

70
cppdraft/rand/dist/pois/weibull.md vendored Normal file
View File

@@ -0,0 +1,70 @@
[rand.dist.pois.weibull]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.pois.weibull)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#pois.weibull)
#### 29.5.9.4 Poisson distributions [[rand.dist.pois]](rand.dist.pois#weibull)
#### 29.5.9.4.4 Class template weibull_distribution [rand.dist.pois.weibull]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5435)
A weibull_distribution random number distribution
produces random numbers x ≥ 0 distributed according to
the probability density function in Formula [29.11](#eq:rand.dist.pois.weibull)[.](#1.sentence-1)
p(x|a,b)=abâ‹(xb)a−‹exp(−(xb)a)(29.11)
[🔗](#lib:weibull_distribution_)
namespace std {template<class RealType = double>class weibull_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions weibull_distribution() : weibull_distribution(1.0) {}explicit weibull_distribution(RealType a, RealType b = 1.0); explicit weibull_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const weibull_distribution& x, const weibull_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType a() const;
RealType b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const weibull_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, weibull_distribution& x); };}
[🔗](#lib:weibull_distribution,constructor)
`explicit weibull_distribution(RealType a, RealType b = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5497)
*Preconditions*: 0<a and 0<b[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5501)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:a,weibull_distribution)
`RealType a() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5513)
*Returns*: The value of the a parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:b,weibull_distribution)
`RealType b() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5525)
*Returns*: The value of the b parameter
with which the object was constructed[.](#5.sentence-1)

519
cppdraft/rand/dist/samp.md vendored Normal file
View File

@@ -0,0 +1,519 @@
[rand.dist.samp]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.samp)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#samp)
#### 29.5.9.6 Sampling distributions [rand.dist.samp]
#### [29.5.9.6.1](#discrete) Class template discrete_distribution [[rand.dist.samp.discrete]](rand.dist.samp.discrete)
[1](#discrete-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6273)
A discrete_distribution random number distribution
produces random integers i, 0≤i<n,
distributed according to
the discrete probability function in Formula [29.19](#eq:rand.dist.samp.discrete)[.](#discrete-1.sentence-1)
P(i|p0,…,pn−1)=pi(29.19)
[2](#discrete-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6282)
Unless specified otherwise,
the distribution parameters are calculated as:pk=wk/S for k=0,…,n−1,
in which the values wk,
commonly known as the [*weights*](#def:weights), shall be non-negative, non-NaN, and non-infinity[.](#discrete-2.sentence-1)
Moreover, the following relation shall hold:0<S=w0+⋯+wn−1[.](#discrete-2.sentence-2)
[🔗](#lib:discrete_distribution_)
namespace std {template<class IntType = int>class discrete_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructor and reset functions discrete_distribution(); template<class InputIterator> discrete_distribution(InputIterator firstW, InputIterator lastW);
discrete_distribution(initializer_list<double> wl); template<class UnaryOperation> discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); explicit discrete_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const discrete_distribution& x, const discrete_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<double> probabilities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const discrete_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, discrete_distribution& x); };}
[🔗](#lib:discrete_distribution,constructor)
`discrete_distribution();
`
[3](#discrete-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6346)
*Effects*: Constructs a discrete_distribution object
with n=1 and p0=1[.](#discrete-3.sentence-1)
[*Note [1](#discrete-note-1)*:
Such an object will always deliver the value 0[.](#discrete-3.sentence-2)
— *end note*]
[🔗](#lib:discrete_distribution,constructor_)
`template<class InputIterator>
discrete_distribution(InputIterator firstW, InputIterator lastW);
`
[4](#discrete-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6363)
*Mandates*: is_convertible_v<iterator_traits<InputIterator>::value_type,double> is true[.](#discrete-4.sentence-1)
[5](#discrete-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6368)
*Preconditions*: InputIterator meets the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#discrete-5.sentence-1)
If firstW == lastW,
let n=1 and w0=1[.](#discrete-5.sentence-2)
Otherwise, [firstW, lastW) forms a sequence w of length n>0[.](#discrete-5.sentence-3)
[6](#discrete-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6378)
*Effects*: Constructs a discrete_distribution object
with probabilities given by the Formula [29.19](#eq:rand.dist.samp.discrete)[.](#discrete-6.sentence-1)
[🔗](#lib:discrete_distribution,constructor__)
`discrete_distribution(initializer_list<double> wl);
`
[7](#discrete-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6391)
*Effects*: Same as discrete_distribution(wl.begin(), wl.end())[.](#discrete-7.sentence-1)
[🔗](#lib:discrete_distribution,constructor___)
`template<class UnaryOperation>
discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
`
[8](#discrete-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6403)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#discrete-8.sentence-1)
[9](#discrete-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6407)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#discrete-9.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#discrete-9.sentence-2)
[10](#discrete-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6414)
*Effects*: Constructs a discrete_distribution object
with probabilities given by the formula above,
using the following values:
If nw=0,
let w0=1[.](#discrete-10.sentence-1)
Otherwise,
let wk=fw(xmin+kâ‹Î´+δ/2) for k=0,…,n−1[.](#discrete-10.sentence-2)
[11](#discrete-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6425)
*Complexity*: The number of invocations of fw does not exceed n[.](#discrete-11.sentence-1)
[🔗](#lib:probabilities,discrete_distribution)
`vector<double> probabilities() const;
`
[12](#discrete-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6436)
*Returns*: A vector<double> whose size member returns n and whose operator[] member returns pk when invoked with argument k for k=0,…,n−1[.](#discrete-12.sentence-1)
#### [29.5.9.6.2](#pconst) Class template piecewise_constant_distribution [[rand.dist.samp.pconst]](rand.dist.samp.pconst)
[1](#pconst-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6452)
A piecewise_constant_distribution random number distribution
produces random numbers x,b0≤x<bn,
uniformly distributed over each subinterval[bi,bi+1) according to the probability density function in Formula [29.20](#eq:rand.dist.samp.pconst)[.](#pconst-1.sentence-1)
p(x|b0,…,bn,ρ0,…,ρˆ’1)=ρ , for bi≤x<bi+1(29.20)
[2](#pconst-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6464)
The n+1 distribution parameters bi,
also known as this distribution's [*interval boundaries*](#def:interval_boundaries), shall satisfy the relationbi<bi+1 for i=0,…,n−1[.](#pconst-2.sentence-1)
Unless specified otherwise,
the remaining n distribution parameters are calculated as:
ρk=wkSâ‹(bk+1−bk) for k=0,…,n− , in which the values wk,
commonly known as the [*weights*](#def:weights), shall be non-negative, non-NaN, and non-infinity[.](#pconst-2.sentence-2)
Moreover, the following relation shall hold: 0<S=w0+⋯+wn−1[.](#pconst-2.sentence-3)
[🔗](#lib:piecewise_constant_distribution_)
namespace std {template<class RealType = double>class piecewise_constant_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_constant_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW); template<class UnaryOperation> piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax,
UnaryOperation fw); explicit piecewise_constant_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const piecewise_constant_distribution& x, const piecewise_constant_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<result_type> intervals() const;
vector<result_type> densities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const piecewise_constant_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, piecewise_constant_distribution& x); };}
[🔗](#lib:piecewise_constant_distribution,constructor)
`piecewise_constant_distribution();
`
[3](#pconst-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6538)
*Effects*: Constructs a piecewise_constant_distribution object
with n=1, ρ0=1, b0=0,
and b1=1[.](#pconst-3.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor_)
`template<class InputIteratorB, class InputIteratorW>
piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW);
`
[4](#pconst-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6556)
*Mandates*: Both of
- [(4.1)](#pconst-4.1)
is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>
- [(4.2)](#pconst-4.2)
is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>
are true[.](#pconst-4.sentence-1)
[5](#pconst-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6565)
*Preconditions*: InputIteratorB and InputIteratorW each meet the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#pconst-5.sentence-1)
If firstB == lastB or ++firstB == lastB,
let n=1, w0=1, b0=0,
and b1=1[.](#pconst-5.sentence-2)
Otherwise, [firstB, lastB) forms a sequence b of length n+1,
the length of the sequence w starting from firstW is at least n,
and any wk for k ≥ n are ignored by the distribution[.](#pconst-5.sentence-3)
[6](#pconst-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6583)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters as specified above[.](#pconst-6.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor__)
`template<class UnaryOperation>
piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`
[7](#pconst-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6597)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#pconst-7.sentence-1)
[8](#pconst-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6601)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters taken or calculated
from the following values:
If bl.size()<2,
let n=1, w0=1, b0=0,
and b1=1[.](#pconst-8.sentence-1)
Otherwise,
let [bl.begin(), bl.end()) form a sequence b0,…,bn,
and
let wk=fw((bk+1+bk)/2) for k=0,…,n−1[.](#pconst-8.sentence-2)
[9](#pconst-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6618)
*Complexity*: The number of invocations of fw does not exceed n[.](#pconst-9.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor___)
`template<class UnaryOperation>
piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
`
[10](#pconst-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6631)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#pconst-10.sentence-1)
[11](#pconst-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6635)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#pconst-11.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#pconst-11.sentence-2)
[12](#pconst-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6641)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters taken or calculated
from the following values:
Let bk=xmin+kâ‹Î´ for k=0,…,n,
and wk=fw(bk+δ/2) for k=0,…,n−1[.](#pconst-12.sentence-1)
[13](#pconst-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6649)
*Complexity*: The number of invocations of fw does not exceed n[.](#pconst-13.sentence-1)
[🔗](#lib:intervals,piecewise_constant_distribution)
`vector<result_type> intervals() const;
`
[14](#pconst-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6660)
*Returns*: A vector<result_type> whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#pconst-14.sentence-1)
[🔗](#lib:densities,piecewise_constant_distribution)
`vector<result_type> densities() const;
`
[15](#pconst-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6674)
*Returns*: A vector<result_type> whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n−1[.](#pconst-15.sentence-1)
#### [29.5.9.6.3](#plinear) Class template piecewise_linear_distribution [[rand.dist.samp.plinear]](rand.dist.samp.plinear)
[1](#plinear-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6690)
A piecewise_linear_distribution random number distribution
produces random numbers x,b0≤x<bn,
distributed over each subinterval[bi,bi+1) according to the probability density function in Formula [29.21](#eq:rand.dist.samp.plinear)[.](#plinear-1.sentence-1)
p(x|b0,…,bn,ρ0,…,ρn)=ρ‹bi+ˆ’xbi+ˆ’bi+ρi+‹ˆ’bibi+ˆ’bi , for bi≤x<bi+1.(29.21)
[2](#plinear-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6704)
The n+1 distribution parameters bi,
also known as this distribution's [*interval boundaries*](#def:interval_boundaries), shall satisfy the relation bi<bi+1 for i=0,…,n−1[.](#plinear-2.sentence-1)
Unless specified otherwise,
the remaining n+1 distribution parameters are calculated asρk=wk/S for k=0,…,n, in which the values wk,
commonly known as the [*weights at boundaries*](#def:weights_at_boundaries), shall be non-negative, non-NaN, and non-infinity[.](#plinear-2.sentence-2)
Moreover, the following relation shall hold:
0<S=12⋈’ˆ‘k=0(wk+wk+1)â‹(bk+1−bk) [.](#plinear-2.sentence-3)
[🔗](#lib:piecewise_linear_distribution_)
namespace std {template<class RealType = double>class piecewise_linear_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_linear_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW); template<class UnaryOperation> piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); explicit piecewise_linear_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const piecewise_linear_distribution& x, const piecewise_linear_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<result_type> intervals() const;
vector<result_type> densities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const piecewise_linear_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, piecewise_linear_distribution& x); };}
[🔗](#lib:piecewise_linear_distribution,constructor)
`piecewise_linear_distribution();
`
[3](#plinear-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6774)
*Effects*: Constructs a piecewise_linear_distribution object
with n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#plinear-3.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor_)
`template<class InputIteratorB, class InputIteratorW>
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW);
`
[4](#plinear-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6791)
*Mandates*: Both of
- [(4.1)](#plinear-4.1)
is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>
- [(4.2)](#plinear-4.2)
is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>
are true[.](#plinear-4.sentence-1)
[5](#plinear-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6800)
*Preconditions*: InputIteratorB and InputIteratorW each meet the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#plinear-5.sentence-1)
If firstB == lastB or ++firstB == lastB,
let n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#plinear-5.sentence-2)
Otherwise, [firstB, lastB) forms a sequence b of length n+1,
the length of the sequence w starting from firstW is at least n+1,
and any wk for k≥n+1 are ignored by the distribution[.](#plinear-5.sentence-3)
[6](#plinear-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6818)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters as specified above[.](#plinear-6.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor__)
`template<class UnaryOperation>
piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`
[7](#plinear-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6832)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#plinear-7.sentence-1)
[8](#plinear-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6836)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters taken or calculated
from the following values:
If bl.size()<2,
let n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#plinear-8.sentence-1)
Otherwise,
let [bl.begin(), bl.end()) form a sequence b0,…,bn,
and
let wk=fw(bk) for k=0,…,n[.](#plinear-8.sentence-2)
[9](#plinear-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6853)
*Complexity*: The number of invocations of fw does not exceed n+1[.](#plinear-9.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor___)
`template<class UnaryOperation>
piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
`
[10](#plinear-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6866)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#plinear-10.sentence-1)
[11](#plinear-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6870)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#plinear-11.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#plinear-11.sentence-2)
[12](#plinear-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6876)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters taken or calculated
from the following values:
Let bk=xmin+kâ‹Î´ for k=0,…,n,
and wk=fw(bk) for k=0,…,n[.](#plinear-12.sentence-1)
[13](#plinear-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6884)
*Complexity*: The number of invocations of fw does not exceed n+1[.](#plinear-13.sentence-1)
[🔗](#lib:intervals,piecewise_linear_distribution)
`vector<result_type> intervals() const;
`
[14](#plinear-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6895)
*Returns*: A vector<result_type> whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#plinear-14.sentence-1)
[🔗](#lib:densities,piecewise_linear_distribution)
`vector<result_type> densities() const;
`
[15](#plinear-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6909)
*Returns*: A vector<result_type> whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n[.](#plinear-15.sentence-1)

150
cppdraft/rand/dist/samp/discrete.md vendored Normal file
View File

@@ -0,0 +1,150 @@
[rand.dist.samp.discrete]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.samp.discrete)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#samp.discrete)
#### 29.5.9.6 Sampling distributions [[rand.dist.samp]](rand.dist.samp#discrete)
#### 29.5.9.6.1 Class template discrete_distribution [rand.dist.samp.discrete]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6273)
A discrete_distribution random number distribution
produces random integers i, 0≤i<n,
distributed according to
the discrete probability function in Formula [29.19](#eq:rand.dist.samp.discrete)[.](#1.sentence-1)
P(i|p0,…,pn−1)=pi(29.19)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6282)
Unless specified otherwise,
the distribution parameters are calculated as:pk=wk/S for k=0,…,n−1,
in which the values wk,
commonly known as the [*weights*](#def:weights), shall be non-negative, non-NaN, and non-infinity[.](#2.sentence-1)
Moreover, the following relation shall hold:0<S=w0+⋯+wn−1[.](#2.sentence-2)
[🔗](#lib:discrete_distribution_)
namespace std {template<class IntType = int>class discrete_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructor and reset functions discrete_distribution(); template<class InputIterator> discrete_distribution(InputIterator firstW, InputIterator lastW);
discrete_distribution(initializer_list<double> wl); template<class UnaryOperation> discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); explicit discrete_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const discrete_distribution& x, const discrete_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<double> probabilities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const discrete_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, discrete_distribution& x); };}
[🔗](#lib:discrete_distribution,constructor)
`discrete_distribution();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6346)
*Effects*: Constructs a discrete_distribution object
with n=1 and p0=1[.](#3.sentence-1)
[*Note [1](#note-1)*:
Such an object will always deliver the value 0[.](#3.sentence-2)
— *end note*]
[🔗](#lib:discrete_distribution,constructor_)
`template<class InputIterator>
discrete_distribution(InputIterator firstW, InputIterator lastW);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6363)
*Mandates*: is_convertible_v<iterator_traits<InputIterator>::value_type,double> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6368)
*Preconditions*: InputIterator meets the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#5.sentence-1)
If firstW == lastW,
let n=1 and w0=1[.](#5.sentence-2)
Otherwise, [firstW, lastW) forms a sequence w of length n>0[.](#5.sentence-3)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6378)
*Effects*: Constructs a discrete_distribution object
with probabilities given by the Formula [29.19](#eq:rand.dist.samp.discrete)[.](#6.sentence-1)
[🔗](#lib:discrete_distribution,constructor__)
`discrete_distribution(initializer_list<double> wl);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6391)
*Effects*: Same as discrete_distribution(wl.begin(), wl.end())[.](#7.sentence-1)
[🔗](#lib:discrete_distribution,constructor___)
`template<class UnaryOperation>
discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6403)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6407)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#9.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6414)
*Effects*: Constructs a discrete_distribution object
with probabilities given by the formula above,
using the following values:
If nw=0,
let w0=1[.](#10.sentence-1)
Otherwise,
let wk=fw(xmin+kâ‹Î´+δ/2) for k=0,…,n−1[.](#10.sentence-2)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6425)
*Complexity*: The number of invocations of fw does not exceed n[.](#11.sentence-1)
[🔗](#lib:probabilities,discrete_distribution)
`vector<double> probabilities() const;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6436)
*Returns*: A vector<double> whose size member returns n and whose operator[] member returns pk when invoked with argument k for k=0,…,n−1[.](#12.sentence-1)

194
cppdraft/rand/dist/samp/pconst.md vendored Normal file
View File

@@ -0,0 +1,194 @@
[rand.dist.samp.pconst]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.samp.pconst)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#samp.pconst)
#### 29.5.9.6 Sampling distributions [[rand.dist.samp]](rand.dist.samp#pconst)
#### 29.5.9.6.2 Class template piecewise_constant_distribution [rand.dist.samp.pconst]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6452)
A piecewise_constant_distribution random number distribution
produces random numbers x,b0≤x<bn,
uniformly distributed over each subinterval[bi,bi+1) according to the probability density function in Formula [29.20](#eq:rand.dist.samp.pconst)[.](#1.sentence-1)
p(x|b0,…,bn,ρ0,…,ρˆ’1)=ρ , for bi≤x<bi+1(29.20)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6464)
The n+1 distribution parameters bi,
also known as this distribution's [*interval boundaries*](#def:interval_boundaries), shall satisfy the relationbi<bi+1 for i=0,…,n−1[.](#2.sentence-1)
Unless specified otherwise,
the remaining n distribution parameters are calculated as:
ρk=wkSâ‹(bk+1−bk) for k=0,…,n− , in which the values wk,
commonly known as the [*weights*](#def:weights), shall be non-negative, non-NaN, and non-infinity[.](#2.sentence-2)
Moreover, the following relation shall hold: 0<S=w0+⋯+wn−1[.](#2.sentence-3)
[🔗](#lib:piecewise_constant_distribution_)
namespace std {template<class RealType = double>class piecewise_constant_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_constant_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW); template<class UnaryOperation> piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax,
UnaryOperation fw); explicit piecewise_constant_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const piecewise_constant_distribution& x, const piecewise_constant_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<result_type> intervals() const;
vector<result_type> densities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const piecewise_constant_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, piecewise_constant_distribution& x); };}
[🔗](#lib:piecewise_constant_distribution,constructor)
`piecewise_constant_distribution();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6538)
*Effects*: Constructs a piecewise_constant_distribution object
with n=1, ρ0=1, b0=0,
and b1=1[.](#3.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor_)
`template<class InputIteratorB, class InputIteratorW>
piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6556)
*Mandates*: Both of
- [(4.1)](#4.1)
is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>
- [(4.2)](#4.2)
is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>
are true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6565)
*Preconditions*: InputIteratorB and InputIteratorW each meet the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#5.sentence-1)
If firstB == lastB or ++firstB == lastB,
let n=1, w0=1, b0=0,
and b1=1[.](#5.sentence-2)
Otherwise, [firstB, lastB) forms a sequence b of length n+1,
the length of the sequence w starting from firstW is at least n,
and any wk for k ≥ n are ignored by the distribution[.](#5.sentence-3)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6583)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters as specified above[.](#6.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor__)
`template<class UnaryOperation>
piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6597)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6601)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters taken or calculated
from the following values:
If bl.size()<2,
let n=1, w0=1, b0=0,
and b1=1[.](#8.sentence-1)
Otherwise,
let [bl.begin(), bl.end()) form a sequence b0,…,bn,
and
let wk=fw((bk+1+bk)/2) for k=0,…,n−1[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6618)
*Complexity*: The number of invocations of fw does not exceed n[.](#9.sentence-1)
[🔗](#lib:piecewise_constant_distribution,constructor___)
`template<class UnaryOperation>
piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6631)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6635)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#11.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#11.sentence-2)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6641)
*Effects*: Constructs a piecewise_constant_distribution object
with parameters taken or calculated
from the following values:
Let bk=xmin+kâ‹Î´ for k=0,…,n,
and wk=fw(bk+δ/2) for k=0,…,n−1[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6649)
*Complexity*: The number of invocations of fw does not exceed n[.](#13.sentence-1)
[🔗](#lib:intervals,piecewise_constant_distribution)
`vector<result_type> intervals() const;
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6660)
*Returns*: A vector<result_type> whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#14.sentence-1)
[🔗](#lib:densities,piecewise_constant_distribution)
`vector<result_type> densities() const;
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6674)
*Returns*: A vector<result_type> whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n−1[.](#15.sentence-1)

193
cppdraft/rand/dist/samp/plinear.md vendored Normal file
View File

@@ -0,0 +1,193 @@
[rand.dist.samp.plinear]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.samp.plinear)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#samp.plinear)
#### 29.5.9.6 Sampling distributions [[rand.dist.samp]](rand.dist.samp#plinear)
#### 29.5.9.6.3 Class template piecewise_linear_distribution [rand.dist.samp.plinear]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6690)
A piecewise_linear_distribution random number distribution
produces random numbers x,b0≤x<bn,
distributed over each subinterval[bi,bi+1) according to the probability density function in Formula [29.21](#eq:rand.dist.samp.plinear)[.](#1.sentence-1)
p(x|b0,…,bn,ρ0,…,ρn)=ρ‹bi+ˆ’xbi+ˆ’bi+ρi+‹ˆ’bibi+ˆ’bi , for bi≤x<bi+1.(29.21)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6704)
The n+1 distribution parameters bi,
also known as this distribution's [*interval boundaries*](#def:interval_boundaries), shall satisfy the relation bi<bi+1 for i=0,…,n−1[.](#2.sentence-1)
Unless specified otherwise,
the remaining n+1 distribution parameters are calculated asρk=wk/S for k=0,…,n, in which the values wk,
commonly known as the [*weights at boundaries*](#def:weights_at_boundaries), shall be non-negative, non-NaN, and non-infinity[.](#2.sentence-2)
Moreover, the following relation shall hold:
0<S=12⋈’ˆ‘k=0(wk+wk+1)â‹(bk+1−bk) [.](#2.sentence-3)
[🔗](#lib:piecewise_linear_distribution_)
namespace std {template<class RealType = double>class piecewise_linear_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_linear_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW); template<class UnaryOperation> piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); explicit piecewise_linear_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const piecewise_linear_distribution& x, const piecewise_linear_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions vector<result_type> intervals() const;
vector<result_type> densities() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const piecewise_linear_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, piecewise_linear_distribution& x); };}
[🔗](#lib:piecewise_linear_distribution,constructor)
`piecewise_linear_distribution();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6774)
*Effects*: Constructs a piecewise_linear_distribution object
with n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#3.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor_)
`template<class InputIteratorB, class InputIteratorW>
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6791)
*Mandates*: Both of
- [(4.1)](#4.1)
is_convertible_v<iterator_traits<InputIteratorB>::value_type, double>
- [(4.2)](#4.2)
is_convertible_v<iterator_traits<InputIteratorW>::value_type, double>
are true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6800)
*Preconditions*: InputIteratorB and InputIteratorW each meet the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3Input iterators[input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3Input iterators"))[.](#5.sentence-1)
If firstB == lastB or ++firstB == lastB,
let n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#5.sentence-2)
Otherwise, [firstB, lastB) forms a sequence b of length n+1,
the length of the sequence w starting from firstW is at least n+1,
and any wk for k≥n+1 are ignored by the distribution[.](#5.sentence-3)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6818)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters as specified above[.](#6.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor__)
`template<class UnaryOperation>
piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6832)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6836)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters taken or calculated
from the following values:
If bl.size()<2,
let n=1, ρ0=ρ1=1, b0=0,
and b1=1[.](#8.sentence-1)
Otherwise,
let [bl.begin(), bl.end()) form a sequence b0,…,bn,
and
let wk=fw(bk) for k=0,…,n[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6853)
*Complexity*: The number of invocations of fw does not exceed n+1[.](#9.sentence-1)
[🔗](#lib:piecewise_linear_distribution,constructor___)
`template<class UnaryOperation>
piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6866)
*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6870)
*Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#11.sentence-1)
The relation 0<δ=(xmax−xmin)/n holds[.](#11.sentence-2)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6876)
*Effects*: Constructs a piecewise_linear_distribution object
with parameters taken or calculated
from the following values:
Let bk=xmin+kâ‹Î´ for k=0,…,n,
and wk=fw(bk) for k=0,…,n[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6884)
*Complexity*: The number of invocations of fw does not exceed n+1[.](#13.sentence-1)
[🔗](#lib:intervals,piecewise_linear_distribution)
`vector<result_type> intervals() const;
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6895)
*Returns*: A vector<result_type> whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#14.sentence-1)
[🔗](#lib:densities,piecewise_linear_distribution)
`vector<result_type> densities() const;
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6909)
*Returns*: A vector<result_type> whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n[.](#15.sentence-1)

139
cppdraft/rand/dist/uni.md vendored Normal file
View File

@@ -0,0 +1,139 @@
[rand.dist.uni]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.uni)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#uni)
#### 29.5.9.2 Uniform distributions [rand.dist.uni]
#### [29.5.9.2.1](#int) Class template uniform_int_distribution [[rand.dist.uni.int]](rand.dist.uni.int)
[1](#int-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4532)
A uniform_int_distribution random number distribution
produces random integers i,a ≤ i ≤ b,
distributed according to
the constant discrete probability function in Formula [29.2](#eq:rand.dist.uni.int)[.](#int-1.sentence-1)
P(i|a,b)=1/(b−a+1)(29.2)
[🔗](#lib:uniform_int_distribution_)
namespace std {template<class IntType = int>class uniform_int_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions uniform_int_distribution() : uniform_int_distribution(0) {}explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max()); explicit uniform_int_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const uniform_int_distribution& x, const uniform_int_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions result_type a() const;
result_type b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, // hostedconst uniform_int_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, // hosted uniform_int_distribution& x); };}
[🔗](#lib:uniform_int_distribution,constructor)
`explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
`
[2](#int-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4597)
*Preconditions*: a ≤ b[.](#int-2.sentence-1)
[3](#int-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4601)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#int-3.sentence-1)
[🔗](#lib:a,uniform_int_distribution)
`result_type a() const;
`
[4](#int-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4613)
*Returns*: The value of the a parameter
with which the object was constructed[.](#int-4.sentence-1)
[🔗](#lib:b,uniform_int_distribution)
`result_type b() const;
`
[5](#int-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4625)
*Returns*: The value of the b parameter
with which the object was constructed[.](#int-5.sentence-1)
#### [29.5.9.2.2](#real) Class template uniform_real_distribution [[rand.dist.uni.real]](rand.dist.uni.real)
[1](#real-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4637)
A uniform_real_distribution random number distribution
produces random numbers x,a≤x<b,
distributed according to
the constant probability density function in Formula [29.3](#eq:rand.dist.uni.real)[.](#real-1.sentence-1)
p(x|a,b)=1/(ˆ’a)(29.3)
[*Note [1](#real-note-1)*:
This implies that p(x | a,b) is undefined when a == b[.](#real-1.sentence-2)
— *end note*]
[🔗](#lib:uniform_real_distribution_)
namespace std {template<class RealType = double>class uniform_real_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions uniform_real_distribution() : uniform_real_distribution(0.0) {}explicit uniform_real_distribution(RealType a, RealType b = 1.0); explicit uniform_real_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const uniform_real_distribution& x, const uniform_real_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions result_type a() const;
result_type b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const uniform_real_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, uniform_real_distribution& x); };}
[🔗](#lib:uniform_real_distribution,constructor)
`explicit uniform_real_distribution(RealType a, RealType b = 1.0);
`
[2](#real-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4703)
*Preconditions*: a ≤ b andb−‰¤numeric_limits<RealType>::max()[.](#real-2.sentence-1)
[3](#real-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4709)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#real-3.sentence-1)
[🔗](#lib:a,uniform_real_distribution)
`result_type a() const;
`
[4](#real-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4721)
*Returns*: The value of the a parameter
with which the object was constructed[.](#real-4.sentence-1)
[🔗](#lib:b,uniform_real_distribution)
`result_type b() const;
`
[5](#real-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4733)
*Returns*: The value of the b parameter
with which the object was constructed[.](#real-5.sentence-1)

71
cppdraft/rand/dist/uni/int.md vendored Normal file
View File

@@ -0,0 +1,71 @@
[rand.dist.uni.int]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.uni.int)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#uni.int)
#### 29.5.9.2 Uniform distributions [[rand.dist.uni]](rand.dist.uni#int)
#### 29.5.9.2.1 Class template uniform_int_distribution [rand.dist.uni.int]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4532)
A uniform_int_distribution random number distribution
produces random integers i,a ≤ i ≤ b,
distributed according to
the constant discrete probability function in Formula [29.2](#eq:rand.dist.uni.int)[.](#1.sentence-1)
P(i|a,b)=1/(b−a+1)(29.2)
[🔗](#lib:uniform_int_distribution_)
namespace std {template<class IntType = int>class uniform_int_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructors and reset functions uniform_int_distribution() : uniform_int_distribution(0) {}explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max()); explicit uniform_int_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const uniform_int_distribution& x, const uniform_int_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions result_type a() const;
result_type b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, // hostedconst uniform_int_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, // hosted uniform_int_distribution& x); };}
[🔗](#lib:uniform_int_distribution,constructor)
`explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4597)
*Preconditions*: a ≤ b[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4601)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:a,uniform_int_distribution)
`result_type a() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4613)
*Returns*: The value of the a parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:b,uniform_int_distribution)
`result_type b() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4625)
*Returns*: The value of the b parameter
with which the object was constructed[.](#5.sentence-1)

77
cppdraft/rand/dist/uni/real.md vendored Normal file
View File

@@ -0,0 +1,77 @@
[rand.dist.uni.real]
# 29 Numerics library [[numerics]](./#numerics)
## 29.5 Random number generation [[rand]](rand#dist.uni.real)
### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#uni.real)
#### 29.5.9.2 Uniform distributions [[rand.dist.uni]](rand.dist.uni#real)
#### 29.5.9.2.2 Class template uniform_real_distribution [rand.dist.uni.real]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4637)
A uniform_real_distribution random number distribution
produces random numbers x,a≤x<b,
distributed according to
the constant probability density function in Formula [29.3](#eq:rand.dist.uni.real)[.](#1.sentence-1)
p(x|a,b)=1/(ˆ’a)(29.3)
[*Note [1](#note-1)*:
This implies that p(x | a,b) is undefined when a == b[.](#1.sentence-2)
— *end note*]
[🔗](#lib:uniform_real_distribution_)
namespace std {template<class RealType = double>class uniform_real_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions uniform_real_distribution() : uniform_real_distribution(0.0) {}explicit uniform_real_distribution(RealType a, RealType b = 1.0); explicit uniform_real_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const uniform_real_distribution& x, const uniform_real_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions result_type a() const;
result_type b() const;
param_type param() const; void param(const param_type& parm);
result_type min() const;
result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const uniform_real_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, uniform_real_distribution& x); };}
[🔗](#lib:uniform_real_distribution,constructor)
`explicit uniform_real_distribution(RealType a, RealType b = 1.0);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4703)
*Preconditions*: a ≤ b andb−‰¤numeric_limits<RealType>::max()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4709)
*Remarks*: a and b correspond to the respective parameters of the distribution[.](#3.sentence-1)
[🔗](#lib:a,uniform_real_distribution)
`result_type a() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4721)
*Returns*: The value of the a parameter
with which the object was constructed[.](#4.sentence-1)
[🔗](#lib:b,uniform_real_distribution)
`result_type b() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4733)
*Returns*: The value of the b parameter
with which the object was constructed[.](#5.sentence-1)