Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::discrete_distribution<IntType>::probabilities

Obtains a std::vector<double> containing the individual probabilities of each integer that is generated by this distribution.

NotebookLM
std::vector<double> probabilities() const;
(since C++11)

Obtains a std::vector<double> containing the individual probabilities of each integer that is generated by this distribution.

Parameters

(none)

Return value

An object of type std::vector<double>.

Example

example.cpp
#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

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.