.. _oneapi-mkl-rng-device-uniform-discrete: oneapi::mkl::rng::device::uniform (Discrete) ============================================ Generates random numbers uniformly distributed over the interval ``[a, b)``. .. contents:: :local: :depth: 1 Description *********** The ``oneapi::mkl::rng::device::uniform`` class object is used in ``oneapi::mkl::rng::device::generate`` functions to provide random numbers uniformly distributed over the interval ``[a, b)``, where ``a, b`` are the left and right bounds of the interval respectively, and ``a, b∈Z; a < b``. The probability distribution is given by: .. math:: P(X = k) = \frac{1}{b-a}, k \in \{a, a + 1, \ldots, b-1\} The cumulative distribution function is as follows: .. math:: 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 API *** Syntax ------ .. code-block:: cpp template class uniform { public: using method_type = Method; using result_type = Type; uniform(): uniform((Type)0, std::is_same::value ? (1 << 23) : std::numeric_limits::max()){}; explicit uniform(Type a, Type b); explicit uniform(const param_type& pt); Type a() const; Type b() const; param_type param() const; void param(const param_type& pt); }; Include Files ------------- - ``oneapi/mkl/rng/device.hpp`` Template Parameters ------------------- .. list-table:: :header-rows: 0 * - ``typename Method`` - Generation method. The specific values are as follows: ``oneapi::mkl::rng::device::uniform_method::standard`` ``oneapi::mkl::rng::device::uniform_method::accurate`` See brief descriptions of the methods in :ref:`distributions-template-parameter-method`. .. note:: The ``oneapi::mkl::rng::device::uniform_method::standard`` uses the ``s`` BRNG type. This might cause the produced numbers to have incorrect statistics (due to rounding error) when :math:`(abs(b – a) > 2^{23} || abs(b) > 2^{23} || abs(a) > 2^{23})`. To get proper statistics for this case, use the ``oneapi::mkl::rng::device::uniform_method::accurate`` method instead. Input Parameters ---------------- .. list-table:: :header-rows: 1 * - Name - Type - Description * - c - ``std::int32_t`` ``std::uint32_t`` - Left bound ``a`` * - d - ``std::int32_t`` ``std::uint32_t`` - Right bound ``b``