std::weibull_distribution
ja.cppreference.net より
| ヘッダ <random>
|
||
template< class RealType = double >
class weibull_distribution;
|
(C++11から) | |
このweibull_distributionは、RandomNumberDistributionの要件を満たし、ワイブル分布に従って乱数を生成します:
- f(x;a,b) =
· ⎛a b
⎜
⎝
⎞x b
⎟
⎠a-1
· exp⎛
⎜
⎝-⎛
⎜
⎝
⎞x b
⎟
⎠a
⎞
⎟
⎠
std::weibull_distributionはRandomNumberDistributionを満たします。
テンプレートパラメータ
| RealType | - | ジェネレータによって生成される結果の型。これが float 、 double 、または long double のいずれでもない場合、動作は未定義です。 |
メンバー型
| メンバー型 | 定義 |
result_type
(C++11)
|
RealType |
param_type
(C++11)
|
パラメータセットの型、 RandomNumberDistribution を参照。 |
メンバー関数
|
(C++11)
|
新しい分布を構築する
(public member function) |
|
(C++11)
|
分布の内部状態をリセットする
(public member function) |
生成 |
|
|
(C++11)
|
分布内の次の乱数を生成する
(public member function) |
特性 |
|
|
(C++11)
|
分布パラメータを返す
(public member function) |
|
(C++11)
|
分布パラメータオブジェクトを取得または設定する
(public member function) |
|
(C++11)
|
生成される可能性のある最小値を返す
(public member function) |
|
(C++11)
|
生成される可能性のある最大値を返す
(public member function) |
非メンバー関数
|
(C++11)
(C++11)
(removed in C++20)
|
二つの分布オブジェクトを比較する
(関数) |
|
(C++11)
|
擬似乱数分布に対するストリーム入出力を実行する
(関数テンプレート) |
例
このコードを実行
#include <cmath> #include <iomanip> #include <iostream> #include <map> #include <random> #include <string> int main() { std::random_device rd; std::mt19937 gen(rd()); std::weibull_distribution<> d; std::map<int, int> hist; for (int n = 0; n != 10000; ++n) ++hist[std::round(d(gen))]; std::cout << std::fixed << std::setprecision(1) << std::hex; for (auto [x, y] : hist) std::cout << x << ' ' << std::string(y / 200, '*') << '\n'; }
出力例:
0 ******************* 1 ******************* 2 ****** 3 ** 4 5 6 7 8
外部リンク
| 1. | Weisstein, Eric W. "Weibull Distribution." MathWorld — Wolfram Web リソースより。 |
| 2. | Weibull distribution — Wikipediaより。 |