std::discrete_distribution
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <random>
|
||
template< class IntType = int > class discrete_distribution; |
(C++11およびそれ以降) | |
std::discrete_distribution
それぞれの個々の整数[0, n)
の確率がすべてi
の重みの和で割ったwi/Sth整数の重量です
i
、として定義されている区間n
、上のランダムな整数を生成. Original:
std::discrete_distribution
produces random integers on the interval [0, n)
, where the probability of each individual integer i
is defined as wi/S, that is the weight of the
i
th integer divided by the sum of all n
weights. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] メンバータイプ
メンバー·タイプ
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
result_type
|
IntType |
param_type
|
不特定のパラメータセットのタイプ
Original: the type of the parameter set, unspecified The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] メンバ関数
新しいディストリビューションを構築します Original: constructs new distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
リセットさ分布の内部状態 Original: resets the internal state of the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
ディストリビューションの次の乱数を生成します Original: generates the next random number in the distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
確率のリストを取得します Original: obtains the list of probabilities The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
分布パラメータオブジェクトを取得または設定します Original: gets or sets the distribution parameter object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
最小潜在的に生成された値を返します Original: returns the minimum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
最大潜在的に生成された値を返します Original: returns the maximum potentially generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |
[編集] 非メンバ関数
2つのディストリビューションオブジェクトを比較します Original: compares two distribution objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
擬似乱数分布にストリーム入出力を行います Original: performs stream input and output on pseudo-random number distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) |
[編集] 例
このコードを実行します
#include <iostream> #include <map> #include <random> int main() { std::random_device rd; std::mt19937 gen(rd()); std::discrete_distribution<> d({40, 10, 10, 40}); std::map<int, int> m; for(int n=0; n<10000; ++n) { ++m[d(gen)]; } for(auto p : m) { std::cout << p.first << " generated " << p.second << " times\n"; } }
出力:
0 generated 4028 times 1 generated 978 times 2 generated 1012 times 3 generated 3982 times