std::negati...distribution(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::negati...distribution(3) πŸ’–

okay so we're in the C++ Standard Libary manual β€” yes, Libary with one r, that's the header's spelling, not me 😭 β€” and this page is std::negati...distribution(3). The main character is std::negative_binomial_distribution::negative_binomial_distribution, which is literally the constructor. constructor inception, bestie.


🌸 NAME 🌸

std::negative_binomial_distribution::negative_binomial_distribution β€” std::negative_binomial_distribution::negative_binomial_distribution. That's the name. It's giving "say it twice so it knows it's iconic" energy. πŸ’…


✨ Synopsis ✨

          negative_binomial_distribution() :
       (1) (since C++11)
          negative_binomial_distribution(1) {}
          explicit negative_binomial_distribution( IntType k, double p = 0.5
       (2) (since C++11)
          );
          explicit negative_binomial_distribution( const param_type& params
       (3) (since C++11)
          );

Constructs a new distribution object.

The numbered ones do this:

  • 2) Uses k and p as the distribution parameters.
  • 3) Uses params as the distribution parameters.

πŸ’… Parameters πŸ’…

  • k β€” the k distribution parameter (number of trial successes). success slay.
  • p β€” the p distribution parameter (probability of a trial generating true). probability core.
  • params β€” the distribution parameter set. the whole little bundle.

🧚 Notes 🧚

Requires that 0 < p ≀ 1 and 0 < k. Like, read those bounds before you come for this constructor, bestie.

⚠️ If p == 1, subsequent calls to the operator() overload that does not accept a param_type object will cause undefined behavior. That's the scary one β€” literally do not play with it. 😭

A default-constructed std::negative_binomial_distribution is equivalent to the default-constructed std::geometric_distribution. fr fr, they're twinning.

πŸ› Defect reports πŸ›

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: P0935R0 β€” Applied to: C++11 β€” Behavior as published: default constructor was explicit β€” Correct behavior: made implicit. glow-up complete. ✨

πŸ’– that's the whole page, bestie! source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::negati...distribution(3) β€” go construct something iconic πŸ’…βœ¨

πŸ“¦ where this page comes from