gaussian

Contents

gaussian#

Generates normally distributed random numbers.

Description

The gaussian class object is used in the generate and function to provide random numbers with normal (Gaussian) distribution with mean (a) and standard deviation (stddev, \(\sigma\) ), where \(a, \sigma \in \mathbb{R}; \sigma > 0\)

The probability density function is given by:

\[f_{a, \sigma} (x) = \frac{1}{\sigma \sqrt{2 \pi}} \exp \left( - \frac{(y-a)^2}{2\sigma^2} \right) dy, - \infty < x < + \infty\]

The cumulative distribution function is as follows:

\[F_{a, \sigma} (x) = \int_{-\infty}^{x} \frac{1}{\sigma \sqrt{2 \pi}} \exp \left( - \frac{(y-a)^2}{2\sigma^2} \right) dy, - \infty < x < + \infty\]

The cumulative distribution function \(F_{a, \sigma}(x)\) can be expressed in terms of standard normal distribution \(\phi(x)\) as

\[F_{a,\sigma}(x) = \phi((x - a)/\sigma)\]

class gaussian#

Syntax

namespace oneapi::math::rng::device {
  template<typename RealType, typename Method>
  class gaussian {
  public:
     using method_type = Method;
     using result_type = RealType;

     gaussian();
     explicit gaussian(RealType mean, RealType stddev);

     RealType mean() const;
     RealType stddev() const;
  };
}

Template parameters

typename RealType

Type of the produced values. Supported types:

  • float

  • double

typename Method

Generation method. The specific values are as follows:

  • oneapi::math::rng::device::gaussian_method::by_default

  • oneapi::math::rng::device::gaussian_method::box_muller2

See description of the methods in Distributions methods template parameter

Class Members

Routine

Description

gaussian()

Default constructor

explicit gaussian(RealType mean, RealType stddev)

Constructor with parameters

RealType mean() const

Method to obtain left bound a

RealType stddev() const

Method to obtain right bound b

Member types

gaussian::method_type = Method

Description

The type which defines transformation method for generation.

gaussian::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

gaussian::gaussian()

Description

Default constructor for distribution, parameters set as mean = 0.0, stddev = 1.0.

explicit gaussian::gaussian(RealType a, RealType b)

Description

Constructor with parameters. mean is a mean value, stddev is a standard deviation value.

Throws

oneapi::math::invalid_argument

Exception is thrown when stddev \(\leq 0\)

Characteristics

RealType gaussian::mean() const

Return Value

Returns the distribution parameter mean - mean value.

RealType gaussian::stddev() const

Return Value

Returns the distribution parameter stddev - standard deviation value.

Parent topic: Device Distributions