32 #ifndef SHARK_RNG_NORMAL_H 33 #define SHARK_RNG_NORMAL_H 39 #include <boost/math/special_functions.hpp> 40 #include <boost/random.hpp> 51 template<
typename RngType = DefaultRngType>
55 public boost::variate_generator<RngType*, boost::normal_distribution<> >
58 typedef boost::variate_generator<RngType*, boost::normal_distribution<> > Base;
69 using Base::operator();
73 boost::normal_distribution<> dist(mean,std::sqrt(variance));
74 return dist(Base::engine());
79 return Base::distribution().mean();
84 return Base::distribution().sigma() * Base::distribution().sigma();
89 Base::distribution() = boost::normal_distribution<>(newMean, Base::distribution().sigma());
94 Base::distribution() = boost::normal_distribution<>(
mean(), std::sqrt(newVariance));
97 double p(
double x)
const 99 const double standardDeviation = Base::distribution().sigma();
100 return std::exp(-
sqr((x -
mean()) / standardDeviation) / 2.0) / (
SQRT_2_PI * standardDeviation);
105 const double standardDeviation = Base::distribution().sigma();
111 template<
class RngType>
120 #endif // SHARK_RNG_NORMAL_H