|
| discrete_distribution () |
| Creates a new discrete_distribution object that has and . More...
|
|
template<class Iter > |
| discrete_distribution (Iter first, Iter last) |
| Constructs a discrete_distribution from an iterator range. More...
|
|
| discrete_distribution (std::initializer_list< WeightType > wl) |
| Constructs a discrete_distribution from a std::initializer_list . More...
|
|
template<class Range > |
| discrete_distribution (const Range &range) |
| Constructs a discrete_distribution from a Boost.Range range. More...
|
|
template<class Func > |
| discrete_distribution (std::size_t nw, double xmin, double xmax, Func fw) |
| Constructs a discrete_distribution that approximates a function. More...
|
|
| discrete_distribution (const param_type &parm) |
| Constructs a discrete_distribution from its parameters. More...
|
|
template<class URNG > |
IntType | operator() (URNG &urng) const |
| Returns a value distributed according to the parameters of the discrete_distribution. More...
|
|
template<class URNG > |
IntType | operator() (URNG &urng, const param_type &parm) const |
| Returns a value distributed according to the parameters specified by param. More...
|
|
result_type min | BOOST_PREVENT_MACRO_SUBSTITUTION () const |
| Returns the smallest value that the distribution can produce. More...
|
|
result_type max | BOOST_PREVENT_MACRO_SUBSTITUTION () const |
| Returns the largest value that the distribution can produce. More...
|
|
std::vector< WeightType > | probabilities () const |
| Returns a vector containing the probabilities of each value of the distribution. More...
|
|
param_type | param () const |
| Returns the parameters of the distribution. More...
|
|
void | param (const param_type &parm) |
| Sets the parameters of the distribution. More...
|
|
void | reset () |
| Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset. More...
|
|
| BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR (os, discrete_distribution, dd) |
| Writes a distribution to a std::ostream . More...
|
|
| BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR (is, discrete_distribution, dd) |
| Reads a distribution from a std::istream . More...
|
|
| BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR (discrete_distribution, lhs, rhs) |
| Returns true if the two distributions will return the same sequence of values, when passed equal generators. More...
|
|
template<class IntType = int, class WeightType = double>
class boost::random::discrete_distribution< IntType, WeightType >
The class discrete_distribution
models a .
It produces integers in the range [0, n) with the probability of producing each value is specified by the parameters of the distribution.
template<class IntType = int, class WeightType = double>
Constructs a discrete_distribution
from a std::initializer_list
.
If the initializer_list
is empty, equivalent to the default constructor. Otherwise, the values of the initializer_list
represent weights for the possible values of the distribution. For example, given the distribution
discrete_distribution<> dist{1, 4, 5};
The probability of a 0 is 1/10, the probability of a 1 is 2/5, the probability of a 2 is 1/2, and no other values are possible.
template<class IntType = int, class WeightType = double>
template<class Func >
Constructs a discrete_distribution that approximates a function.
If nw is zero, equivalent to the default constructor. Otherwise, the range of the distribution is [0, nw), and the weights are found by calling fw with values evenly distributed between and , where .
template<class IntType = int, class WeightType = double>
Returns a vector containing the probabilities of each value of the distribution.
For example, given
discrete_distribution<> dist = { 1, 4, 5 };
std::vector<double>
p = dist.param();
the vector, p will contain {0.1, 0.4, 0.5}.
If WeightType
is integral, then the weights will be returned unchanged.