beta

Class is used for generation of beta distributed real types random numbers.

Description

The class object is used in the oneapi::mkl::rng::generate() function to provide random numbers beta distributed with shape parameters \(p\) and \(q\), displacement \(\alpha\) and scale parameter \((b, \beta)\), where \(p\), \(q\). \(\alpha\), \(\beta\) \(\in R; p > 0; q > 0; \beta > 0\).

The probability distribution is given by:

\[\begin{split}f_{p, q, \alpha, \beta}(x) = \left\{ \begin{array}{rcl} \frac{1}{B(p, q) * \beta^{p + q - 1}}(x - a)^{p - 1}*(\beta + \alpha - x)^{q - 1}, \alpha \leq x < \alpha + \beta \\ 0, x < \alpha, x \ge \alpha + \beta \end{array}\right.\end{split}\]

The cumulative distribution function is as follows:

\[\begin{split}F_{a, b}(x) = \left\{ \begin{array}{rcl} 0, x < \alpha \\ \int^x_{\alpha}\frac{1}{B(p, q) * \beta^{p + q - 1}}(y - \alpha)^{p - 1}*(\beta + \alpha - y)^{q - 1}dy, \alpha \leq x < \alpha + \beta, x \in R \\ 1, x \ge \alpha + \beta \end{array}\right.\end{split}\]

Where \(B(p, 1)\) is the complete beta function.

class beta

Syntax

namespace oneapi::mkl::rng {
template<typename RealType = float, typename Method = beta_method::by_default>
class beta {
public:
    using method_type = Method;
    using result_type = RealType;
    beta();
    explicit beta(RealType p, RealType q, RealType a, RealType b);
    RealType p() const;
    RealType q() const;
    RealType a() const;
    RealType b() const;
};
}

Template parameters

typename RealType
Type of the produced values. Supported types:
  • float

  • double

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

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

  • oneapi::mkl::rng::beta_method::by_default

  • oneapi::mkl::rng::beta_method::cja

  • oneapi::mkl::rng::beta_method::cja_accurate

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

beta()

Default constructor

explicit beta(RealType p, RealType q, RealType a, RealType b)

Constructor with parameters

RealType p() const

Method to obtain shape p

RealType q() const

Method to obtain shape q

RealType a() const

Method to obtain displacement \(\alpha\)

RealType b() const

Method to obtain scalefactor \(\beta\)

Member types

beta::method_type = Method

Description

The type which defines transformation method for generation.

beta::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

beta::beta()

Description

Default constructor for distribution, parameters set as p = 1.0, q = 0.0, \(\alpha\) = 1.0, \(\beta\) = 1.0.

explicit beta::beta(RealType p, RealType q, RealType a, RealType b)

Description

Constructor with parameters. p and q are shapes, \(\alpha\) is a displacement, \(\beta\) is a scalefactor.

Throws

oneapi::mkl::invalid_argument

Exception is thrown when \(p \leq 0.0f\), or \(q \leq 0.0f\), or \(\beta \leq 0.0f\)

Characteristics

RealType beta::p() const

Return Value

Returns the distribution parameter p - shape.

RealType beta::q() const

Return Value

Returns the distribution parameter q - shape.

RealType beta::a() const

Return Value

Returns the distribution parameter \(\alpha\) - displacement.

RealType beta::b() const

Return Value

Returns the distribution parameter \(\beta\) - scalefactor.

Parent topic: Distributions