std::normal...distribution(3)

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

okay bestie, we're on the std::normal...distribution(3) page from the C++ Standard Libary manual β€” yep, that's how the header spells it, we keep it πŸ’…. This is the constructor page for std::normal_distribution, and it's lowkey iconic.

πŸŽ€ NAME πŸŽ€

std::normal_distribution::normal_distribution β€” std::normal_distribution::normal_distribution. That's the whole NAME line, fr fr. It's the constructor constructor moment πŸ‘‘

✨ Synopsis ✨

Three overloads, all (since C++11), and the code is exactly this:

normal_distribution() : normal_distribution(0.0) {}
(1) (since C++11)
explicit normal_distribution( RealType mean, RealType stddev = 1.0
(2) (since C++11)
);
explicit normal_distribution( const param_type& params );
(3) (since C++11)

Calling any of these constructs a new distribution object 🫢.

  • 2) Uses mean and stddev as the distribution parameters.
  • 3) Uses params as the distribution parameters.
🚨 and bestie, read this part twice: the behavior is undefined if stddev is not greater than zero. Not "oops maybe", not "sorta weird" β€” undefined behavior, periodt πŸ˜­πŸ’€.

πŸ“ Parameters πŸ“

  • mean β€” the ΞΌ distribution parameter (mean) ✨
  • stddev β€” the Οƒ distribution parameter (standard deviation) πŸ’…
  • params β€” the distribution parameter set πŸŽ€

πŸ¦‹ Defect reports πŸ¦‹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards, so they're giving "we fixed it after the fact" energy πŸ™ˆ:

  • DR P0935R0 β€” applied to C++11; behavior as published: default constructor was explicit; correct behavior: made implicit.

Okay bestie, that's the whole page πŸ’– β€” source: http://cppreference.com, date/version: 2024.06.10, page: std::normal...distribution(3). Go forth and distribute normally, no cap πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from