我使用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> >â

===============>>#1 票数:1

您使用了错误的泊松分布。 boost :: math发行版似乎不适用于Boost.Random,因此请使用:

 #include <boost/random/poisson_distribution.hpp>
 boost::poisson_distribution<> pd(mean);
 boost::variate_generator <boost::mt19937, boost::poisson_distribution<> >

  ask by sivakhno translate from so

未解决问题?本站智能推荐: