12 #if !defined(RANDOMLIB_NORMALDISTRIBUTION_HPP)
13 #define RANDOMLIB_NORMALDISTRIBUTION_HPP 1
78 template<
class Random>
80 RealType sigma = RealType(1))
const throw();
83 template<typename RealType> template<class
Random> inline RealType
85 RealType sigma) const throw() {
90 m = RealType( 1.7156 ),
91 s = RealType( 0.449871),
92 t = RealType(-0.386595),
93 a = RealType( 0.19600 ),
94 b = RealType( 0.25472 ),
95 r1 = RealType( 0.27597 ),
96 r2 = RealType( 0.27846 );
100 u = r.template FixedU<RealType>();
101 v = m * r.template FixedS<RealType>();
103 const RealType x = u - s;
104 const RealType y = (v < 0 ? -v : v) - t;
105 Q = x*x + y * (a*y - b*x);
108 v*v > - 4 * u*u * std::log(u) ) );
109 return mu + sigma * (v / u);
114 #endif // RANDOMLIB_NORMALDISTRIBUTION_HPP
Generate random integers, reals, and booleans.
RealType operator()(Random &r, RealType mu=RealType(0), RealType sigma=RealType(1)) const