名前空間
変種
操作

std::discrete_distribution<IntType>::discrete_distribution

From cppreference.com
 
 
 
 
 
discrete_distribution();
(1) (C++11以降)
template< class InputIt >
discrete_distribution( InputIt first, InputIt last );
(2) (C++11以降)
discrete_distribution( std::initializer_list<double> weights );
(3) (C++11以降)
template< class UnaryOperation >

discrete_distribution( std::size_t count, double xmin, double xmax,

                       UnaryOperation unary_op );
(4) (C++11以降)
explicit discrete_distribution( const param_type& params );
(5) (C++11以降)

新しい分布オブジェクトを構築します。

1) デフォルトコンストラクタ。単一の重みp = {1}で分布を構築します。この分布は常に0を生成します。
2) 重みが範囲[firstlast)にある分布を構築します。first == lastの場合、デフォルトコンストラクタと同じ効果があります。
3) 重みがweightsにある分布を構築します。discrete_distribution(weights.begin(), weights.end())を効果的に呼び出します。
4) 関数unary_opを使用して生成されるcount個の重みを持つ分布を構築します。各重みはwi = unary_op(xmin + δ(i + 0.5))に等しく、ここでδ =
(xmax − xmin)
count
およびi ∈ {0, ..., count − 1}です。xminおよびxmaxδ > 0となるようにする必要があります。count == 0の場合、デフォルトコンストラクタと同じ効果があります。
5) 分布パラメータとしてparamsを持つ分布を構築します。

[編集] パラメータ

first, last - 重みとして使用される数値を定義する要素の範囲。InputIteratorが参照する要素の型は、doubleに変換可能である必要があります。
weights - 重みを含む初期化子リスト
unary_op - 適用される単項演算関数オブジェクト。

関数のシグネチャは以下と同等である必要があります。

 Ret fun(const Type &a);

シグネチャは const & を持つ必要はありません。
 Type型は、double型のオブジェクトを逆参照してから Type型に暗黙的に変換できる必要があります。Ret型は、double型のオブジェクトを逆参照し、Ret型の値を代入できる必要があります。

params - 分布パラメータセット
型要件
-
InputItLegacyInputIterator の要件を満たす必要があります。
English 日本語 中文(简体) 中文(繁體)