Generates hypergeometrically distributed random values.


template<typename IntType = std::int32_t, typename Method = hypergeometric_method::by_default>
class hypergeometric {
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);
std::int32_t s() const;
std::int32_t m() const;
std::int32_t l() const;

Devices supported: Host and CPU

Include Files

  • oneapi/mkl/rng.hpp


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:)


, k∈ {max(0, s + m - l), …, min(s, m)} The cumulative distribution function is as follows:


Intel’s compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. Notice revision #20110804

This notice covers the following instruction sets: SSE2, SSE4.2, AVX2, AVX-512.

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 Values

Input Parameters






Lot size of l.



Size of sampling without replacement.



Number of marked elements m.