binomial
Contents
binomial#
Class is used for generation of binomially distributed integer types random numbers.
Description
The class object is used in the oneapi::mkl::rng::generate() function to provide random numbers binomially distributed with a number of independent Bernoulli trials \(m\), and with probability \(p\) of a single trial success, where \(p \in R; 0 \leq p \leq 1, m \in N\).
A binomially distributed variate represents the number of successes in \(m\) independent Bernoulli trials with probability of a single trial success \(p\).
The probability distribution is given by:
The cumulative distribution function is as follows:
class binomial#
Syntax
namespace oneapi::mkl::rng {
template<typename IntType = std::int32_t, typename Method = binomial_method::by_default>
class binomial {
public:
using method_type = Method;
using result_type = IntType;
binomial();
explicit binomial(std::int32_t ntrial, double p);
std::int32_t ntrial() const;
double p() const;
};
}
Template parameters
- typename IntType
- Type of the produced values. Supported types:
std::int32_t
- typename Method = oneapi::mkl::rng::binomial_method::by_default
Transformation method, which will be used for generation. Supported types:
oneapi::mkl::rng::binomial_method::by_default
oneapi::mkl::rng::binomial_method::btpe
See description of the methods in Distributions methods template parameter.
Class Members
Routine |
Description |
---|---|
Default constructor |
|
Constructor with parameters |
|
Method to obtain number of independent trials m |
|
Method to obtain success probability of a single trial p |
Member types
binomial::method_type = Method
Description
The type which defines transformation method for generation.
binomial::result_type = IntType
Description
The type which defines type of generated random numbers.
Constructors
binomial::binomial()
Description
Default constructor for distribution, parameters set as m = 5, p = 0.5.
explicit binomial::binomial(std::int32_t ntrial, double p)
Description
Constructor with parameters. ntrial is the number of independent trials, p is the success probability of a single trial.
Throws
- oneapi::mkl::invalid_argument
Exception is thrown when \(p > 1.0\), or \(p < 0.0\), or \(ntrial < 1\)
Characteristics
std::int32_t binomial::ntrial() const
Return Value
Returns the distribution parameter m - number of independent trials.
double binomial::p() const
Return Value
Returns the distribution parameter p - success probability of a single trial.
Parent topic: Distributions