32 #ifndef SHARK_RNG_POISSON_H 33 #define SHARK_RNG_POISSON_H 37 #include <boost/random.hpp> 38 #include <boost/random/poisson_distribution.hpp> 45 template<
typename RngType = shark::DefaultRngType>
46 class Poisson :
public boost::variate_generator< RngType*,boost::poisson_distribution<> > {
48 typedef boost::variate_generator< RngType*,boost::poisson_distribution<> > Base;
58 :Base(&rng,
boost::poisson_distribution<>(
mean))
64 using Base::operator();
72 boost::poisson_distribution<> dist(mean);
73 return dist(Base::engine());
81 return Base::distribution().mean();
89 Base::distribution()=boost::poisson_distribution<>(newMean);
95 double p(
double x)
const 98 return std::pow(
mean(), x) * std::exp(-
mean()) / boost::math::factorial<double>(std::size_t(x));