multinomial#
Class is used for generation of multinomially distributed integer types random numbers.
Description
The class object is used in the oneapi::mkl::rng::generate() function to provide n random numbers multinomially distributed, with independent trials \((ntrial, m)\) and possible mutually exclusive outcomes \(k\), with corresponding probabilities \(p_i\), where \(p_i \in R; 0 \leq p_i \leq 1; m, k \in N\).
The probability distribution is given by:
class multinomial#
Syntax
namespace oneapi::mkl::rng {
template<typename IntType = std::int32_t, typename Method = multinomial_method::by_default>
class multinomial {
public:
using method_type = Method;
using result_type = IntType;
explicit multinomial(double ntrial, std::vector<double> p);
std::int32_t ntrial() const;
std::vector<double> p() const;
};
}
Template parameters
- typename IntType
- Type of the produced values. Supported types:
std::int32_t
std::uint32_t
- typename Method = oneapi::mkl::rng::multinomial_method::by_default
Transformation method, which will be used for generation. Supported types:
oneapi::mkl::rng::multinomial_method::by_default
oneapi::mkl::rng::multinomial_method::poisson_icdf_based
See description of the methods in Distributions methods template parameter.
Class Members
Routine |
Description |
---|---|
Constructor with parameters |
|
Method to obtain number of independent trials |
|
Method to obtain probability vector of possible outcomes |
Member types
multinomial::method_type = Method
Description
The type which defines the transformation method for generation.
multinomial::result_type = IntType
Description
The type which defines the type of generated random numbers.
Constructors
explicit multinomial::multinomial(double ntrial, std::vector<double> p)
Description
Constructor with parameters. ntrial is a number of independent trials, p is a probability vector.
Throws
- oneapi::mkl::invalid_argument
Exception is thrown when \(ntrial < 0\), or \(p.size() < 1\)
Characteristics
std::int32_t multinomial::ntrial() const
Return Value
Returns the distribution parameter ntrial.
std::vector<double> multinomial::p() const
Return Value
Returns the distribution parameter p.
Parent topic: Distributions