uniform (Discrete)#
Generates random numbers uniformly distributed over the interval [a, b)
.
Description
The uniform
class object is used in generate
and function
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 \in Z ; a < b\).
The probability distribution is given by:
The cumulative distribution function is as follows:
class uniform#
Syntax
namespace oneapi::mkl::rng::device {
template<typename Type, typename Method>
class uniform<Type, Method> {
public:
using method_type = Method;
using result_type = Type;
uniform();
explicit uniform(Type a, Type b);
Type a() const;
Type b() const;
};
}
Template parameters
- typename Type
Type of the produced values. Supported types:
std::int32_t
std::uint32_t
- typename Method = oneapi::mkl::rng::uniform_method::by_default
Transformation method, which will be used for generation. Supported types:
oneapi::mkl::rng::device::uniform_method::by_default
oneapi::mkl::rng::device::uniform_method::standard
oneapi::mkl::rng::device::uniform_method::accurate
See description of the methods in Distributions methods template parameter.
Class Members
Routine |
Description |
---|---|
Default constructor |
|
Constructor with parameters |
|
Method to obtain left bound a |
|
Method to obtain right bound b |
Constructors
uniform::uniform()
Description
Default constructor for distribution, parameters set as a = 0, b = (1 << 23) with uniform_method::standard
or std::numeric_limits<Type>::max() with uniform_method::accurate
.
explicit uniform::uniform(Type a, Type b)
Description
Constructor with parameters. a is a left bound, b is a right bound, assume \(a < b\).
Throws
- oneapi::mkl::invalid_argument
Exception is thrown when \(a \ge b\)
Characteristics
uniform::a() const
Return Value
Returns the distribution parameter a - left bound.
uniform::b() const
Return Value
Returns the distribution parameter b - right bound.
Parent topic: Device Distributions