我使用 boost variate_generator 从 boost_1_46_1 的泊松分布生成随机数(显然 variate_generator 的文件夹结构在版本之间随机变化)。
下面的代码片段是错误报告:显然它无法识别variate_generator
对variate_generator.hpp:123: error: no type named result_type in class boost::math::poisson_distribution
.
我无法弄清楚我做错了什么 - 非常感谢您的帮助!谢谢。
代码
#include <boost/random/variate_generator.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/math/distributions/poisson.hpp>
using namespace boost;
double poiss(double mean) {
static boost::mt19937 randgen(0);
static boost::math::poisson_distribution <double> pd(mean);
static boost::variate_generator <boost::mt19937&, boost::math::poisson_distribution <double> > generator(randgen, pd); <- line CnvSeg.c:46
return (double) generator();
}
错误
CnvSeg.c:47: error: no match for call to â(boost::variate_generator<boost::mt19937&, boost::math::poisson_distribution<double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> > >) ()â
/home/craczy/boost_1_46_1/include/boost/random/variate_generator.hpp: In constructor âboost::variate_generator<Engine, Distribution>::variate_generator(Engine, Distribution) [with Engine = boost::mt19937&, Distribution = boost::math::poisson_distribution<double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >]â:
CnvSeg.c:46: instantiated from here
/home/craczy/boost_1_46_1/include/boost/random/variate_generator.hpp:134: error: using invalid field âboost::variate_generator<Engine, Distribution>::_engâ
/home/craczy/boost_1_46_1/include/boost/random/variate_generator.hpp:123: error: no type named âresult_typeâ in âclass boost::math::poisson_distribution<double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >â