I am trying to use the Gamma distribution from Boost 1.5. Now I want the value of k and theta to be 4 and .5 respectively. But I get a compile error whenever I set the value of theta < 1.
/usr/local/include/boost/random/gamma_distribution.hpp:118: boost::random::gamma_distribution<RealType>::gamma_distribution(const RealType&, const RealType&) [with RealType = double]: Assertion `_beta > result_type(0)' failed.
Is there any way to get around the same?
It looks like you do not pass the parameters correctly to the distribution function. Here is the C++11 version (Boost works equivalently):
Note the parametrization:
alphais the same askbetathe inverse scale parameter and is the same as1 / theta.