Difference between revisions of "cpp/numeric/random/discrete distribution/probabilities"
From cppreference.com
< cpp | numeric | random | discrete distribution
m (stray }) |
m (Text replace - "{{example cpp" to "{{example") |
||
Line 16: | Line 16: | ||
===Example=== | ===Example=== | ||
− | {{example | + | {{example |
| code= | | code= | ||
#include <iostream> | #include <iostream> |
Revision as of 18:07, 19 April 2012
Template:cpp/numeric/random/discrete distribution/sidebar Template:ddcl list begin <tr class="t-dcl ">
<td >std::vector<double> probabilities() const;
</td>
<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end
Obtains a Template:cpp containing the individual probabilities of each integer that is generated by this distribution.
Parameters
(none)
Return value
An object of type Template:cpp
Example
Run this code
#include <iostream> #include <vector> #include <random> 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