名前空間
変種
操作

std::lognormal_distribution

提供: cppreference.com
< cpp‎ | numeric‎ | random
 
 
 
擬似乱数生成
一様ランダムビットジェネレータ
エンジンとエンジンアダプタ
非決定的なジェネレータ
分布
一様分布
ベルヌーイ分布
ポアソン分布
正規分布
lognormal_distribution
(C++11)
標本分布
シードシーケンス
(C++11)
C のライブラリ
 
 
ヘッダ <random> で定義
template<class RealType =double>
class lognormal_distribution;
(C++11以上)

lognormal_distribution 乱数分布は対数正規分布に従った x > 0 の乱数を生成します。

f(x; m,s) =
1
sx2 π
exp

-
(ln x - m)2
2s2


パラメータ m および s はそれぞれ x の自然対数の平均と標準偏差です。

std::lognormal_distributionRandomNumberDistribution の要件をすべて満たします。

目次

[編集]テンプレート引数

RealType - ジェネレータが生成する結果の型。 floatdouble または longdouble のいずれかでない場合、効果は未定義です


[編集]メンバ型

メンバ型 定義
result_typeRealType
param_type パラメータセットの型、 RandomNumberDistribution を参照してください

[編集]メンバ関数

新しい分布を構築します
(パブリックメンバ関数)[edit]
分布の内部状態をリセットします
(パブリックメンバ関数)[edit]
生成
分布の次の乱数を生成します
(パブリックメンバ関数)[edit]
特性
分布のパラメータを返します
(パブリックメンバ関数)[edit]
分布のパラメータオブジェクトを取得または設定します
(パブリックメンバ関数)[edit]
生成される可能性のある最小値を返します
(パブリックメンバ関数)[edit]
生成される可能性のある最大値を返します
(パブリックメンバ関数)[edit]

[編集]非メンバ関数

2つの分布オブジェクトを比較します
(関数)[edit]
乱数分布に対してストリーム入出力を行います
(関数テンプレート)[edit]

[編集]

#include <iostream>#include <iomanip>#include <string>#include <map>#include <random>#include <cmath>int main(){std::random_device rd;std::mt19937 gen(rd());   std::lognormal_distribution<> d(1.6, 0.25);   std::map<int, int> hist;for(int n=0; n<10000;++n){++hist[std::round(d(gen))];}for(auto p : hist){std::cout<<std::fixed<<std::setprecision(1)<<std::setw(2)<< p.first<<' '<<std::string(p.second/200, '*')<<'\n';}}

出力:

2 3 *** 4 ************* 5 *************** 6 ********* 7 **** 8 * 9 10 11 12

[編集]外部リンク

close