[rand.dist] # 29 Numerics library [[numerics]](./#numerics) ## 29.5 Random number generation [[rand]](rand#dist) ### 29.5.9 Random number distribution class templates [rand.dist] #### [29.5.9.1](#general) General [[rand.dist.general]](rand.dist.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4486) Each type instantiated from a class template specified in [rand.dist] meets the requirements of a [random number distribution](rand.req.dist "29.5.3.6 Random number distribution requirements [rand.req.dist]") type[.](#general-1.sentence-1) [2](#general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4492) Descriptions are provided in [rand.dist] only for distribution operations that are not described in [[rand.req.dist]](rand.req.dist "29.5.3.6 Random number distribution requirements") or for operations where there is additional semantic information[.](#general-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[.](#general-2.sentence-2) [3](#general-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4504) The algorithms for producing each of the specified distributions areimplementation-defined[.](#general-3.sentence-1) [4](#general-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[.](#general-4.sentence-1) #### [29.5.9.2](#uni) Uniform distributions [[rand.dist.uni]](rand.dist.uni) #### [29.5.9.2.1](#uni.int) Class template uniform_int_distribution [[rand.dist.uni.int]](rand.dist.uni.int) [1](#uni.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)[.](#uni.int-1.sentence-1) P(i|a,b)=1/(b−a+1)(29.2) [🔗](#lib:uniform_int_distribution_) namespace std {templateclass 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::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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, // hostedconst uniform_int_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, // hosted uniform_int_distribution& x); };} [🔗](#lib:uniform_int_distribution,constructor) `explicit uniform_int_distribution(IntType a, IntType b = numeric_limits::max()); ` [2](#uni.int-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4597) *Preconditions*: a ≤ b[.](#uni.int-2.sentence-1) [3](#uni.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[.](#uni.int-3.sentence-1) [🔗](#lib:a,uniform_int_distribution) `result_type a() const; ` [4](#uni.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[.](#uni.int-4.sentence-1) [🔗](#lib:b,uniform_int_distribution) `result_type b() const; ` [5](#uni.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[.](#uni.int-5.sentence-1) #### [29.5.9.2.2](#uni.real) Class template uniform_real_distribution [[rand.dist.uni.real]](rand.dist.uni.real) [1](#uni.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≤xclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const uniform_real_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, uniform_real_distribution& x); };} [🔗](#lib:uniform_real_distribution,constructor) `explicit uniform_real_distribution(RealType a, RealType b = 1.0); ` [2](#uni.real-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4703) *Preconditions*: a ≤ b andb−a≤numeric_limits::max()[.](#uni.real-2.sentence-1) [3](#uni.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[.](#uni.real-3.sentence-1) [🔗](#lib:a,uniform_real_distribution) `result_type a() const; ` [4](#uni.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[.](#uni.real-4.sentence-1) [🔗](#lib:b,uniform_real_distribution) `result_type b() const; ` [5](#uni.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[.](#uni.real-5.sentence-1) #### [29.5.9.3](#bern) Bernoulli distributions [[rand.dist.bern]](rand.dist.bern) #### [29.5.9.3.1](#bern.bernoulli) Class bernoulli_distribution [[rand.dist.bern.bernoulli]](rand.dist.bern.bernoulli) [1](#bern.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)[.](#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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const bernoulli_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, bernoulli_distribution& x); };} [🔗](#lib:bernoulli_distribution,constructor) `explicit bernoulli_distribution(double p); ` [2](#bern.bernoulli-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4820) *Preconditions*: 0 ≤ p ≤ 1[.](#bern.bernoulli-2.sentence-1) [3](#bern.bernoulli-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4824) *Remarks*: p corresponds to the parameter of the distribution[.](#bern.bernoulli-3.sentence-1) [🔗](#lib:p,bernoulli_distribution) `double p() const; ` [4](#bern.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[.](#bern.bernoulli-4.sentence-1) #### [29.5.9.3.2](#bern.bin) Class template binomial_distribution [[rand.dist.bern.bin]](rand.dist.bern.bin) [1](#bern.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)[.](#bern.bin-1.sentence-1) P(i|t,p)=(ti)â‹piâ‹(1−p)t−i(29.5) [🔗](#lib:binomial_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const binomial_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, binomial_distribution& x); };} [🔗](#lib:binomial_distribution,constructor) `explicit binomial_distribution(IntType t, double p = 0.5); ` [2](#bern.bin-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4910) *Preconditions*: 0 ≤ p ≤ 1 and 0 ≤ t[.](#bern.bin-2.sentence-1) [3](#bern.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[.](#bern.bin-3.sentence-1) [🔗](#lib:t,binomial_distribution) `IntType t() const; ` [4](#bern.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[.](#bern.bin-4.sentence-1) [🔗](#lib:p,binomial_distribution) `double p() const; ` [5](#bern.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[.](#bern.bin-5.sentence-1) #### [29.5.9.3.3](#bern.geo) Class template geometric_distribution [[rand.dist.bern.geo]](rand.dist.bern.geo) [1](#bern.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)[.](#bern.geo-1.sentence-1) P(i|p)=pâ‹(1−p)i(29.6) [🔗](#lib:geometric_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const geometric_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, geometric_distribution& x); };} [🔗](#lib:geometric_distribution,constructor) `explicit geometric_distribution(double p); ` [2](#bern.geo-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5009) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const negative_binomial_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, negative_binomial_distribution& x); };} [🔗](#lib:negative_binomial_distribution,constructor) `explicit negative_binomial_distribution(IntType k, double p = 0.5); ` [2](#bern.negbin-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5103) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const poisson_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, poisson_distribution& x); };} [🔗](#lib:poisson_distribution,constructor) `explicit poisson_distribution(double mean); ` [2](#pois.poisson-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5218) *Preconditions*: 00 distributed according to the probability density function in Formula [29.9](#eq:rand.dist.pois.exp)[.](#pois.exp-1.sentence-1) p(x|λ)=λe−λx(29.9) [🔗](#lib:exponential_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const exponential_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, exponential_distribution& x); };} [🔗](#lib:exponential_distribution,constructor) `explicit exponential_distribution(RealType lambda); ` [2](#pois.exp-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5305) *Preconditions*: 00 distributed according to the probability density function in Formula [29.10](#eq:rand.dist.pois.gamma)[.](#pois.gamma-1.sentence-1) p(x|α,β)=e−x/ββαâ‹Î“(α)â‹xα−1(29.10) [🔗](#lib:gamma_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const gamma_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, gamma_distribution& x); };} [🔗](#lib:gamma_distribution,constructor) `explicit gamma_distribution(RealType alpha, RealType beta = 1.0); ` [2](#pois.gamma-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5394) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const weibull_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, weibull_distribution& x); };} [🔗](#lib:weibull_distribution,constructor) `explicit weibull_distribution(RealType a, RealType b = 1.0); ` [2](#pois.weibull-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5497) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const extreme_value_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, extreme_value_distribution& x); };} [🔗](#lib:extreme_value_distribution,constructor) `explicit extreme_value_distribution(RealType a, RealType b = 1.0); ` [2](#pois.extreme-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5610) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const normal_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, normal_distribution& x); };} [🔗](#lib:normal_distribution,constructor) `explicit normal_distribution(RealType mean, RealType stddev = 1.0); ` [2](#norm.normal-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5733) *Preconditions*: 00 distributed according to the probability density function in Formula [29.14](#eq:rand.dist.norm.lognormal)[.](#norm.lognormal-1.sentence-1) p(x|m,s)=1sx√2πâ‹exp(−(lnx−m)22s2)(29.14) [🔗](#lib:lognormal_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const lognormal_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, lognormal_distribution& x); };} [🔗](#lib:lognormal_distribution,constructor) `explicit lognormal_distribution(RealType m, RealType s = 1.0); ` [2](#norm.lognormal-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5836) *Preconditions*: 00 distributed according to the probability density function in Formula [29.15](#eq:rand.dist.norm.chisq)[.](#norm.chisq-1.sentence-1) p(x|n)=x(n/2)−1â‹e−x/2Γ(n/2)â‹2n/2(29.15) [🔗](#lib:chi_squared_distribution_) namespace std {templateclass 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const chi_squared_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, chi_squared_distribution& x); };} [🔗](#lib:chi_squared_distribution,constructor) `explicit chi_squared_distribution(RealType n); ` [2](#norm.chisq-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5936) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const cauchy_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, cauchy_distribution& x); };} [🔗](#lib:cauchy_distribution,constructor) `explicit cauchy_distribution(RealType a, RealType b = 1.0); ` [2](#norm.cauchy-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6025) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const fisher_f_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, fisher_f_distribution& x); };} [🔗](#lib:fisher_f_distribution,constructor) `explicit fisher_f_distribution(RealType m, RealType n = 1); ` [2](#norm.f-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6129) *Preconditions*: 0class 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 result_type operator()(URBG& g); template 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 extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const student_t_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, student_t_distribution& x); };} [🔗](#lib:student_t_distribution,constructor) `explicit student_t_distribution(RealType n); ` [2](#norm.t-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6231) *Preconditions*: 0class discrete_distribution {public:// typesusing result_type = IntType; using param_type = *unspecified*; // constructor and reset functions discrete_distribution(); template discrete_distribution(InputIterator firstW, InputIterator lastW); discrete_distribution(initializer_list wl); template 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 result_type operator()(URBG& g); template result_type operator()(URBG& g, const param_type& parm); // property functions vector probabilities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; // inserters and extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const discrete_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, discrete_distribution& x); };} [🔗](#lib:discrete_distribution,constructor) `discrete_distribution(); ` [3](#samp.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[.](#samp.discrete-3.sentence-1) [*Note [1](#samp.discrete-note-1)*: Such an object will always deliver the value 0[.](#samp.discrete-3.sentence-2) — *end note*] [🔗](#lib:discrete_distribution,constructor_) `template discrete_distribution(InputIterator firstW, InputIterator lastW); ` [4](#samp.discrete-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6363) *Mandates*: is_convertible_v​::​value_type,double> is true[.](#samp.discrete-4.sentence-1) [5](#samp.discrete-5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6368) *Preconditions*: InputIterator meets the [*Cpp17InputIterator*](input.iterators#:Cpp17InputIterator "24.3.5.3 Input iterators [input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3 Input iterators"))[.](#samp.discrete-5.sentence-1) If firstW == lastW, let n=1 and w0=1[.](#samp.discrete-5.sentence-2) Otherwise, [firstW, lastW) forms a sequence w of length n>0[.](#samp.discrete-5.sentence-3) [6](#samp.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)[.](#samp.discrete-6.sentence-1) [🔗](#lib:discrete_distribution,constructor__) `discrete_distribution(initializer_list wl); ` [7](#samp.discrete-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6391) *Effects*: Same as discrete_distribution(wl.begin(), wl.end())[.](#samp.discrete-7.sentence-1) [🔗](#lib:discrete_distribution,constructor___) `template discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); ` [8](#samp.discrete-8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6403) *Mandates*: is_invocable_r_v is true[.](#samp.discrete-8.sentence-1) [9](#samp.discrete-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6407) *Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#samp.discrete-9.sentence-1) The relation 0<δ=(xmax−xmin)/n holds[.](#samp.discrete-9.sentence-2) [10](#samp.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[.](#samp.discrete-10.sentence-1) Otherwise, let wk=fw(xmin+kâ‹Î´+δ/2) for k=0,…,n−1[.](#samp.discrete-10.sentence-2) [11](#samp.discrete-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6425) *Complexity*: The number of invocations of fw does not exceed n[.](#samp.discrete-11.sentence-1) [🔗](#lib:probabilities,discrete_distribution) `vector probabilities() const; ` [12](#samp.discrete-12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6436) *Returns*: A vector whose size member returns n and whose operator[] member returns pk when invoked with argument k for k=0,…,n−1[.](#samp.discrete-12.sentence-1) #### [29.5.9.6.2](#samp.pconst) Class template piecewise_constant_distribution [[rand.dist.samp.pconst]](rand.dist.samp.pconst) [1](#samp.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≤xclass piecewise_constant_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_constant_distribution(); template piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template piecewise_constant_distribution(initializer_list bl, UnaryOperation fw); template 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 result_type operator()(URBG& g); template result_type operator()(URBG& g, const param_type& parm); // property functions vector intervals() const; vector densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; // inserters and extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const piecewise_constant_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, piecewise_constant_distribution& x); };} [🔗](#lib:piecewise_constant_distribution,constructor) `piecewise_constant_distribution(); ` [3](#samp.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[.](#samp.pconst-3.sentence-1) [🔗](#lib:piecewise_constant_distribution,constructor_) `template piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); ` [4](#samp.pconst-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6556) *Mandates*: Both of - [(4.1)](#samp.pconst-4.1) is_convertible_v​::​value_type, double> - [(4.2)](#samp.pconst-4.2) is_convertible_v​::​value_type, double> are true[.](#samp.pconst-4.sentence-1) [5](#samp.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.3 Input iterators [input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3 Input iterators"))[.](#samp.pconst-5.sentence-1) If firstB == lastB or ++firstB == lastB, let n=1, w0=1, b0=0, and b1=1[.](#samp.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[.](#samp.pconst-5.sentence-3) [6](#samp.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[.](#samp.pconst-6.sentence-1) [🔗](#lib:piecewise_constant_distribution,constructor__) `template piecewise_constant_distribution(initializer_list bl, UnaryOperation fw); ` [7](#samp.pconst-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6597) *Mandates*: is_invocable_r_v is true[.](#samp.pconst-7.sentence-1) [8](#samp.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[.](#samp.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[.](#samp.pconst-8.sentence-2) [9](#samp.pconst-9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6618) *Complexity*: The number of invocations of fw does not exceed n[.](#samp.pconst-9.sentence-1) [🔗](#lib:piecewise_constant_distribution,constructor___) `template piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); ` [10](#samp.pconst-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6631) *Mandates*: is_invocable_r_v is true[.](#samp.pconst-10.sentence-1) [11](#samp.pconst-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6635) *Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#samp.pconst-11.sentence-1) The relation 0<δ=(xmax−xmin)/n holds[.](#samp.pconst-11.sentence-2) [12](#samp.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[.](#samp.pconst-12.sentence-1) [13](#samp.pconst-13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6649) *Complexity*: The number of invocations of fw does not exceed n[.](#samp.pconst-13.sentence-1) [🔗](#lib:intervals,piecewise_constant_distribution) `vector intervals() const; ` [14](#samp.pconst-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6660) *Returns*: A vector whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#samp.pconst-14.sentence-1) [🔗](#lib:densities,piecewise_constant_distribution) `vector densities() const; ` [15](#samp.pconst-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6674) *Returns*: A vector whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n−1[.](#samp.pconst-15.sentence-1) #### [29.5.9.6.3](#samp.plinear) Class template piecewise_linear_distribution [[rand.dist.samp.plinear]](rand.dist.samp.plinear) [1](#samp.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≤xclass piecewise_linear_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructor and reset functions piecewise_linear_distribution(); template piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template piecewise_linear_distribution(initializer_list bl, UnaryOperation fw); template 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 result_type operator()(URBG& g); template result_type operator()(URBG& g, const param_type& parm); // property functions vector intervals() const; vector densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; // inserters and extractorstemplatefriend basic_ostream&operator<<(basic_ostream& os, const piecewise_linear_distribution& x); templatefriend basic_istream&operator>>(basic_istream& is, piecewise_linear_distribution& x); };} [🔗](#lib:piecewise_linear_distribution,constructor) `piecewise_linear_distribution(); ` [3](#samp.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[.](#samp.plinear-3.sentence-1) [🔗](#lib:piecewise_linear_distribution,constructor_) `template piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); ` [4](#samp.plinear-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6791) *Mandates*: Both of - [(4.1)](#samp.plinear-4.1) is_convertible_v​::​value_type, double> - [(4.2)](#samp.plinear-4.2) is_convertible_v​::​value_type, double> are true[.](#samp.plinear-4.sentence-1) [5](#samp.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.3 Input iterators [input.iterators]") requirements ([[input.iterators]](input.iterators "24.3.5.3 Input iterators"))[.](#samp.plinear-5.sentence-1) If firstB == lastB or ++firstB == lastB, let n=1, ρ0=ρ1=1, b0=0, and b1=1[.](#samp.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[.](#samp.plinear-5.sentence-3) [6](#samp.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[.](#samp.plinear-6.sentence-1) [🔗](#lib:piecewise_linear_distribution,constructor__) `template piecewise_linear_distribution(initializer_list bl, UnaryOperation fw); ` [7](#samp.plinear-7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6832) *Mandates*: is_invocable_r_v is true[.](#samp.plinear-7.sentence-1) [8](#samp.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[.](#samp.plinear-8.sentence-1) Otherwise, let [bl.begin(), bl.end()) form a sequence b0,…,bn, and let wk=fw(bk) for k=0,…,n[.](#samp.plinear-8.sentence-2) [9](#samp.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[.](#samp.plinear-9.sentence-1) [🔗](#lib:piecewise_linear_distribution,constructor___) `template piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); ` [10](#samp.plinear-10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6866) *Mandates*: is_invocable_r_v is true[.](#samp.plinear-10.sentence-1) [11](#samp.plinear-11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6870) *Preconditions*: If nw=0, let n=1, otherwise let n=nw[.](#samp.plinear-11.sentence-1) The relation 0<δ=(xmax−xmin)/n holds[.](#samp.plinear-11.sentence-2) [12](#samp.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[.](#samp.plinear-12.sentence-1) [13](#samp.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[.](#samp.plinear-13.sentence-1) [🔗](#lib:intervals,piecewise_linear_distribution) `vector intervals() const; ` [14](#samp.plinear-14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6895) *Returns*: A vector whose size member returns n+1 and whose operator[] member returns bk when invoked with argument k for k=0,…,n[.](#samp.plinear-14.sentence-1) [🔗](#lib:densities,piecewise_linear_distribution) `vector densities() const; ` [15](#samp.plinear-15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6909) *Returns*: A vector whose size member returns n and whose operator[] member returns ρk when invoked with argument k for k=0,…,n[.](#samp.plinear-15.sentence-1)