piecewise_constant_distribution::piecewise_constant_distribution

Constructs the distribution.

// default constructor
piecewise_constant_distribution();

// constructs using a range of intervals, [firstI, lastI), with
// matching weights starting at firstW
template<class InputIteratorI, class InputIteratorW>
piecewise_constant_distribution(InputIteratorI firstI, InputIteratorI lastI, InputIteratorW firstW);

// constructs using an initializer list for range of intervals,
// with weights generated by function weightfunc
template<class UnaryOperation>
piecewise_constant_distribution(initializer_list<RealType> intervals, UnaryOperation weightfunc);

// constructs using an initializer list for range of count intervals,
// distributed uniformly over [xmin,xmax] with weights generated by function weightfunc
template<class UnaryOperation>
piecewise_constant_distribution(size_t count, RealType xmin, RealType xmax, UnaryOperation weightfunc);

// constructs from an existing param_type structure
explicit piecewise_constant_distribution(const param_type& parm);

Parameters

  • firstI
    An input iterator of the first element in the distribution range.

  • lastI
    An input iterator of the last element in the distribution range.

  • firstW
    An input iterator of the first element in the weights range.

  • intervals
    An initializer_list with the intervals of the distribution.

  • count
    The number of elements in the distribution range.

  • xmin
    The lowest value in the distribution range.

  • xmax
    The highest value in the distribution range. Must be greater than xmin.

  • weightfunc
    The object representing the probability function for the distribution. Both the parameter and the return value must be convertible to double.

  • parm
    The parameter structure used to construct the distribution.

Remarks

The default constructor sets the stored parameters such that there is one interval, 0 to 1, with a probability density of 1.

The iterator range constructor

template<class InputIteratorI, class InputIteratorW>
piecewise_constant_distribution(InputIteratorI firstI, InputIteratorI lastI,
        InputIteratorW firstW);

constructs a distribution object with itnervals from iterators over the sequence [firstI, lastI) and a matching weight sequence starting at firstW.

The initializer list constructor

template<class UnaryOperation>
piecewise_constant_distribution(initializer_list<RealType> intervals, 
        UnaryOperation weightfunc);

constructs a distribution object with intervals from the intializer list intervals and weights generated from the function weightfunc.

The constructor defined as

template<class UnaryOperation>
piecewise_constant_distribution(size_t count, RealType xmin, RealType xmax,
        UnaryOperation weightfunc);

constructs a distribution object with count intervals distributed uniformly over [xmin,xmax], assigning each interval weights according to the function weightfunc, and weightfunc must accept one parameter and have a return value, both of which are convertible to double. **Precondition:**xmin < xmax

The constructor defined as

explicit piecewise_constant_distribution(const param_type& parm);

constructs a distribution object using parm as the stored parameter structure.

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

piecewise_constant_distribution Class