gamma

Contents

gamma#

Generates gamma distributed random numbers.

Description

The gamma class object is used in the generate function to provide random numbers with gamma distribution that has shape \(\alpha\), displacement \(a\), and scale parameter \(\beta\), where \(a, \alpha, \beta \in R; \alpha > 0; \beta > 0\).

The probability distribution is given by:

\[\begin{split}f_{a, \alpha, \beta}(x) = \left\{ \begin{array}{rcl} \frac{1}{\Gamma(\alpha)\beta^{\alpha}}(x - a)^{\alpha - 1}e^{-(x - a) / \beta}, x \ge a \\ 0, x < a \end{array}\right.\end{split}\]

The cumulative distribution function is as follows:

\[\begin{split}F_{a, \alpha, \beta}(x) = \left\{ \begin{array}{rcl} \int^x_a\frac{1}{\Gamma(\alpha)\beta^{\alpha}}(y - a)^{\alpha - 1}e^{-(y - a) / \beta}dy, x \ge a \\ 0, x < a \end{array}\right.\end{split}\]

class gamma#

Syntax

namespace oneapi::mkl::rng::device {
  template<typename RealType, typename Method>
  class gamma {
  public:
    using method_type = Method;
    using result_type = RealType;

    gamma();
    explicit gamma(RealType alpha, RealType a, RealType beta);

    RealType alpha() const;
    RealType a() const;
    RealType beta() const;
    std::size_t count_rejected_numbers() const;
  };
}

Template parameters

typename RealType

Type of the produced values. Supported types:

  • float

  • double

typename Method

Generation method. The type is unspecified.

Class Members

Routine

Description

gamma()

Default constructor

explicit gamma(RealType alpha, RealType a, RealType beta)

Constructor with parameters

RealType alpha() const

Method to obtain shape value

RealType a() const

Method to obtain displacement value

RealType beta() const

Method to obtain scale parameter

size_t count_rejected_numbers() const

Method to obtain amount of random numbers that were rejected during the last generate function call. If no generate calls, 0 is returned.

Member types

gamma::method_type = Method

Description

The type which defines transformation method for generation.

gamma::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

gamma::gamma()

Description

Default constructor for distribution, parameters set as alpha = 1.0, a = 0.0, beta = 1.0.

explicit gamma::gamma(RealType alpha, RealType a, RealType beta)

Description

Constructor with parameters. alpha is a shape, a is a displacement, beta is a scale parameter.

Throws

oneapi::mkl::invalid_argument

Exception is thrown when \(alpha \leq 0\) or \(beta \leq 0\)

Characteristics

RealType gamma::alpha() const

Return Value

Returns the distribution parameter alpha - shape.

RealType gamma::a() const

Return Value

Returns the distribution parameter a - displacement.

RealType gamma::beta() const

Return Value

Returns the distribution parameter beta - scale parameter value.

std::size_t gamma::count_rejected_numbers() const

Return Value

Returns the amount of random numbers that were rejected during the last generate function call. If no generate calls, 0 is returned.

Parent topic: Device Distributions