[rand.dist.norm]

# 29 Numerics library [[numerics]](./#numerics)

## 29.5 Random number generation [[rand]](rand#dist.norm)

### 29.5.9 Random number distribution class templates [[rand.dist]](rand.dist#norm)

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

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

[1](#normal-1)

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

A normal_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.13](#eq:rand.dist.norm.normal)[.](#normal-1.sentence-1)

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

[ð](#lib:normal_distribution_)

namespace std {template<class RealType = double>class normal_distribution {public:// typesusing result_type = RealType; using param_type = *unspecified*; // constructors and reset functions normal_distribution() : normal_distribution(0.0) {}explicit normal_distribution(RealType mean, RealType stddev = 1.0); explicit normal_distribution(const param_type& parm); void reset(); // equality operatorsfriend bool operator==(const normal_distribution& x, const normal_distribution& y); // generating functionstemplate<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); // property functions RealType mean() const;
 RealType stddev() const;
 param_type param() const; void param(const param_type& parm);
 result_type min() const;
 result_type max() const; // inserters and extractorstemplate<class charT, class traits>friend basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const normal_distribution& x); template<class charT, class traits>friend basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is, normal_distribution& x); };}

[ð](#lib:normal_distribution,constructor)

`explicit normal_distribution(RealType mean, RealType stddev = 1.0);
`

[2](#normal-2)

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

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

[3](#normal-3)

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

*Remarks*: mean and stddev correspond to the respective parameters of the distribution[.](#normal-3.sentence-1)

[ð](#lib:mean,normal_distribution)

`RealType mean() const;
`

[4](#normal-4)

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

*Returns*: The value of the mean parameter
 with which the object was constructed[.](#normal-4.sentence-1)

[ð](#lib:stddev,normal_distribution)

`RealType stddev() const;
`

[5](#normal-5)

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

*Returns*: The value of the stddev parameter
 with which the object was constructed[.](#normal-5.sentence-1)

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

[1](#lognormal-1)

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

A lognormal_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.14](#eq:rand.dist.norm.lognormal)[.](#lognormal-1.sentence-1)

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

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

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

[3](#lognormal-3)

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

*Remarks*: m and s correspond to the respective parameters of the distribution[.](#lognormal-3.sentence-1)

[ð](#lib:m,lognormal_distribution)

`RealType m() const;
`

[4](#lognormal-4)

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

*Returns*: The value of the m parameter
 with which the object was constructed[.](#lognormal-4.sentence-1)

[ð](#lib:s,lognormal_distribution)

`RealType s() const;
`

[5](#lognormal-5)

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

*Returns*: The value of the s parameter
 with which the object was constructed[.](#lognormal-5.sentence-1)

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

[1](#chisq-1)

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

A chi_squared_distribution random number distribution
produces random numbers x>0 distributed according to
the probability density function in Formula [29.15](#eq:rand.dist.norm.chisq)[.](#chisq-1.sentence-1)

p(x|n)=x(n/2)â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](#chisq-2)

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

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

[3](#chisq-3)

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

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

[ð](#lib:n,chi_squared_distribution)

`RealType n() const;
`

[4](#chisq-4)

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

*Returns*: The value of the n parameter
 with which the object was constructed[.](#chisq-4.sentence-1)

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

[1](#cauchy-1)

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

A cauchy_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.16](#eq:rand.dist.norm.cauchy)[.](#cauchy-1.sentence-1)

p(x|a,b)=(Ïb(1+(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](#cauchy-2)

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

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

[3](#cauchy-3)

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

*Remarks*: a and b correspond to the respective parameters of the distribution[.](#cauchy-3.sentence-1)

[ð](#lib:a,cauchy_distribution)

`RealType a() const;
`

[4](#cauchy-4)

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

*Returns*: The value of the a parameter
 with which the object was constructed[.](#cauchy-4.sentence-1)

[ð](#lib:b,cauchy_distribution)

`RealType b() const;
`

[5](#cauchy-5)

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

*Returns*: The value of the b parameter
 with which the object was constructed[.](#cauchy-5.sentence-1)

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

[1](#f-1)

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

A fisher_f_distribution random number distribution
produces random numbers x â¥ 0 distributed according to
the probability density function in Formula [29.17](#eq:rand.dist.norm.f)[.](#f-1.sentence-1)

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

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

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

[3](#f-3)

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

*Remarks*: m and n correspond to the respective parameters of the distribution[.](#f-3.sentence-1)

[ð](#lib:m,fisher_f_distribution)

`RealType m() const;
`

[4](#f-4)

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

*Returns*: The value of the m parameter
 with which the object was constructed[.](#f-4.sentence-1)

[ð](#lib:n,fisher_f_distribution)

`RealType n() const;
`

[5](#f-5)

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

*Returns*: The value of the n parameter
 with which the object was constructed[.](#f-5.sentence-1)

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

[1](#t-1)

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

A student_t_distribution random number distribution
produces random numbers x distributed according to
the probability density function in Formula [29.18](#eq:rand.dist.norm.t)[.](#t-1.sentence-1)

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

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

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

[3](#t-3)

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

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

[ð](#lib:mean,student_t_distribution)

`RealType n() const;
`

[4](#t-4)

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

*Returns*: The value of the n parameter
 with which the object was constructed[.](#t-4.sentence-1)
