geometric#
Class is used for generation of geometrically distributed integer types random numbers.
Description
The class object is used in the oneapi::math::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:
The cumulative distribution function is as follows:
class geometric#
Syntax
namespace oneapi::math::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::math::rng::geometric_method::by_default
Transformation method, which will be used for generation. Supported types:
oneapi::math::rng::geometric_method::by_default
oneapi::math::rng::geometric_method::icdf
See description of the methods in Distributions methods template parameter.
Class Members
Routine |
Description |
---|---|
Default constructor |
|
Constructor with parameters |
|
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::math::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: Host Distributions