STD::BINOMIAL_DISTRIBUTION(3)
π std::binomial_distribution< _IntType > π
okay bestie, gather round, because we are reading a library functions manual page β the <pink>std::binom..._IntType >(3)</pink> one, no cap β and it's lowkey iconic. this is the page for std::binomial_distribution< _IntType >, a discrete binomial random number distribution. it's giving math girlie with a random number generator. periodt. π
β¨ NAME β¨
std::binomial_distribution< _IntType > β a discrete binomial random number distribution.
like, it hands you random numbers that follow a binomial distribution. that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
#include <random>
π§ Classes
struct param_type
π§ Public Types
typedef _IntType result_type
π§ Public Member Functions
binomial_distribution (_IntType __t, double __p=0.5)β construct one of these with atand an optionalpthat defaults to0.5binomial_distribution (const param_type &__p)β construct it from aparam_typeinsteadtemplate<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng)β fill the range[__f, __t)with generated values using__urngtemplate<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng, const param_type &__p)β same thing but with aparam_typehanded intemplate<typename _UniformRandomNumberGenerator> void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p)β and the pointer-flavoured version of thatresult_type max () constβ returns the least upper bound value of the distributionresult_type min () constβ returns the greatest lower bound value of the distributiontemplate<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng)β generating functions β¨template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)β generating functions, but you're choosing the params yourselfdouble p () constβ returns the distributionpparameterparam_type param () constβ returns the parameter set of the distributionvoid param (const param_type &__param)β sets the parameter set of the distributionvoid reset ()β resets the distribution state_IntType t () constβ returns the distributiontparameter
π§ Friends
template<typename _IntType1, typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::binomial_distribution< _IntType1 > &__x)β inserts abinomial_distributionrandom number distribution__xinto the output stream__osbool operator== (const binomial_distribution &__d1, const binomial_distribution &__d2)β returnstrueif two binomial distributions have the same parameters and the sequences that would be generated are equaltemplate<typename _IntType1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::binomial_distribution< _IntType1 > &__x)β extracts abinomial_distributionrandom number distribution__xfrom the input stream__is
π Detailed Description π
template<typename _IntType = int>
class std::binomial_distribution< _IntType >
a discrete binomial random number distribution. yes, that's the quote, and the source text right after it is a lil scrambled β it literally reads:
o
mhe formula for the binomial probability density function is $p(i|t,p) =
{} p^i (1 - p)^{t - i}$ where $t$ and $p$ are the parameters of the
distribution.
}
{
so the actual formula for the binomial probability density function is
$p(i|t,p) = {} p^i (1 - p)^{t - i}$
where t and p are the parameters of the distribution. π
Since: C++11 π
π«Ά Member Typedef Documentation π«Ά
π template<typename _IntType = int> typedef _IntType std::binomial_distribution< _IntType >::result_type
the type of the range of the distribution. that's it, that's the type. π
π Member Function Documentation π
β¨ template<typename _IntType = int> result_type std::binomial_distribution< _IntType >::max () const [inline]
returns the least upper bound value of the distribution. the ceiling. the limit. the top of the range. π
β¨ template<typename _IntType = int> result_type std::binomial_distribution< _IntType >::min () const [inline]
returns the greatest lower bound value of the distribution. the floor. the bottom of the range. π§
β¨ template<typename _IntType = int> template<typename _UniformRandomNumberGenerator> result_type std::binomial_distribution< _IntType >::operator() (_UniformRandomNumberGenerator & __urng) [inline]
generating functions. β¨
ngl this one is referenced by operator()() β yes, it says that, we're just reporting it faithfully bestie.
β¨ template<typename _IntType> template<typename _UniformRandomNumberGenerator> binomial_distribution< _IntType >::result_type std::binomial_distribution< _IntType >::operator() (_UniformRandomNumberGenerator & __urng, const param_type & __param)
okay so algorithm tea β: it uses a rejection algorithm when t * p >= 8, and a simple waiting time method β the second one in the referenced book β otherwise.
NB: the former (the rejection algorithm) is available only if _GLIBCXX_USE_C99_MATH_FUNCS is defined. if it isn't, don't come crying, it's just not there. π
Reference: Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, New York, 1986, Ch. X, Sect. 4 (+ Errata!).
References: std::abs(), std::numeric_limits< _Tp >::epsilon(), std::log(), and std::numeric_limits< _Tp >::max().
β¨ template<typename _IntType = int> double std::binomial_distribution< _IntType >::p () const [inline]
returns the distribution p parameter. that's the probability one. π
β¨ template<typename _IntType = int> param_type std::binomial_distribution< _IntType >::param () const [inline]
returns the parameter set of the distribution.
β¨ template<typename _IntType = int> void std::binomial_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> void std::binomial_distribution< _IntType >::reset () [inline]
resets the distribution state. fresh start, clean slate, main character energy. π¦
β¨ template<typename _IntType = int> _IntType std::binomial_distribution< _IntType >::t () const [inline]
returns the distribution t parameter. the trial count one. πΈ
π 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::binomial_distribution< _IntType1 > & __x) [friend]
inserts a binomial_distribution random number distribution __x into the output stream __os. slay, it prints itself. π
Parameters
__osβ an output stream.__xβ abinomial_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 binomial_distribution< _IntType > & __d1, const binomial_distribution< _IntType > & __d2) [friend]
returns true if two binomial distributions have the same parameters and the sequences that would be generated are equal. like, twin flame behaviour, fr fr. π―
π« template<typename _IntType = int> template<typename _IntType1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > & __is, std::binomial_distribution< _IntType1 > & __x) [friend]
extracts a binomial_distribution random number distribution __x from the input stream __is.
Parameters
__isβ an input stream.__xβ abinomial_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. not a human, just a very busy doc generator. π
and that's the whole page bestie, you ate it, you understood it, you're literally the main character of random number distributions now π
signing off β this was std::binom..._IntType >(3) from the Library Functions Manual, brought to you by libstdc++, no date on the tin, just vibes. π«Άβ¨π
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms