geometric#

Class is used for generation of geometrically distributed integer types random numbers.

Description

The class object is used in the oneapi::mkl::rng::generate() function to provide random numbers geometrically distributed with probability \(p\) of a single success trial, where \(p \in R; 0 < p < 1\).

The probability distribution is given by:

\[P(X = k) = p * (1 - p)^k, k = \{0, 1, 2, ... \}.\]

The cumulative distribution function is as follows:

\[\begin{split}F_{p}(x) = \left\{ \begin{array}{rcl} 0, x < 0 \\ 1 - (1 - p)^{\lfloor x + 1 \rfloor}, x \ge 0 \end{array}\right.\end{split}\]

class geometric#

Syntax

namespace oneapi::mkl::rng {
template<typename IntType = std::int32_t, typename Method = geometric_method::by_default>
class geometric {
public:
    using method_type = Method;
    using result_type = IntType;
    geometric();
    explicit geometric(float p);
    float p() const;
};
}

Template parameters

typename IntType
Type of the produced values. Supported types:
  • std::int32_t

  • std::uint32_t

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

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

  • oneapi::mkl::rng::geometric_method::by_default

  • oneapi::mkl::rng::geometric_method::icdf

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

geometric()

Default constructor

explicit geometric(float p)

Constructor with parameters

float p() const

Method to obtain probability value

Member types

geometric::method_type = Method

Description

The type which defines transformation method for generation.

geometric::result_type = IntType

Description

The type which defines type of generated random numbers.

Constructors

geometric::geometric()

Description

Default constructor for distribution, parameters set as p = 0.5.

explicit geometric::geometric(float p)

Description

Constructor with parameters. p is a probability value.

Throws

oneapi::mkl::invalid_argument

Exception is thrown when \(p \ge 1.0f\), or \(p \leq 0.0f\)

Characteristics

float geometric::p() const

Return Value

Returns the distribution parameter p - probability value.

Parent topic: Distributions