oneapi::mkl::rng::uniform (Discrete)
¶
Generates random numbers uniformly distributed over the interval [a, b)
.
Syntax
template<typename Method> class uniform<std::(u)int32_t, Method> { public: using method_type = Method; using result_type = std::(u)int32_t; uniform(): uniform((std::(u)int32_t )(0), std::is_same<Method, uniform_method::standard>::value ? (1 << 23) :std::numeric_limits<Type>::max()){}; explicit uniform(std::(u)int32_t a, std::(u)int32_t b); explicit uniform(const param_type& pt); std::(u)int32_t a() const; std::(u)int32_t b() const; param_type param() const; void param(const param_type& pt); };
Devices supported: Host, CPU, and GPU.
Include Files
oneapi/mkl/rng.hpp
Description
The
oneapi::mkl::rng::uniform
class object is used in oneapi::mkl::rng::generate functions to provide random numbers uniformly distributed over the interval[a, b)
, wherea, b
are the left and right bounds of the interval respectively, anda, b∈Z; a < b
.The probability distribution is given by:
P(X = k) = \frac{1}{b-a} k \in \{a, a + 1, \ldots, b-1\}
The cumulative distribution function is as follows:
F_{a, b}(x) = \begin{cases} 0, & x < a \\ \frac{x-a + 1}{b-a}, & a \leq x < b \\ 1, & x \geq b \end{cases}, x \in R
Template Parameters
typename Method = oneapi::mkl::rng::uniform_method::by_default
Generation method. The specific values are as follows:
oneapi::mkl::rng::uniform_method::standard
oneapi::mkl::rng::uniform_method::accurate
See brief descriptions of the methods in Distributions Template Parameter Method.
Note
The
oneapi::mkl::rng::uniform_method::standard
uses thes
BRNG type on GPU devices. This might cause the produced numbers to have incorrect statistics (due to rounding error) when (abs(b – a) > 2^{23} || abs(b) > 2^{23} || abs(a) > 2^{23}). To get proper statistics for this case, use theoneapi::mkl::rng::uniform_method::accurate
method instead.Input Parameters
Name
Type
Description
a
std::int32_t
std::uint32_t
Left bound
a
b
std::int32_t
std::uint32_t
Right bound
b