Visible to Intel only — GUID: GUID-90ECCA9F-2C4A-4FD4-B5F8-5478B5D02642
Visible to Intel only — GUID: GUID-90ECCA9F-2C4A-4FD4-B5F8-5478B5D02642
uniform (Discrete)
Generates random numbers uniformly distributed over the interval [a, b).
Description
The uniform class object is used in 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 .
The probability distribution is given by:
![](/content/dam/docs/us/en/developer-reference-dpcpp/2024-2/4A24B4E1-E6A5-4DD3-86B3-29EDAA197C94-low.png)
The cumulative distribution function is as follows:
![](/content/dam/docs/us/en/developer-reference-dpcpp/2024-2/66308D51-C1E6-4A96-B04B-930ADEE4D55B-low.png)
API
Syntax
namespace oneapi::mkl::rng::device {
template<typename Type, typename Method>
class uniform<std::(u)int32_t, Method> {
public:
using method_type = Method;
using result_type = Type;
uniform(): uniform((Type)0,
std::is_same<Method,
uniform_method::standard>::value ? (1 << 23) :
std::numeric_limits<Type>::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
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 Distributions Template Parameter Method. |
![](/content/dam/docs/us/en/developer-reference-dpcpp/2024-2/3F57799E-2F00-4EDD-9CCF-D2829F3C4F56-low.png)
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 |