OpenMPCD
|
The gamma distribution. More...
#include <Gamma.hpp>
Public Member Functions | |
OPENMPCD_CUDA_DEVICE | Gamma (const T shape, const T scale) |
The constructor. More... | |
template<typename RNG > | |
OPENMPCD_CUDA_DEVICE T | operator() (RNG &rng) const |
Generates a random value sampled from the distribution. More... | |
The gamma distribution.
This is the distribution which has the probability density function
\[ f \left(x ; k, \theta \right) = \frac { x^{k-1} \exp \left( - \frac{ x }{ \theta } \right) } { \Gamma \left( k \right) \theta^k } \]
where the parameters \( k \) and \( \theta \) are called shape
and scale
, respectively, and \( \Gamma \) is the gamma function.
For further information, see e.g. [2], chapter IX.3.
T | The underlying data type, which must be a floating-point type. |
|
inline |
|
inline |
Generates a random value sampled from the distribution.
This function implements the algorithm in [16], and additionally making use of the scaling property of the gamma distribution, i.e. the fact that if \( X \) is gamma-distributed with shape \( k \) and scale \( \theta \), then \( cX \) is gamma-distributed with shape \( k \) and scale \( c \theta \), given that \( c > 0 \) (see [2], chapter IX.3).
RNG | The random number generator type. |
[in] | rng | The random number generator instance. |