0

我正在使用 boost_1_31_0 并且我正在尝试创建 beta 分布随机数(我正在使用 beta(alpha, beta) = gamma(alpha) / (gamma(alpha) + gamma(beta)))I' m 每次使用这个创建 16 个随机数(见下文):问题是随机生成的不遵守大数定律:对于每个分布,当我计算生成数的平均值时,它与分布。结论是我们不能对很多发行版使用相同的引擎吗?我的代码如下:

//this engine is created in the top of my code.
boost::mt19937 eng;

//MyVector.size() is equal to 8, this boucle is called 100 000 times

for (int i = 0; i<MyVector.size(); i++)
{
    MyObject seedPtr = MyVector[i];
alpha = m_map_alpha.find(seedPtr)->second ;
boost::gamma_distribution<> gamma_alpha(alpha);
boost::variate_generator< boost::mt19937&,boost::gamma_distribution<>> generator_gamma_alpha(eng, gamma_alpha);
alpha_random = generator_gamma_alpha();
boost::gamma_distribution<> gamma_beta(beta);
boost::variate_generator< boost::mt19937&, boost::gamma_distribution<>> generator_gamma_beta(eng, gamma_beta);
beta_random = generator_gamma_beta();   
random = alpha_random / (alpha_random + beta_random ) ;
pair<myObject, double> graine(seedPtr, random);
mapRandoms.insert(graine);
}
4

0 回答 0