bernoulli#
Generates Bernoulli distributed random values.
Description
The bernoulli
class object is used in the generate
and function
to provide Bernoulli distributed random numbers with probability p
of a single trial success,
where \(p \in R; 0 \leq p \leq 1\).
The probability distribution is given by:
The cumulative distribution function is as follows:
class bernoulli#
Syntax
namespace oneapi::mkl::rng::device {
template<typename IntType, typename Method>
class bernoulli {
public:
using method_type = Method;
using result_type = IntType;
bernoulli();
explicit bernoulli(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::bernoulli_method::by_default
Transformation method, which will be used for generation. Supported types:
oneapi::mkl::rng::bernoulli_method::by_default
oneapi::mkl::rng::bernoulli_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 p |
Member types
bernoulli::method_type = Method
Description
The type which defines transformation method for generation.
bernoulli::result_type = IntType
Description
The type which defines type of generated random numbers.
Constructors
bernoulli::bernoulli()
Description
Default constructor for distribution, parameters set as p = 0.5f.
explicit bernoulli::bernoulli(float p)
Description
Constructor with parameters. p is a probability.
Throws
- oneapi::mkl::invalid_argument
Exception is thrown when p > 1, or p < 0
Characteristics
float bernoulli::p() const
Return Value
Returns the distribution parameter p - probability.
Parent topic: Device Distributions