16 KiB
[rand.dist.norm]
29 Numerics library [numerics]
29.5 Random number generation [rand]
29.5.9 Random number distribution class templates [rand.dist]
29.5.9.5 Normal distributions [rand.dist.norm]
29.5.9.5.1 Class template normal_distribution [rand.dist.norm.normal]
A normal_distribution random number distribution produces random numbers x distributed according to the probability density function in Formula 29.13.
p(x|μ,Ï)=1Ïâ2Ïâexp(â(xâμ)22Ï2)(29.13)
The distribution parameters μ and Ï are also known as this distribution's mean and standard deviation.
namespace std {templateclass 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 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); };}
explicit normal_distribution(RealType mean, RealType stddev = 1.0);
Preconditions: 0<stddev.
Remarks: mean and stddev correspond to the respective parameters of the distribution.
RealType mean() const;
Returns: The value of the mean parameter with which the object was constructed.
RealType stddev() const;
Returns: The value of the stddev parameter with which the object was constructed.
29.5.9.5.2 Class template lognormal_distribution [rand.dist.norm.lognormal]
A lognormal_distribution random number distribution produces random numbers x>0 distributed according to the probability density function in Formula 29.14.
p(x|m,s)=1sxâ2Ïâexp(â(lnxâm)22s2)(29.14)
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 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); };}
explicit lognormal_distribution(RealType m, RealType s = 1.0);
Preconditions: 0<s.
Remarks: m and s correspond to the respective parameters of the distribution.
RealType m() const;
Returns: The value of the m parameter with which the object was constructed.
RealType s() const;
Returns: The value of the s parameter with which the object was constructed.
29.5.9.5.3 Class template chi_squared_distribution [rand.dist.norm.chisq]
A chi_squared_distribution random number distribution produces random numbers x>0 distributed according to the probability density function in Formula 29.15.
p(x|n)=x(n/2)â1âeâx/2Î(n/2)â2n/2(29.15)
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 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); };}
explicit chi_squared_distribution(RealType n);
Preconditions: 0<n.
Remarks: n corresponds to the parameter of the distribution.
RealType n() const;
Returns: The value of the n parameter with which the object was constructed.
29.5.9.5.4 Class template cauchy_distribution [rand.dist.norm.cauchy]
A cauchy_distribution random number distribution produces random numbers x distributed according to the probability density function in Formula 29.16.
p(x|a,b)=(Ïb(1+(xâab)2))â1(29.16)
namespace std {templateclass 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 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); };}
explicit cauchy_distribution(RealType a, RealType b = 1.0);
Preconditions: 0<b.
Remarks: a and b correspond to the respective parameters of the distribution.
RealType a() const;
Returns: The value of the a parameter with which the object was constructed.
RealType b() const;
Returns: The value of the b parameter with which the object was constructed.
29.5.9.5.5 Class template fisher_f_distribution [rand.dist.norm.f]
A fisher_f_distribution random number distribution produces random numbers x ⥠0 distributed according to the probability density function in Formula 29.17.
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)
namespace std {templateclass 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 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); };}
explicit fisher_f_distribution(RealType m, RealType n = 1);
Preconditions: 0<m and 0<n.
Remarks: m and n correspond to the respective parameters of the distribution.
RealType m() const;
Returns: The value of the m parameter with which the object was constructed.
RealType n() const;
Returns: The value of the n parameter with which the object was constructed.
29.5.9.5.6 Class template student_t_distribution [rand.dist.norm.t]
A student_t_distribution random number distribution produces random numbers x distributed according to the probability density function in Formula 29.18.
p(x|n)=1ânÏâÎ((n+1)/2)Î(n/2)â(1+x2n)â(n+1)/2(29.18)
namespace std {templateclass 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 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); };}
explicit student_t_distribution(RealType n);
Preconditions: 0<n.
Remarks: n corresponds to the parameter of the distribution.
RealType n() const;
Returns: The value of the n parameter with which the object was constructed.