negative_binomial

negative_binomial#

Class is used for generation of negative binomially distributed integer types random numbers.

Description

The class object is used in the oneapi::math::rng::generate() function to provide random numbers negative binomially distributed with distribution parameters \(a\) and \(p\), where \(p, a \in R; 0 \leq p \leq 1, a > 0\).

The probability distribution is given by:

\[P(X = k) = C^k_{a + k - 1}p^a(1 - p)^{k}, k \in \{0, 1, 2, ...\}\]

The cumulative distribution function is as follows:

\[\begin{split}F_{a, p}(x) = \left\{ \begin{array}{rcl} \sum^{\lfloor x \rfloor}_{k = 0} C^k_{a + k - 1}p^a(1 - p)^{k}, x \ge 0, x \in R \\ 0, x < 0 \end{array}\right.\end{split}\]

class negative_binomial#

Syntax

namespace oneapi::math::rng {
template<typename IntType = std::int32_t, typename Method = negative_binomial_method::by_default>
class negative_binomial {
public:
    using method_type = Method;
    using result_type = IntType;
    negative_binomial();
    explicit negative_binomial(double a, double p);
    double a() const;
    double p() const;
};
}

Template parameters

typename IntType
Type of the produced values. Supported types:
  • std::int32_t

  • std::uint32_t

typename Method = oneapi::math::rng::negative_binomial_method::by_default

Transformation method, which will be used for generation. Supported types:

  • oneapi::math::rng::negative_binomial_method::by_default

  • oneapi::math::rng::negative_binomial_method::nbar

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

negative_binomial()

Default constructor

explicit negative_binomial(double a, double p)

Constructor with parameters

double a() const

Method to obtain the first distribution parameter a

double p() const

Method to obtain the second distribution parameter p

Member types

negative_binomial::method_type = Method

Description

The type which defines transformation method for generation.

negative_binomial::result_type = IntType

Description

The type which defines type of generated random numbers.

Constructors

negative_binomial::negative_binomial()

Description

Default constructor for distribution, parameters set as a = 0.1, p = 0.5.

explicit negative_binomial::negative_binomial(double a, double p)

Description

Constructor with parameters. a is the first distribution parameter, p is the second distribution parameter.

Throws

oneapi::math::invalid_argument

Exception is thrown when \(p \ge 1.0\), or \(p \leq 0.0\), or \(a \leq 0.0\)

Characteristics

double negative_binomial::a() const

Return Value

Returns the distribution parameter a - the first distribution parameter.

double negative_binomial::p() const

Return Value

Returns the distribution parameter p - the second distribution parameter.

Parent topic: Host Distributions