Go to the documentation of this file.
6 #ifndef OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_GAMMA_SHAPE_GE_1_HPP
7 #define OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_GAMMA_SHAPE_GE_1_HPP
15 #include <boost/static_assert.hpp>
16 #include <boost/type_traits/is_floating_point.hpp>
25 namespace Distributions
69 : k(shape), theta(scale),
70 d(k - T(1.0)/3), c(1 /
sqrt(9 * d))
72 BOOST_STATIC_ASSERT(boost::is_floating_point<T>::value);
96 template<
typename RNG>
109 x = standardNormal(rng);
116 const T u = uniform0e1e(rng);
118 if(u < 1 - 0.0331 * x * x * x * x)
119 return theta * d * v;
121 const T criterion = 0.5 * x * x + d * ( 1 - v + log(v) );
122 if(log(u) < criterion)
123 return theta * d * v;
141 #endif //OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_GAMMA_SHAPE_GE_1_HPP
OPENMPCD_CUDA_DEVICE Gamma_shape_ge_1(const T shape, const T scale)
The constructor.
The standard normal distribution.
#define OPENMPCD_DEBUG_ASSERT(assertion)
Asserts that the given expression evaluates to true, but only if OPENMPCD_DEBUG is defined.
#define OPENMPCD_CUDA_DEVICE
Denotes a function to be callable from a CUDA Device.
OPENMPCD_CUDA_DEVICE T operator()(RNG &rng) const
Generates a random value sampled from the distribution.
boost::mt11213b RNG
The random number generator type.
#define OPENMPCD_DEBUG_ASSERT_EXCEPTIONTYPE(assertion, ExceptionType)
OPENMPCD_CUDA_HOST_AND_DEVICE T sqrt(const T x)
Returns the sqaure root of the argument.
The gamma distribution, with shape parameter assumed to satisfy .
Invalid argument exception.