[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 {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](#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â¤x<b,
distributed according to
the constant probability density function in Formula [29.3](#eq:rand.dist.uni.real)[.](#uni.real-1.sentence-1)

p(x|a,b)=1/(bâa)(29.3)

[*Note [1](#uni.real-note-1)*:

This implies that p(x | a,b) is undefined when a == b[.](#uni.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](#uni.real-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4703)

*Preconditions*: a â¤ b andbâaâ¤numeric_limits<RealType>::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<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](#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 {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](#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 {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](#bern.geo-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5009)

*Preconditions*: 0<p<1[.](#bern.geo-2.sentence-1)

[3](#bern.geo-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5013)

*Remarks*: p corresponds to the parameter of the distribution[.](#bern.geo-3.sentence-1)

[ð](#lib:p,geometric_distribution)

`double p() const;
`

[4](#bern.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[.](#bern.geo-4.sentence-1)

#### [29.5.9.3.4](#bern.negbin) Class template negative_binomial_distribution [[rand.dist.bern.negbin]](rand.dist.bern.negbin)

[1](#bern.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)[.](#bern.negbin-1.sentence-1)

P(i|k,p)=(k+iâ1i)âpkâ(1âp)i(29.7)

[*Note [1](#bern.negbin-note-1)*:

This implies that P(i | k,p) is undefined when p == 1[.](#bern.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](#bern.negbin-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5103)

*Preconditions*: 0<pâ¤1 and 0<k[.](#bern.negbin-2.sentence-1)

[3](#bern.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[.](#bern.negbin-3.sentence-1)

[ð](#lib:k,negative_binomial_distribution)

`IntType k() const;
`

[4](#bern.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[.](#bern.negbin-4.sentence-1)

[ð](#lib:p,negative_binomial_distribution)

`double p() const;
`

[5](#bern.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[.](#bern.negbin-5.sentence-1)

#### [29.5.9.4](#pois) Poisson distributions [[rand.dist.pois]](rand.dist.pois)

#### [29.5.9.4.1](#pois.poisson) Class template poisson_distribution [[rand.dist.pois.poisson]](rand.dist.pois.poisson)

[1](#pois.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)[.](#pois.poisson-1.sentence-1)

P(i|Î¼)=eâÎ¼Î¼ii!(29.8)

The distribution parameter Î¼ is also known as this distribution's [*mean*](#def:mean)[.](#pois.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](#pois.poisson-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5218)

*Preconditions*: 0<mean[.](#pois.poisson-2.sentence-1)

[3](#pois.poisson-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5222)

*Remarks*: mean corresponds to the parameter of the distribution[.](#pois.poisson-3.sentence-1)

[ð](#lib:mean,poisson_distribution)

`double mean() const;
`

[4](#pois.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[.](#pois.poisson-4.sentence-1)

#### [29.5.9.4.2](#pois.exp) Class template exponential_distribution [[rand.dist.pois.exp]](rand.dist.pois.exp)

[1](#pois.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)[.](#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](#pois.exp-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5305)

*Preconditions*: 0<lambda[.](#pois.exp-2.sentence-1)

[3](#pois.exp-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5309)

*Remarks*: lambda corresponds to the parameter of the distribution[.](#pois.exp-3.sentence-1)

[ð](#lib:lambda,exponential_distribution)

`RealType lambda() const;
`

[4](#pois.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[.](#pois.exp-4.sentence-1)

#### [29.5.9.4.3](#pois.gamma) Class template gamma_distribution [[rand.dist.pois.gamma]](rand.dist.pois.gamma)

[1](#pois.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)[.](#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](#pois.gamma-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5394)

*Preconditions*: 0<alpha and 0<beta[.](#pois.gamma-2.sentence-1)

[3](#pois.gamma-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5398)

*Remarks*: alpha and beta correspond to the parameters of the distribution[.](#pois.gamma-3.sentence-1)

[ð](#lib:alpha,gamma_distribution)

`RealType alpha() const;
`

[4](#pois.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[.](#pois.gamma-4.sentence-1)

[ð](#lib:beta,gamma_distribution)

`RealType beta() const;
`

[5](#pois.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[.](#pois.gamma-5.sentence-1)

#### [29.5.9.4.4](#pois.weibull) Class template weibull_distribution [[rand.dist.pois.weibull]](rand.dist.pois.weibull)

[1](#pois.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)[.](#pois.weibull-1.sentence-1)

p(x|a,b)=abâ(xb)aâ1â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](#pois.weibull-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5497)

*Preconditions*: 0<a and 0<b[.](#pois.weibull-2.sentence-1)

[3](#pois.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[.](#pois.weibull-3.sentence-1)

[ð](#lib:a,weibull_distribution)

`RealType a() const;
`

[4](#pois.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[.](#pois.weibull-4.sentence-1)

[ð](#lib:b,weibull_distribution)

`RealType b() const;
`

[5](#pois.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[.](#pois.weibull-5.sentence-1)

#### [29.5.9.4.5](#pois.extreme) Class template extreme_value_distribution [[rand.dist.pois.extreme]](rand.dist.pois.extreme)

[1](#pois.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)[.](#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](#pois.extreme-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5610)

*Preconditions*: 0<b[.](#pois.extreme-2.sentence-1)

[3](#pois.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[.](#pois.extreme-3.sentence-1)

[ð](#lib:a,extreme_value_distribution)

`RealType a() const;
`

[4](#pois.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[.](#pois.extreme-4.sentence-1)

[ð](#lib:b,extreme_value_distribution)

`RealType b() const;
`

[5](#pois.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[.](#pois.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)

#### [29.5.9.5](#norm) Normal distributions [[rand.dist.norm]](rand.dist.norm)

#### [29.5.9.5.1](#norm.normal) Class template normal_distribution [[rand.dist.norm.normal]](rand.dist.norm.normal)

[1](#norm.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)[.](#norm.normal-1.sentence-1)

p(x|Î¼,Ï)=1Ïâ2Ïâ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)[.](#norm.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](#norm.normal-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5733)

*Preconditions*: 0<stddev[.](#norm.normal-2.sentence-1)

[3](#norm.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[.](#norm.normal-3.sentence-1)

[ð](#lib:mean,normal_distribution)

`RealType mean() const;
`

[4](#norm.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[.](#norm.normal-4.sentence-1)

[ð](#lib:stddev,normal_distribution)

`RealType stddev() const;
`

[5](#norm.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[.](#norm.normal-5.sentence-1)

#### [29.5.9.5.2](#norm.lognormal) Class template lognormal_distribution [[rand.dist.norm.lognormal]](rand.dist.norm.lognormal)

[1](#norm.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)[.](#norm.lognormal-1.sentence-1)

p(x|m,s)=1sxâ2Ïâ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](#norm.lognormal-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5836)

*Preconditions*: 0<s[.](#norm.lognormal-2.sentence-1)

[3](#norm.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[.](#norm.lognormal-3.sentence-1)

[ð](#lib:m,lognormal_distribution)

`RealType m() const;
`

[4](#norm.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[.](#norm.lognormal-4.sentence-1)

[ð](#lib:s,lognormal_distribution)

`RealType s() const;
`

[5](#norm.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[.](#norm.lognormal-5.sentence-1)

#### [29.5.9.5.3](#norm.chisq) Class template chi_squared_distribution [[rand.dist.norm.chisq]](rand.dist.norm.chisq)

[1](#norm.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)[.](#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 {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](#norm.chisq-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5936)

*Preconditions*: 0<n[.](#norm.chisq-2.sentence-1)

[3](#norm.chisq-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L5940)

*Remarks*: n corresponds to the parameter of the distribution[.](#norm.chisq-3.sentence-1)

[ð](#lib:n,chi_squared_distribution)

`RealType n() const;
`

[4](#norm.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[.](#norm.chisq-4.sentence-1)

#### [29.5.9.5.4](#norm.cauchy) Class template cauchy_distribution [[rand.dist.norm.cauchy]](rand.dist.norm.cauchy)

[1](#norm.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)[.](#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](#norm.cauchy-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6025)

*Preconditions*: 0<b[.](#norm.cauchy-2.sentence-1)

[3](#norm.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[.](#norm.cauchy-3.sentence-1)

[ð](#lib:a,cauchy_distribution)

`RealType a() const;
`

[4](#norm.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[.](#norm.cauchy-4.sentence-1)

[ð](#lib:b,cauchy_distribution)

`RealType b() const;
`

[5](#norm.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[.](#norm.cauchy-5.sentence-1)

#### [29.5.9.5.5](#norm.f) Class template fisher_f_distribution [[rand.dist.norm.f]](rand.dist.norm.f)

[1](#norm.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)[.](#norm.f-1.sentence-1)

p(x|m,n)=Î((m+n)/2)Î(m/2)Î(n/2)â(mn)m/2âx(m/2)â1â(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](#norm.f-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6129)

*Preconditions*: 0<m and 0<n[.](#norm.f-2.sentence-1)

[3](#norm.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[.](#norm.f-3.sentence-1)

[ð](#lib:m,fisher_f_distribution)

`RealType m() const;
`

[4](#norm.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[.](#norm.f-4.sentence-1)

[ð](#lib:n,fisher_f_distribution)

`RealType n() const;
`

[5](#norm.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[.](#norm.f-5.sentence-1)

#### [29.5.9.5.6](#norm.t) Class template student_t_distribution [[rand.dist.norm.t]](rand.dist.norm.t)

[1](#norm.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)[.](#norm.t-1.sentence-1)

p(x|n)=1â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](#norm.t-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6231)

*Preconditions*: 0<n[.](#norm.t-2.sentence-1)

[3](#norm.t-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6235)

*Remarks*: n corresponds to the parameter of the distribution[.](#norm.t-3.sentence-1)

[ð](#lib:mean,student_t_distribution)

`RealType n() const;
`

[4](#norm.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[.](#norm.t-4.sentence-1)

#### [29.5.9.6](#samp) Sampling distributions [[rand.dist.samp]](rand.dist.samp)

#### [29.5.9.6.1](#samp.discrete) Class template discrete_distribution [[rand.dist.samp.discrete]](rand.dist.samp.discrete)

[1](#samp.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)[.](#samp.discrete-1.sentence-1)

P(i|p0,â¦,pnâ1)=pi(29.19)

[2](#samp.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[.](#samp.discrete-2.sentence-1)

Moreover, the following relation shall hold:0<S=w0+â¯+wnâ1[.](#samp.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](#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<class InputIterator>
  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<iterator_traits<InputIterator>​::​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<double> 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<class UnaryOperation>
  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<double, UnaryOperation&, double> 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<double> probabilities() const;
`

[12](#samp.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[.](#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â¤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)[.](#samp.pconst-1.sentence-1)

p(x|b0,â¦,bn,Ï0,â¦,Ïnâ1)=ÏiÂ , forÂ biâ¤x<bi+1(29.20)

[2](#samp.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[.](#samp.pconst-2.sentence-1)

Unless specified otherwise,
the remaining n distribution parameters are calculated as:  
Ïk=wkSâ(bk+1âbk)Â 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[.](#samp.pconst-2.sentence-2)

Moreover, the following relation shall hold: 0<S=w0+â¯+wnâ1[.](#samp.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](#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<class InputIteratorB, class InputIteratorW>
  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<iterator_traits<InputIteratorB>​::​value_type, double>

- [(4.2)](#samp.pconst-4.2)

is_convertible_v<iterator_traits<InputIteratorW>​::​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<class UnaryOperation>
  piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`

[7](#samp.pconst-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6597)

*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> 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<class UnaryOperation>
  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<double, UnaryOperation&, double> 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<result_type> intervals() const;
`

[14](#samp.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[.](#samp.pconst-14.sentence-1)

[ð](#lib:densities,piecewise_constant_distribution)

`vector<result_type> densities() const;
`

[15](#samp.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[.](#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â¤x<bn,
distributed over each subinterval[bi,bi+1) according to the probability density function in Formula [29.21](#eq:rand.dist.samp.plinear)[.](#samp.plinear-1.sentence-1)

p(x|b0,â¦,bn,Ï0,â¦,Ïn)=Ïiâbi+1âxbi+1âbi+Ïi+1âxâbibi+1âbiÂ , forÂ biâ¤x<bi+1.(29.21)

[2](#samp.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[.](#samp.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[.](#samp.plinear-2.sentence-2)

Moreover, the following relation shall hold:  
0<S=12ânâ1âk=0(wk+wk+1)â(bk+1âbk)Â [.](#samp.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](#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<class InputIteratorB, class InputIteratorW>
  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<iterator_traits<InputIteratorB>​::​value_type, double>

- [(4.2)](#samp.plinear-4.2)

is_convertible_v<iterator_traits<InputIteratorW>​::​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<class UnaryOperation>
  piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
`

[7](#samp.plinear-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L6832)

*Mandates*: is_invocable_r_v<double, UnaryOperation&, double> 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<class UnaryOperation>
  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<double, UnaryOperation&, double> 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<result_type> intervals() const;
`

[14](#samp.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[.](#samp.plinear-14.sentence-1)

[ð](#lib:densities,piecewise_linear_distribution)

`vector<result_type> densities() const;
`

[15](#samp.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[.](#samp.plinear-15.sentence-1)
