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 a normal_distribution random number distribution __x into the output stream __os.
  • template<typename _RealType1 > bool operator== (const std::normal_distribution< _RealType1 > &__d1, const std::normal_distribution< _RealType1 > &__d2) β€” return true if 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 a normal_distribution random number distribution __x from 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.


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 β€” a normal_distribution random number distribution.

Returns

  • The output stream with the state of __x inserted 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 β€” a normal_distribution random number generator engine.

Returns

  • The input stream with __x extracted 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