ライス分布サンプリング; Rice Distribution Sampling
概要
ライス分布とは以下の式で表現される確率分布。
$$f(x)=\frac{x}{\sigma^2} exp \left( - \frac{x^2 + \nu^2}{2 \sigma^2} \right) I_0 \left( \frac{x \nu}{\sigma^2} \right), \quad x \geq 0 $$
ここで\( I_0\)は第1種のゼロ次変形ベッセル関数である。
ソースコード
namespace ExRandom.Continuous {
public class RiceRandom : Random{
readonly MT19937 mt;
readonly NormalRandom nd;
readonly double nu, sigma;
public RiceRandom(MT19937 mt, double nu = 0.5, double sigma = 1) {
if(mt == null) {
throw new ArgumentNullException();
}
if(!(nu >= 0) || !(sigma >= 0)) {
throw new ArgumentException();
}
this.mt = mt;
this.nd = new NormalRandom(mt, sigma);
this.nu = nu;
this.sigma = sigma;
}
public override double Next() {
double theta = 2 * Math.PI * mt.NextDouble_OpenInterval1();
double x = nu * Math.Cos(theta) + nd.Next();
double y = nu * Math.Sin(theta) + nd.Next();
return Math.Sqrt(x * x + y * y);
}
}
}
関連項目
メルセンヌ・ツイスタ
各種確率分布サンプリング基本クラス