STD::DISCRETE_DISTRIBUTION(3cxx)
π NAME π
std::discrete_distribution< _IntType > β bestie, this is the 3cxx manual page for a discrete_distribution random number distribution. It's giving C++ class template realness, not a CLI tool, but the lore is still iconic. π
π¦ SYNOPSIS π¦
#include <random>
π Classes π
struct param_type
π Public Types π
typedef _IntType result_type
β¨ Public Member Functions β¨
template<typename _InputIterator > discrete_distribution (_InputIterator __wbegin, _InputIterator __wend)β constructor overload, no extra deets here.discrete_distribution (const param_type &__p)β constructor overload, periodt.discrete_distribution (initializer_list< double > __wl)β constructor overload from an initializer list.template<typename _Func > discrete_distribution (size_t __nw, double __xmin, double __xmax, _Func __fw)β constructor overload with a function vibe.template<typename _ForwardIterator , typename _UniformRandomNumberGenerator > void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng)β generate internals, listed exactly as the page says.template<typename _ForwardIterator , typename _UniformRandomNumberGenerator > void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng, const param_type &__p)β same energy, now withconst param_type &__p.template<typename _UniformRandomNumberGenerator > void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p)β pointer-style generate internals.result_type max () constβ returns the least upper bound value of the distribution.result_type min () constβ returns the greatest lower bound value of the distribution.template<typename _UniformRandomNumberGenerator > result_type operator() (_UniformRandomNumberGenerator &__urng)β generating functions.template<typename _UniformRandomNumberGenerator > result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)β the other generating-function overload.param_type param () constβ returns the parameter set of the distribution.void param (const param_type &__param)β sets the parameter set of the distribution.std::vector< double > probabilities () constβ returns the probabilities of the distribution.void reset ()β resets the distribution state.
π Friends π
template<typename _IntType1 , typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::discrete_distribution< _IntType1 > &__x)β inserts adiscrete_distributionrandom number distribution__xinto the output stream__os.bool operator== (const discrete_distribution &__d1, const discrete_distribution &__d2)β return true if two discrete distributions have the same parameters.template<typename _IntType1 , typename _CharT , typename _Traits > std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::discrete_distribution< _IntType1 > &__x)β extracts adiscrete_distributionrandom number distribution__xfrom the input stream__is.
π Detailed Description π
template<typename _IntType = int>
class std::discrete_distribution< _IntType >"A discrete_distribution random number distribution.
This distribution produces random numbers $ i, 0 i < n $, distributed according to the probability mass function $ p(i | p_0, ..., p_{n-1}) = p_i $.
Since: C++11
π§ Member Typedef Documentation π§
template<typename _IntType = int> typedef _IntType std::discrete_distribution< _IntType >::result_typeβ the type of the range of the distribution. π«
π₯ Member Function Documentation π₯
template<typename _IntType = int> result_type std::discrete_distribution< _IntType >::max () const [inline]β returns the least upper bound value of the distribution. Referencesstd::vector< _Tp, _Alloc >::empty(), andstd::vector< _Tp, _Alloc >::size().template<typename _IntType = int> result_type std::discrete_distribution< _IntType >::min () const [inline]β returns the greatest lower bound value of the distribution.template<typename _IntType = int> template<typename _UniformRandomNumberGenerator > result_type std::discrete_distribution< _IntType >::operator() (_UniformRandomNumberGenerator & __urng) [inline]β generating functions. Referencesstd::discrete_distribution< _IntType >::operator()(). Referenced bystd::discrete_distribution< _IntType >::operator()().template<typename _IntType = int> param_type std::discrete_distribution< _IntType >::param () const [inline]β returns the parameter set of the distribution.template<typename _IntType = int> void std::discrete_distribution< _IntType >::param (const param_type & __param) [inline]β sets the parameter set of the distribution.
Parameters
__paramβ the new parameter set of the distribution.
template<typename _IntType = int> std::vector< double > std::discrete_distribution< _IntType >::probabilities () const [inline]β returns the probabilities of the distribution. Referencesstd::vector< _Tp, _Alloc >::empty().template<typename _IntType = int> void std::discrete_distribution< _IntType >::reset () [inline]β resets the distribution state.
π«Ά Friends And Related Symbol Documentation π«Ά
template<typename _IntType = int> template<typename _IntType1 , typename _CharT , typename _Traits > std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > & __os, const std::discrete_distribution< _IntType1 > & __x) [friend]β inserts adiscrete_distributionrandom number distribution__xinto the output stream__os.
Parameters
__osβ an output stream.__xβ adiscrete_distributionrandom number distribution.
Returns The output stream with the state of __x inserted or in an error state.
template<typename _IntType = int> bool operator== (const discrete_distribution< _IntType > & __d1, const discrete_distribution< _IntType > & __d2) [friend]β return true if two discrete distributions have the same parameters. β¨template<typename _IntType = int> template<typename _IntType1 , typename _CharT , typename _Traits > std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > & __is, std::discrete_distribution< _IntType1 > & __x) [friend]β extracts adiscrete_distributionrandom number distribution__xfrom the input stream__is.
Parameters
__isβ an input stream.__xβ adiscrete_distributionrandom 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.
π cute sign-off: this whole thing lives in the libstdc++ 3cxx manual set, and the supplied footer has no separate date line, so Iβm not inventing one β no cap, bestie. bye and slay your random numbers π«Άπ
π¦ 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