chi_square#

Class is used for generation of chi-square distributed real types random numbers.

Description

The class object is used in the oneapi::mkl::rng::generate() function to provide random numbers chi-square distributed with \(n\) degrees of freedom, \(n \in N; n > 0\).

The probability distribution is given by:

\[\begin{split}f_{n}(x) = \left\{ \begin{array}{rcl} \frac{x^{\frac{n - 2}{2}}e^{-\frac{x}{2}}}{2^{n/2}\Gamma(n/2)}, x \ge 0 \\ 0, x < 0 \end{array}\right.\end{split}\]

The cumulative distribution function is as follows:

\[\begin{split}F_{n}(x) = \left\{ \begin{array}{rcl} \int^{x}_{0}\frac{y^{\frac{n - 2}{2}}e^{-\frac{x}{2}}}{2^{n/2}\Gamma(n/2)}dy, x \ge 0 \\ 0, x < 0 \end{array}\right.\end{split}\]

class chi_square#

Syntax

namespace oneapi::mkl::rng {
template<typename RealType = float, typename Method = chi_square_method::by_default>
class chi_square {
public:
    using method_type = Method;
    using result_type = RealType;
    chi_square();
    explicit chi_square(std::int32_t n);
    std::int32_t n() const;
};
}

Template parameters

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

  • double

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

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

  • oneapi::mkl::rng::chi_square_method::by_default

  • oneapi::mkl::rng::chi_square_method::gamma_based

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

chi_square()

Default constructor

explicit chi_square(std::int32_t n)

Constructor with parameters

std::int32_t n() const

Method to obtain number of degrees of freedom n

Member types

chi_square::method_type = Method

Description

The type which defines transformation method for generation.

chi_square::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

chi_square::chi_square()

Description

Default constructor for distribution, parameters set as n = 5.

explicit chi_square::chi_square(std::int32_t n)

Description

Constructor with parameters. n is the number of degrees of freedom.

Throws

oneapi::mkl::invalid_argument

Exception is thrown when \(n < 1\)

Characteristics

std::int32_t chi_square::n() const

Return Value

Returns the distribution parameter n - number of degrees of freedom.

Parent topic: Distributions