uniform (continuous)

Contents

uniform (continuous)#

Class is used for generation of uniformly distributed real types random numbers.

Description

The class object is used in the oneapi::mkl::rng::generate() 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 R; a < b\)

The probability distribution is given by:

\[\begin{split}f_{a, b}(x) = \left\{ \begin{array}{rcl} \frac{1}{b-a}, x \in [a, b) \\ 0, x \notin [a, b) \end{array}\right.\end{split}\]

The cumulative distribution function is as follows:

\[\begin{split}F_{a, b}(x) = \left\{ \begin{array}{rcl} 0, x < a \\ \frac{x - a}{b - a}, a \leq x < b, x \in R \\ 1, x \ge b \end{array}\right.\end{split}\]

class uniform#

Syntax

namespace oneapi::mkl::rng {
template<typename RealType = float, typename Method = uniform_method::by_default>
class uniform {
public:
    using method_type = Method;
    using result_type = RealType;
    uniform();
    explicit uniform(RealType a, RealType b);
    RealType a() const;
    RealType b() const;
};
}

Template parameters

typename RealType
Type of the produced values. Supported types:
  • float

  • double

typename Method = oneapi::mkl::rng::uniform_method::by_default

Transformation method, which will be used for generation. Supported types:

  • oneapi::mkl::rng::uniform_method::by_default

  • oneapi::mkl::rng::uniform_method::standard

  • oneapi::mkl::rng::uniform_method::accurate

See description of the methods in Distributions methods template parameter

Class Members

Routine

Description

uniform()

Default constructor

explicit uniform(RealType a, RealType b)

Constructor with parameters

RealType a() const

Method to obtain left bound a

RealType b() const

Method to obtain right bound b

Member types

uniform::method_type = Method

Description

The type which defines transformation method for generation.

uniform::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

uniform::uniform()

Description

Default constructor for distribution, parameters set as a = 0.0, b = 1.0.

explicit uniform::uniform(RealType a, RealType 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

RealType uniform::a() const

Return Value

Returns the distribution parameter a - left bound.

RealType uniform::b() const

Return Value

Returns the distribution parameter b - right bound.

Parent topic: Host Distributions