STD::NORMAL_DISTRIBUTION(3cxx)
π std::normal_distribution< _RealType > β a normal continuous distribution for random numbers π
okay so bestie, this is a page from the libstdc++ manual, the 3cxx section (that's the C++ library manuals, iykyk). Sit down, grab a strawberry π, and let's get into it β no cap, it's actually so good.
β¨ NAME β¨
std::normal_distribution< _RealType > β a normal continuous distribution for random numbers. literally the bell curve, the icon, the moment. π
π¦ SYNOPSIS π¦
#include <random>
π Classes
struct param_type
πΈ Public Types
typedef _RealType result_type
π Public Member Functions
normal_distribution (const param_type &__p)normal_distribution (result_type __mean, result_type __stddev=result_type(1))template<typename _ForwardIterator , typename _UniformRandomNumberGenerator > void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng)template<typename _ForwardIterator , typename _UniformRandomNumberGenerator > void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng, const param_type &__p)template<typename _UniformRandomNumberGenerator > void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p)result_type max () constβ returns the least upper bound value of the distribution. the ceiling, basically β¨_RealType mean () constβ returns the mean of the distribution. the vibe center of the whole thing π―result_type min () constβ returns the greatest lower bound value of the distribution. the floor, bestie.template<typename _UniformRandomNumberGenerator > result_type operator() (_UniformRandomNumberGenerator &__urng)β generating functions. this is the one that actually makes numbers happen π₯template<typename _UniformRandomNumberGenerator > result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)param_type param () constβ returns the parameter set of the distribution.void param (const param_type &__param)β sets the parameter set of the distribution.void reset ()β resets the distribution state. a little refresh, a little cleanse π§_RealType stddev () constβ returns the standard deviation of the distribution.
π Friends
template<typename _RealType1 , typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::normal_distribution< _RealType1 > &__x)β inserts anormal_distributionrandom number distribution__xinto the output stream__os.template<typename _RealType1 > bool operator== (const std::normal_distribution< _RealType1 > &__d1, const std::normal_distribution< _RealType1 > &__d2)β returntrueif two normal distributions have the same parameters and the sequences that would be generated are equal.template<typename _RealType1 , typename _CharT , typename _Traits > std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::normal_distribution< _RealType1 > &__x)β extracts anormal_distributionrandom number distribution__xfrom the input stream__is.
π Detailed Description
template<typename _RealType = double>
class std::normal_distribution< _RealType >
"A normal continuous distribution for random numbers." πΈ
The formula for the normal probability density function is:
p(x|,ma) = ac{1}{ma t{2 i}}
e^{- ac{{x - }^ {2}}{2 ma ^ {2}} } ]
(yeah the formula rendering is a whole aesthetic, we don't question it π β it's verbatim from the page, keep it moving)
Since
- C++11
π«Ά Member Typedef Documentation
template<typename _RealType = double> typedef _RealType std::normal_distribution< _RealType >::result_type
The type of the range of the distribution. that's the whole typedef, slay.
π Constructor & Destructor Documentation
template<typename _RealType = double> std::normal_distribution< _RealType >::normal_distribution (result_type __mean, result_type __stddev = result_type(1)) [inline], [explicit]
Constructs a normal distribution with parameters $mean$ and standard deviation.
note the[inline]and[explicit]markers β they're part of the signature, don't come for me π«Ά
π₯ Member Function Documentation
template<typename _RealType = double> result_type std::normal_distribution< _RealType >::max () const [inline]
Returns the least upper bound value of the distribution.
References std::numeric_limits< _Tp >::max().
template<typename _RealType = double> _RealType std::normal_distribution< _RealType >::mean () const [inline]
Returns the mean of the distribution.
template<typename _RealType = double> result_type std::normal_distribution< _RealType >::min () const [inline]
Returns the greatest lower bound value of the distribution.
References std::numeric_limits< _Tp >::lowest().
template<typename _RealType = double> template<typename _UniformRandomNumberGenerator > result_type std::normal_distribution< _RealType >::operator() (_UniformRandomNumberGenerator & __urng) [inline]
Generating functions.
References std::normal_distribution< _RealType >::operator()().
Referenced by std::normal_distribution< _RealType >::operator()().
template<typename _RealType > template<typename _UniformRandomNumberGenerator > normal_distribution< _RealType >::result_type std::normal_distribution< _RealType >::operator() (_UniformRandomNumberGenerator & __urng, const param_type & __param)
Polar method due to Marsaglia. π₯
Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, New York, 1986, Ch. V, Sect. 4.4.
References std::log(), and std::sqrt().
template<typename _RealType = double> param_type std::normal_distribution< _RealType >::param () const [inline]
Returns the parameter set of the distribution.
template<typename _RealType = double> void std::normal_distribution< _RealType >::param (const param_type & __param) [inline]
Sets the parameter set of the distribution.
Parameters
__paramβ the new parameter set of the distribution.
template<typename _RealType = double> void std::normal_distribution< _RealType >::reset () [inline]
Resets the distribution state.
Referenced by std::lognormal_distribution< _RealType >::reset(), std::gamma_distribution< _RealType >::reset(), std::student_t_distribution< _RealType >::reset(), std::binomial_distribution< _IntType >::reset(), and std::poisson_distribution< _IntType >::reset().
template<typename _RealType = double> _RealType std::normal_distribution< _RealType >::stddev () const [inline]
Returns the standard deviation of the distribution.
π§ Friends And Related Symbol Documentation
template<typename _RealType = double> template<typename _RealType1 , typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > & __os, const std::normal_distribution< _RealType1 > & __x) [friend]
Inserts a normal_distribution random number distribution __x into the output stream __os.
Parameters
__osβ an output stream.__xβ anormal_distributionrandom number distribution.
Returns
- The output stream with the state of
__xinserted or in an error state.
template<typename _RealType = double> template<typename _RealType1 > bool operator== (const std::normal_distribution< _RealType1 > & __d1, const std::normal_distribution< _RealType1 > & __d2) [friend]
Return true if two normal distributions have the same parameters and the sequences that would be generated are equal.
template<typename _RealType = double> template<typename _RealType1 , typename _CharT , typename _Traits > std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > & __is, std::normal_distribution< _RealType1 > & __x) [friend]
Extracts a normal_distribution random number distribution __x from the input stream __is.
Parameters
__isβ an input stream.__xβ anormal_distributionrandom number generator engine.
Returns
- The input stream with
__xextracted or in an error state.
π Author
Generated automatically by Doxygen for libstdc++ from the source code. not a human author, a robot did this, and honestly? it ate. π
okay bestie that's the whole page, every flag and reference intact, no notes π«Ά this manual page is libstdc++'s std::normal_di...on< _RealType >(3cxx) β go forth and generate some beautifully normal random numbers, periodt. πβ¨ππ¦
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms