Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::random::piecewise_constant_distribution< RealType, WeightType > Class Template Reference

The class piecewise_constant_distribution models a . More...

#include <piecewise_constant_distribution.hpp>

Classes

class  param_type
 

Public Types

typedef std::size_t input_type
 
typedef RealType result_type
 

Public Member Functions

 piecewise_constant_distribution ()
 Creates a new piecewise_constant_distribution with a single interval, [0, 1). More...
 
template<class IntervalIter , class WeightIter >
 piecewise_constant_distribution (IntervalIter first_interval, IntervalIter last_interval, WeightIter first_weight)
 Constructs a piecewise_constant_distribution from two iterator ranges containing the interval boundaries and the interval weights. More...
 
template<class T , class F >
 piecewise_constant_distribution (std::initializer_list< T > il, F f)
 Constructs a piecewise_constant_distribution from an initializer_list containing the interval boundaries and a unary function specifying the weights. More...
 
template<class IntervalsRange , class WeightsRange >
 piecewise_constant_distribution (const IntervalsRange &intervals_arg, const WeightsRange &weights_arg)
 Constructs a piecewise_constant_distribution from Boost.Range ranges holding the interval boundaries and the weights. More...
 
template<class F >
 piecewise_constant_distribution (std::size_t nw, RealType xmin, RealType xmax, F f)
 Constructs a piecewise_constant_distribution that approximates a function. More...
 
 piecewise_constant_distribution (const param_type &parm)
 Constructs a piecewise_constant_distribution from its parameters. More...
 
template<class URNG >
RealType operator() (URNG &urng) const
 Returns a value distributed according to the parameters of the piecewist_constant_distribution. More...
 
template<class URNG >
RealType 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< RealType > densities () const
 Returns a vector containing the probability density over each interval. More...
 
std::vector< RealType > intervals () const
 Returns a vector containing the interval boundaries. 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, piecewise_constant_distribution, pcd)
 Writes a distribution to a std::ostream. More...
 
 BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR (is, piecewise_constant_distribution, pcd)
 Reads a distribution from a std::istream. More...
 
 BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR (piecewise_constant_distribution, lhs, rhs)
 Returns true if the two distributions will return the same sequence of values, when passed equal generators. More...
 

Detailed Description

template<class RealType = double, class WeightType = double>
class boost::random::piecewise_constant_distribution< RealType, WeightType >

The class piecewise_constant_distribution models a .

Member Typedef Documentation

template<class RealType = double, class WeightType = double>
typedef std::size_t boost::random::piecewise_constant_distribution< RealType, WeightType >::input_type
template<class RealType = double, class WeightType = double>
typedef RealType boost::random::piecewise_constant_distribution< RealType, WeightType >::result_type

Constructor & Destructor Documentation

template<class RealType = double, class WeightType = double>
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( )
inline

Creates a new piecewise_constant_distribution with a single interval, [0, 1).

template<class RealType = double, class WeightType = double>
template<class IntervalIter , class WeightIter >
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( IntervalIter  first_interval,
IntervalIter  last_interval,
WeightIter  first_weight 
)
inline

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,

double intervals[] = { 0.0, 1.0, 4.0 };
double weights[] = { 1.0, 1.0 };
piecewise_constant_distribution<> dist(
&intervals[0], &intervals[0] + 3, &weights[0]);

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.

References boost::multiprecision::backends::i.

template<class RealType = double, class WeightType = double>
template<class T , class F >
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( std::initializer_list< T il,
f 
)
inline

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).

References boost::multiprecision::backends::i.

template<class RealType = double, class WeightType = double>
template<class IntervalsRange , class WeightsRange >
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( const IntervalsRange &  intervals_arg,
const WeightsRange &  weights_arg 
)
inline

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<class RealType = double, class WeightType = double>
template<class F >
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( std::size_t  nw,
RealType  xmin,
RealType  xmax,
f 
)
inline

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.

References boost::polygon::delta(), and boost::multiprecision::backends::i.

template<class RealType = double, class WeightType = double>
boost::random::piecewise_constant_distribution< RealType, WeightType >::piecewise_constant_distribution ( const param_type parm)
inlineexplicit

Constructs a piecewise_constant_distribution from its parameters.

Member Function Documentation

template<class RealType = double, class WeightType = double>
result_type min boost::random::piecewise_constant_distribution< RealType, WeightType >::BOOST_PREVENT_MACRO_SUBSTITUTION ( ) const
inline

Returns the smallest value that the distribution can produce.

template<class RealType = double, class WeightType = double>
result_type max boost::random::piecewise_constant_distribution< RealType, WeightType >::BOOST_PREVENT_MACRO_SUBSTITUTION ( ) const
inline

Returns the largest value that the distribution can produce.

template<class RealType = double, class WeightType = double>
boost::random::piecewise_constant_distribution< RealType, WeightType >::BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR ( piecewise_constant_distribution< RealType, WeightType >  ,
lhs  ,
rhs   
)
inline

Returns true if the two distributions will return the same sequence of values, when passed equal generators.

template<class RealType = double, class WeightType = double>
boost::random::piecewise_constant_distribution< RealType, WeightType >::BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR ( is  ,
piecewise_constant_distribution< RealType, WeightType >  ,
pcd   
)
inline

Reads a distribution from a std::istream.

template<class RealType = double, class WeightType = double>
boost::random::piecewise_constant_distribution< RealType, WeightType >::BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR ( os  ,
piecewise_constant_distribution< RealType, WeightType >  ,
pcd   
)
inline

Writes a distribution to a std::ostream.

template<class RealType = double, class WeightType = double>
std::vector<RealType> boost::random::piecewise_constant_distribution< RealType, WeightType >::densities ( ) const
inline

Returns a vector containing the probability density over each interval.

References boost::multiprecision::backends::i.

template<class RealType = double, class WeightType = double>
std::vector<RealType> boost::random::piecewise_constant_distribution< RealType, WeightType >::intervals ( ) const
inline

Returns a vector containing the interval boundaries.

template<class RealType = double, class WeightType = double>
template<class URNG >
RealType boost::random::piecewise_constant_distribution< RealType, WeightType >::operator() ( URNG &  urng) const
inline

Returns a value distributed according to the parameters of the piecewist_constant_distribution.

References boost::multiprecision::backends::i.

template<class RealType = double, class WeightType = double>
template<class URNG >
RealType boost::random::piecewise_constant_distribution< RealType, WeightType >::operator() ( URNG &  urng,
const param_type parm 
) const
inline

Returns a value distributed according to the parameters specified by param.

References boost::random::piecewise_constant_distribution< RealType, WeightType >::param_type::piecewise_constant_distribution.

template<class RealType = double, class WeightType = double>
param_type boost::random::piecewise_constant_distribution< RealType, WeightType >::param ( ) const
inline
template<class RealType = double, class WeightType = double>
void boost::random::piecewise_constant_distribution< RealType, WeightType >::param ( const param_type parm)
inline

Sets the parameters of the distribution.

template<class RealType = double, class WeightType = double>
void boost::random::piecewise_constant_distribution< RealType, WeightType >::reset ( void  )
inline

Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.


The documentation for this class was generated from the following file: