![]() |
Home | Libraries | People | FAQ | More |
boost::random::piecewise_constant_distribution
// In header: <boost/random/piecewise_constant_distribution.hpp> template<typename RealType, typename WeightType> class piecewise_constant_distribution { public: // types typedef ; typedef ; // member classes/structs/unions class param_type { public: // types typedef piecewise_constant_distribution ; // construct/copy/destruct (); template<typename IntervalIter, typename WeightIter> (, , ); template<typename T, typename F> (, ); template<typename IntervalRange, typename WeightRange> (, ); template<typename F> (, , , ); // friend functions template<typename CharT, typename Traits> (, param_type &); template<typename CharT, typename Traits> (, param_type &); (param_type &, param_type &); (param_type &, param_type &); // public member functions () ; () ; }; // construct/copy/destruct (); template<typename IntervalIter, typename WeightIter> (, , ); template<typename T, typename F> (, ); template<typename IntervalsRange, typename WeightsRange> (, ); template<typename F> (, , , ); (param_type &); // public member functions template<typename URNG> () ; template<typename URNG> (, param_type &) ; () ; () ; () ; () ; param_type () ; (param_type &); (); // friend functions template<typename CharT, typename Traits> (, piecewise_constant_distribution &); template<typename CharT, typename Traits> (, piecewise_constant_distribution &); (piecewise_constant_distribution &, piecewise_constant_distribution &); (piecewise_constant_distribution &, piecewise_constant_distribution &); };
The class piecewise_constant_distribution
models a random distribution .
piecewise_constant_distribution
public
construct/copy/destruct();
Creates a new
with a single interval, [0, 1). piecewise_constant_distribution
template<typename IntervalIter, typename WeightIter> ( first_interval, last_interval, first_weight);
Constructs a piecewise_constant_distribution
from two iterator ranges containing the interval boundaries and the interval weights. If there are less than two boundaries, then this is equivalent to the default constructor and creates a single interval, [0, 1).
The values of the interval boundaries must be strictly increasing, and the number of weights must be one less than the number of interval boundaries. If there are extra weights, they are ignored.
For example,
The distribution has a 50% chance of producing a value between 0 and 1 and a 50% chance of producing a value between 1 and 4.
template<typename T, typename F> ( il, f);
Constructs a piecewise_constant_distribution
from an initializer_list containing the interval boundaries and a unary function specifying the weights. Each weight is determined by calling the function at the midpoint of the corresponding interval.
If the initializer_list contains less than two elements, this is equivalent to the default constructor and the distribution will produce values uniformly distributed in the range [0, 1).
template<typename IntervalsRange, typename WeightsRange> ( intervals_arg, weights_arg);
Constructs a piecewise_constant_distribution
from Boost.Range ranges holding the interval boundaries and the weights. If there are less than two interval boundaries, this is equivalent to the default constructor and the distribution will produce values uniformly distributed in the range [0, 1). The number of weights must be one less than the number of interval boundaries.
template<typename F> ( nw, xmin, xmax, f);
Constructs a piecewise_constant_distribution
that approximates a function. The range of the distribution is [xmin, xmax). This range is divided into nw equally sized intervals and the weights are found by calling the unary function f on the midpoints of the intervals.
(param_type & param);
Constructs a piecewise_constant_distribution
from its parameters.
piecewise_constant_distribution
public member functionstemplate<typename URNG> ( urng) ;
Returns a value distributed according to the parameters of the piecewist_constant_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 probability density over each interval.
() ;
Returns a vector containing the interval boundaries.
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.
piecewise_constant_distribution
friend functionstemplate<typename CharT, typename Traits> ( os, piecewise_constant_distribution & pcd);
Writes a distribution to a std::ostream
.
template<typename CharT, typename Traits> ( is, piecewise_constant_distribution & pcd);
Reads a distribution from a std::istream
(piecewise_constant_distribution & lhs, piecewise_constant_distribution & rhs);
Returns true if the two distributions will return the same sequence of values, when passed equal generators.
(piecewise_constant_distribution & lhs, piecewise_constant_distribution & rhs);
Returns true if the two distributions may return different sequences of values, when passed equal generators.