対数正規分布サンプリング; Log Normal Distribution Sampling
概要
対数正規分布とは以下の式で表現される確率分布。正規分布に従う確率変数を\(Z\)としたとき、\(exp(Z)\)は対数正規分布に従う。
$$f(x)=\frac{1}{\sqrt{2 \pi}\sigma x} exp \left(-\frac{(\log x-\mu)^2}{2 \sigma^2} \right) , \quad x \gt 0 $$
ソースコード
namespace ExRandom.Continuous {
public class LogNormalRandom : Random{
readonly NormalRandom nd;
public LogNormalRandom(MT19937 mt, double s = 1, double m = 0){
if(mt == null) {
throw new ArgumentNullException();
}
this.nd = new NormalRandom(mt, sigma : s, mu : m);
}
public override double Next() {
return Math.Exp(nd.Next());
}
}
}
関連項目
メルセンヌ・ツイスタ
各種確率分布サンプリング基本クラス
正規分布サンプリング