Files
2025-10-25 03:02:53 +03:00

16 KiB
Raw Permalink Blame History

[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]

1

#

A normal_distribution random number distribution produces random numbers x distributed according to the probability density function in Formula 29.13.

p(x|μ,σ)=1σ√€â‹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);

2

#

Preconditions: 0<stddev.

3

#

Remarks: mean and stddev correspond to the respective parameters of the distribution.

🔗

RealType mean() const;

4

#

Returns: The value of the mean parameter with which the object was constructed.

🔗

RealType stddev() const;

5

#

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]

1

#

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√€â‹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);

2

#

Preconditions: 0<s.

3

#

Remarks: m and s correspond to the respective parameters of the distribution.

🔗

RealType m() const;

4

#

Returns: The value of the m parameter with which the object was constructed.

🔗

RealType s() const;

5

#

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]

1

#

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)−‹ˆ’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);

2

#

Preconditions: 0<n.

3

#

Remarks: n corresponds to the parameter of the distribution.

🔗

RealType n() const;

4

#

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]

1

#

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);

2

#

Preconditions: 0<b.

3

#

Remarks: a and b correspond to the respective parameters of the distribution.

🔗

RealType a() const;

4

#

Returns: The value of the a parameter with which the object was constructed.

🔗

RealType b() const;

5

#

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]

1

#

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+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);

2

#

Preconditions: 0<m and 0<n.

3

#

Remarks: m and n correspond to the respective parameters of the distribution.

🔗

RealType m() const;

4

#

Returns: The value of the m parameter with which the object was constructed.

🔗

RealType n() const;

5

#

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]

1

#

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+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);

2

#

Preconditions: 0<n.

3

#

Remarks: n corresponds to the parameter of the distribution.

🔗

RealType n() const;

4

#

Returns: The value of the n parameter with which the object was constructed.