A
piecewise_linear_distribution random number distribution
produces random numbers
x,
b0≤x<bn,
distributed over each subinterval
[bi,bi+1)
according to the probability density function
p(x|b0,…,bn,ρ0,…,ρn)=ρi⋅bi+1−xbi+1−bi+ρi+1⋅x−bibi+1−bi , for bi≤x<bi+1.
The
n+1 distribution parameters
bi,
also known as this distribution's
interval boundaries, shall satisfy the relation
bi<bi+1 for
i=0,…,n−1. Unless specified otherwise,
the remaining
n+1 distribution parameters are calculated as
ρk=wk/S for
k=0,…,n, in which the values
wk,
commonly known as the
weights at boundaries, shall be non-negative, non-NaN, and non-infinity
. Moreover, the following relation shall hold:
0<S=12⋅n−1∑k=0(wk+wk+1)⋅(bk+1−bk) .
template<class RealType = double>
class piecewise_linear_distribution {
public:
using result_type = RealType;
using param_type = unspecified;
piecewise_linear_distribution();
template<class InputIteratorB, class InputIteratorW>
piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB,
InputIteratorW firstW);
template<class UnaryOperation>
piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
template<class UnaryOperation>
piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
explicit piecewise_linear_distribution(const param_type& parm);
void reset();
template<class URBG>
result_type operator()(URBG& g);
template<class URBG>
result_type operator()(URBG& g, const param_type& parm);
vector<result_type> intervals() const;
vector<result_type> densities() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;
};