std::discre...robabilities(3)
πΈ NAME πΈ
std::discrete_distribution::probabilities β bestie, it's literally the member function that hands you back the probabilities π
(and yes, the manual name is C++ Standard Libary up top, typo and all, we don't gatekeep, we don't fix, we just vibe π«Ά β this page lives in section 3, the C++ Standard Library section)
β¨ SYNOPSIS β¨
std::vector<double> probabilities() const; (since C++11)
Okay so what even is this? It obtains a std::vector<double> containing the individual probabilities of each integer that is generated by this distribution. That's the whole thing. She's an icon, she's simple, she ate π₯
Note the (since C++11) β she's been here since C++11, a founding mother π
π PARAMETERS π
- (none) β not a single parameter, not one, zero, nada, she takes no arguments and needs no arguments, main character energy fr fr π
π RETURN VALUE π
An object of type std::vector<double>. That's it. That's the return value. A whole vector of doubles, just for you, no cap π
π¦ EXAMPLE π¦
The manpage literally says "Run this code" and honestly? Run it. Go off β¨
#include <iostream>
#include <random>
#include <vector>
int main()
{
std::discrete_distribution<> d({40, 10, 10, 40});
std::vector<double> p = d.probabilities();
for (auto n : p)
std::cout << n << ' ';
std::cout << '\n';
}
β Output:
0.4 0.1 0.1 0.4
See how that works?? You fed in {40, 10, 10, 40} and it normalized them into 0.4 0.1 0.1 0.4 β the individual probabilities, exactly what the tin says, we love a function that does what it says πβ¨
Heads up bestie: only the things listed above appear on this page β no extra secret options, no hidden overloads, no surprise environment variables. What you see is what you get, iykyk π
And that's the whole page! π§ Author credits aren't listed here, and the copyright/license lines aren't on this page either β but the source and version do carry a little signature: it's from http://cppreference.com, dated 2024.06.10, and the footer still calls it std::discre...robabilities(3). Slay, periodt π
π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms