oneapi::mkl::rng::hypergeometric

Generates hypergeometrically distributed random values.

Description

The oneapi::mkl::rng::hypergeometric class object is used in the oneapi::mkl::rng::generate function to provide hypergeometrically distributed random values with lot size l, size of sampling s, and number of marked elements in the lot m, where l, m, s∈N∪{0}; l≥ 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_m^k C_{l-m}^{s-k}}{C_l^s}\]

, k∈ {max(0, s + m - l), …, min(s, m)}

The cumulative distribution function is as follows:

\[\begin{split}F_{l, s, m}(x) = \begin{cases} 0, & x < max (0, s + m - l)\\ \sum_{k = \max (0, s+m-l)}^{\lfloor x \rfloor} \frac{C_m^k C_{l-m}^{s-k}}{C_l^s}, & max (0, s + m - l) \leq x \leq \min (s, m)\\ 1, & x > \min(s, m) \end{cases}\end{split}\]

Product and Performance Information

Performance varies by use, configuration and other factors. Learn more at https://www.intel.com/PerformanceIndex. Notice revision #20201201

API

Syntax

template<typename IntType = std::int32_t, typename Method = hypergeometric_method::by_default>
class hypergeometric {
public:
  using method_type = Method;
  using result_type = IntType;
  hypergeometric(): hypergeometric(1, 1, 1){}
  explicit hypergeometric(std::int32_t l, std::int32_T s, std::int32_T m);
  explicit hypergeometric(const param_type& pt);
  std::int32_t s() const;
  std::int32_t m() const;
  std::int32_t l() const;
  param_type param() const;
  void param(const param_type& pt);
};

Devices supported: CPU and GPU

Include Files

  • oneapi/mkl/rng.hpp

Template Parameters

typename IntType = std::int32_t

Type of the produced values. The specific values are as follows:

std::int32_t

std::uint32_t

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

Generation method. The specific values are as follows:

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

See brief descriptions of the methods in Distributions Template Parameter Method.

Input Parameters

Name

Type

Description

l

std::int32_t

Lot size of l.

s

std::int32_t

Size of sampling without replacement.

m

std::int32_t

Number of marked elements m.