OpenMPCD
Public Member Functions | List of all members
OpenMPCD::CUDA::Random::Distributions::Gamma< T > Class Template Reference

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_DEVICEoperator() (RNG &rng) const
 Generates a random value sampled from the distribution. More...
 

Detailed Description

template<typename T>
class OpenMPCD::CUDA::Random::Distributions::Gamma< T >

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.

Template Parameters
TThe underlying data type, which must be a floating-point type.

Definition at line 53 of file Gamma.hpp.

Constructor & Destructor Documentation

◆ Gamma()

template<typename T >
OPENMPCD_CUDA_DEVICE OpenMPCD::CUDA::Random::Distributions::Gamma< T >::Gamma ( const T  shape,
const T  scale 
)
inline

The constructor.

Exceptions
OpenMPCD::InvalidArgumentErrorIf OPENMPCD_DEBUG is defined, throws if shape < 0 or scale < 0.
Parameters
[in]shapeThe shape parameter \( k > 0 \).
[in]scaleThe scale parameter \( \theta > 0 \).

Definition at line 67 of file Gamma.hpp.

Member Function Documentation

◆ operator()()

template<typename T >
template<typename RNG >
OPENMPCD_CUDA_DEVICE T OpenMPCD::CUDA::Random::Distributions::Gamma< T >::operator() ( RNG rng) const
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).

Template Parameters
RNGThe random number generator type.
Parameters
[in]rngThe random number generator instance.

Definition at line 94 of file Gamma.hpp.


The documentation for this class was generated from the following file: