32 #ifndef SHARK_RNG_GEOMETRIC_H 33 #define SHARK_RNG_GEOMETRIC_H 46 template<
typename RngType = shark::DefaultRngType>
47 class Geometric:
public boost::variate_generator<RngType*,boost::geometric_distribution<long> > {
49 typedef boost::variate_generator<RngType*,boost::geometric_distribution<long> > Base;
59 :Base(&rng,
boost::geometric_distribution<long>(1.0-
p))
63 using Base::operator();
70 boost::geometric_distribution<long> dist( p );
71 return dist(Base::engine());
78 return 1-Base::distribution().p();
84 void prob(
double newMean) {
85 Base::distribution()=boost::geometric_distribution<long>(1-newMean);
92 return( x > 0 ?
prob() * std::pow(1 -
prob(), (
double) x - 1) : 0 );