Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/numeric/random/discrete distribution/probabilities"

From cppreference.com
m (Text replace - "{{example cpp" to "{{example")
m (Text replace - "{{cpp|" to "{{c|")
Line 7: Line 7:
 
{{ddcl list end}}
 
{{ddcl list end}}
  
Obtains a {{cpp|std::vector<double>}} containing the individual probabilities of each integer that is generated by this distribution.
+
Obtains a {{|std::vector<double>}} containing the individual probabilities of each integer that is generated by this distribution.
  
 
===Parameters===
 
===Parameters===
Line 13: Line 13:
  
 
===Return value===
 
===Return value===
An object of type {{cpp|std::vector<double>}}
+
An object of type {{|std::vector<double>}}
  
 
===Example===
 
===Example===

Revision as of 21:32, 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 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

#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