STD::BERNOULLI_DISTRIBUTION(3)

✨ NAME ✨

std::bernoulli_distribution β€” bestie it's a Bernoulli random number distribution πŸ’– like, coin-flip energy, literally.


🌸 SYNOPSIS 🌸

#include <random>

πŸ“¦ Classes

  • struct param_type

πŸŽ€ Public Types

  • typedef bool result_type

🫢 Public Member Functions

  • bernoulli_distribution () β€” ok so this one constructs a Bernoulli distribution with likelihood 0.5 ✨
  • bernoulli_distribution (const param_type &__p)
  • bernoulli_distribution (double __p) β€” constructs a Bernoulli distribution with likelihood p πŸ’…
  • 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 β€” hands you the least upper bound value of the distribution πŸ‘‘
  • result_type min () const β€” hands you the greatest lower bound value of the distribution 🌈
  • template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng) β€” generating functions, the main character fr fr
  • template<typename _UniformRandomNumberGenerator> result_type operator() (_UniformRandomNumberGenerator &__urng, const param_type &__p)
  • double p () const β€” returns the p parameter of the distribution πŸ’œ
  • 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 🧚

πŸ’– Friends

  • bool operator== (const bernoulli_distribution &__d1, const bernoulli_distribution &__d2) β€” returns true if two Bernoulli distributions have the same parameters, no cap πŸ‘―

πŸ”₯ Detailed Description πŸ”₯

A Bernoulli random number distribution. That's it, that's the vibe.

It generates a sequence of true and false values, with likelihood $p$ that true will come up and $(1 - p)$ that false will appear. So like... weighted coin flip, but make it C++ πŸ’…

Since

C++11 ⭐ (yes it's been iconic since then)


πŸŽ€ Member Typedef Documentation πŸŽ€

typedef bool std::bernoulli_distribution::result_type

The type of the range of the distribution. It's bool bestie, the range is literally two things 😭


🌸 Constructor & Destructor Documentation 🌸

std::bernoulli_distribution::bernoulli_distribution () [inline]

Constructs a Bernoulli distribution with likelihood 0.5. Perfectly balanced, as all things should be ✨

References bernoulli_distribution().

Referenced by bernoulli_distribution(), and operator==.


std::bernoulli_distribution::bernoulli_distribution (double __p) [inline], [explicit]

Constructs a Bernoulli distribution with likelihood p. You're picking your own odds, main character move πŸ’…

Parameters

  • __p [IN] β€” the likelihood of a true result being returned. Must be in the interval $[0, 1]$.
okay so lowkey do NOT go outside that interval, it says must and it means it 🚨

πŸ’œ Member Function Documentation πŸ’œ

result_type std::bernoulli_distribution::max () const [inline]

Returns the least upper bound value of the distribution.

References std::numeric_limits< _Tp >::max().


result_type std::bernoulli_distribution::min () const [inline]

Returns the greatest lower bound value of the distribution.

References std::numeric_limits< _Tp >::min().


template<typename _UniformRandomNumberGenerator> result_type std::bernoulli_distribution::operator() (_UniformRandomNumberGenerator & __urng) [inline]

Generating functions. This is the one that actually makes the numbers appear πŸͺ„

References operator()().

Referenced by operator()().


double std::bernoulli_distribution::p () const [inline]

Returns the p parameter of the distribution. Just... giving you the p back 🫢


param_type std::bernoulli_distribution::param () const [inline]

Returns the parameter set of the distribution.

Referenced by std::operator>>().


void std::bernoulli_distribution::param (const param_type & __param) [inline]

Sets the parameter set of the distribution.

Parameters

  • __param β€” the new parameter set of the distribution.

void std::bernoulli_distribution::reset () [inline]

Resets the distribution state. And here's the tea: it does nothing for a Bernoulli distribution. Like, girl, there's nothing to reset 😭 still gotta call it tho, it's the vibe.


bool operator== (const bernoulli_distribution & __d1, const bernoulli_distribution & __d2) [friend]

Returns true if two Bernoulli distributions have the same parameters. Twin check βœ…

References bernoulli_distribution().


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. Not me writing it by hand, the robots did that 🧚


okay that's the whole page bestie, you ate it up πŸ’… this was std::berno...istribution(3) from the libstdc++ crew, brought to you by the Doxygen machine and a girl who genuinely loves a random number distribution β€” periodt πŸŽ€βœ¨

πŸ“¦ 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
  • centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 Β· 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
  • centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· 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
  • centos-stream 10: libstdc++-docs 14.4.1-4.el10 Β· 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 43: libstdc++-docs 15.2.1-2.fc43 Β· 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 43: libstdc++-docs 15.3.1-1.fc43 Β· 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.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