![]() |
Home | Libraries | People | FAQ | More |
boost::random::discrete_distribution
// In header: <boost/random/discrete_distribution.hpp> template<typename IntType, typename WeightType> class discrete_distribution { public: // types typedef ; typedef ; // member classes/structs/unions class param_type { public: // types typedef ; // construct/copy/destruct (); template<typename Iter> (, ); (); template<typename Range> (); template<typename Func> (, , , ); // public member functions () ; // friend functions template<typename CharT, typename Traits> (, ); template<typename CharT, typename Traits> (, ); (, ); (, ); }; // construct/copy/destruct (); template<typename Iter> (, ); (); template<typename Range> (); template<typename Func> (, , , ); (param_type &); // public member functions template<typename URNG> () ; template<typename URNG> (, param_type &) ; () ; () ; () ; param_type () ; (param_type &); (); // friend functions template<typename CharT, typename Traits> (, ); template<typename CharT, typename Traits> (, ); (, ); (, ); };
The class discrete_distribution models a random distribution . It produces integers in the range [0, n) with the probability of producing each value is specified by the parameters of the distribution.
discrete_distribution
public
construct/copy/destruct();
Creates a new object that has discrete_distribution
and
.
template<typename Iter> ( first, last);
Constructs a discrete_distribution from an iterator range. If first == last, equivalent to the default constructor. Otherwise, the values of the range represent weights for the possible values of the distribution.
( wl);
Constructs a from a discrete_distributionstd::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
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<typename Range> ( range);
Constructs a discrete_distribution from a Boost.Range range. If the range is empty, equivalent to the default constructor. Otherwise, the values of the range represent weights for the possible values of the distribution.
template<typename Func> ( nw, xmin, xmax, fw);
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
.
(param_type & param);
Constructs a discrete_distribution from its parameters.
discrete_distribution public member functionstemplate<typename URNG> ( urng) ;
Returns a value distributed according to the parameters of the discrete_distribution.
template<typename URNG> ( urng, param_type & param) ;
Returns a value distributed according to the parameters specified by param.
() ;
Returns the smallest value that the distribution can produce.
() ;
Returns the largest value that the distribution can produce.
() ;
Returns a vector containing the probabilities of each value of the distribution. For example, given
the vector, p will contain {0.1, 0.4, 0.5}.
If WeightType is integral, then the weights will be returned unchanged.
param_type () ;
Returns the parameters of the distribution.
(param_type & param);
Sets the parameters of the distribution.
();
Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.
discrete_distribution friend functionstemplate<typename CharT, typename Traits> ( os, dd);
Writes a distribution to a std::ostream.
template<typename CharT, typename Traits> ( is, dd);
Reads a distribution from a std::istream
( lhs, rhs);
Returns true if the two distributions will return the same sequence of values, when passed equal generators.
( lhs, rhs);
Returns true if the two distributions may return different sequences of values, when passed equal generators.