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 a t and an optional p that defaults to 0.5
  • binomial_distribution (const param_type &__p) β€” construct it from a param_type instead
  • template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng) β€” fill the range [__f, __t) with generated values using __urng
  • template<typename _ForwardIterator, typename _UniformRandomNumberGenerator> void __generate (_ForwardIterator __f, _ForwardIterator __t, _UniformRandomNumberGenerator &__urng, const param_type &__p) β€” same thing but with a param_type handed in
  • template<typename _UniformRandomNumberGenerator> void __generate (result_type *__f, result_type *__t, _UniformRandomNumberGenerator &__urng, const param_type &__p) β€” and the pointer-flavoured version of that
  • 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) β€” generating functions, but you're choosing the params yourself
  • double p () const β€” returns the distribution p parameter
  • 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
  • _IntType t () const β€” returns the distribution t parameter

🧚 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 a binomial_distribution random number distribution __x into the output stream __os
  • bool operator== (const binomial_distribution &__d1, const binomial_distribution &__d2) β€” returns true if two binomial distributions have the same parameters and the sequences that would be generated are equal
  • template<typename _IntType1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::binomial_distribution< _IntType1 > &__x) β€” extracts a binomial_distribution random number distribution __x from 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. 🌸


πŸ’« 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 β€” a binomial_distribution random 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 β€” a binomial_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, 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