# hypergeometric#

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

Description

The class object is used in the oneapi::mkl::rng::generate() function to provide random numbers hypergeometrically distributed with lot size $$l$$, size of sampling $$s$$, and number of marked elements in the lot $$m$$, where $$l, m, s \in N \bigcup \{0\}; l \ge max (s, m)$$.

Consider a lot of $$l$$ elements comprising $$m$$ marked and $$l$$ - $$m$$ unmarked elements. A trial sampling without replacement of exactly $$s$$ elements from this lot helps to define the hypergeometric distribution, which is the probability that the group of $$s$$ elements contains exactly $$k$$ marked elements.

The probability distribution is given by:

$P_(X = k) = \frac{C^k_mC^{s-k}_{l-m}}{C^s_l}, k \in \{max(0, s + m - l), ... , min(s, m)\}.$

The cumulative distribution function is as follows:

$\begin{split}F_{l, s, m}(x) = \left\{ \begin{array}{rcl} 0, x < max(0, s + m - l) \\ \sum^{\lfloor x \rfloor}_{k = max(0, s + m - l)}\frac{C^k_mC^{s-k}_{l-m}}{C^s_l}, max(0, s + m - l) \leq x \leq min(s, m) \\ 1, x > min(s, m) \end{array}\right.\end{split}$

## class hypergeometric#

Syntax

namespace oneapi::mkl::rng {
template<typename IntType = std::int32_t, typename Method = hypergeometric_method::by_default>
class hypergeometric {
public:
using method_type = Method;
using result_type = IntType;
hypergeometric();
explicit hypergeometric(std::int32_t l, std::int32_T s, std::int32_T m);
std::int32_t s() const;
std::int32_t m() const;
std::int32_t l() const;
};
}


Template parameters

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

• std::uint32_t

typename Method = oneapi::mkl::rng::hypergeometric_method::by_default

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

• oneapi::mkl::rng::hypergeometric_method::by_default

• oneapi::mkl::rng::hypergeometric_method::h2pe

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

hypergeometric()

Default constructor

explicit hypergeometric(std::int32_t l, std::int32_T s, std::int32_T m)

Constructor with parameters

std::int32_t s() const

Method to obtain lot size

std::int32_t m() const

Method to obtain size of sampling without replacement

std::int32_t l() const

Method to obtain number of marked elements

Member types

hypergeometric::method_type = Method


Description

The type which defines transformation method for generation.

hypergeometric::result_type = IntType


Description

The type which defines type of generated random numbers.

Constructors

hypergeometric::hypergeometric()


Description

Default constructor for distribution, parameters set as l = 1, s = 1, m = 1.

explicit hypergeometric::hypergeometric(std::int32_t l, std::int32_T s, std::int32_T m)


Description

Constructor with parameters. l is a lot size, s is a size of sampling without replacement, m is a number of marked elements.

Throws

oneapi::mkl::invalid_argument

Exception is thrown when $$s < 0$$, or $$m < 0$$, or $$l < (s > m ? s : m)$$

Characteristics

std::int32_t hypergeometric::l() const


Return Value

Returns the distribution parameter l - lot size value.

std::int32_t hypergeometric::s() const


Return Value

Returns the distribution parameter s - size of sampling without replacement.

std::int32_t hypergeometric::m() const


Return Value

Returns the distribution parameter m - number of marked elements.

Parent topic: Distributions