共用方式為


piecewise_constant_distribution::piecewise_constant_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); 

參數

  • firstI
    分佈範圍中第一個元素的輸入迭代器。

  • lastI
    分佈範圍中最後一個元素的輸入迭代器。

  • firstW
    加權範圍中第一個元素的輸入迭代器。

  • intervals
    具有分佈間隔的 initializer_list

  • count
    分佈範圍中的元素數目。

  • xmin
    分佈範圍中的最低值。

  • xmax
    分佈範圍中的最高值。 必須大於 xmin。

  • weightfunc
    表示分佈的可能性函式的物件。 參數和傳回值都必須可以轉換為 double。

  • parm
    用於建構分佈的參數結構。

備註

預設建構函式會設定儲存的參數,因此會有可能性密度為 1 的一個間隔 (0 到 1)。

迭代器範圍建構函式

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

建構分佈物件,而分佈物件具有序列 [firstI, lastI) 上來自迭代器的間隔,以及從 firstW 開始的相符加權序列。

初始設定式清單建構函式

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

建構分佈物件,而分佈物件具有來自初始設定式清單 intervals 的間隔,以及透過函式 weightfunc 產生的加權。

建構函式定義為

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

建構分佈物件,其具有平均分佈在 [xmin,xmax] 的 count 個間隔 (根據函式 weightfunc 指派每個間隔加權),而且 weightfunc 必須接受一個參數並有一個傳回值 (兩者都可以轉換為 double)。 **前置條件:**xmin < xmax

建構函式定義為

explicit piecewise_constant_distribution(const param_type& parm);

使用 parm 做為儲存參數結構,以建構分佈物件。

需求

標頭:<random>

命名空間: std

請參閱

參考

<random>

piecewise_constant_distribution 類別