32 #ifndef SHARK_RNG_DIFFGEOMETRIC_H 33 #define SHARK_RNG_DIFFGEOMETRIC_H 37 #include <boost/random.hpp> 38 #include <boost/random/geometric_distribution.hpp> 40 #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS 52 template<
class IntType =
int,
class RealType =
double>
56 typedef RealType input_type;
57 typedef IntType result_type;
68 template<
class Engine>
71 return geom(eng)-geom(eng);
74 #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS 75 template<
class CharT,
class Traits>
76 friend std::basic_ostream<CharT,Traits>&
83 template<
class CharT,
class Traits>
84 friend std::basic_istream<CharT,Traits>&
92 boost::geometric_distribution<IntType,RealType> geom;
98 template<
typename RngType = shark::DefaultRngType>
99 class DiffGeometric:
public boost::variate_generator<RngType*,DiffGeometric_distribution<> >
102 typedef boost::variate_generator<RngType*,DiffGeometric_distribution<> > Base;
109 using Base::operator();
114 return dist(Base::engine());
119 return 1-Base::distribution().p();
126 double p(
double x)
const 128 return(
mean() * std::pow( 1 -
mean(), std::abs(x) ) / ( 2 -
mean() ) );