laplace

Contents

laplace#

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

Description

The class object is used in the oneapi::math::rng::generate() function to provide random numbers Laplace distributed with mean value (or average) \(a\), and scalefactor \((b, \beta)\), where \(a, \beta \in R; \beta > 0\). The scalefactor value determines the standard deviation as \(\sigma = \beta\sqrt{2}\).

The probability distribution is given by:

\[f_{a, \beta}(x) = \frac{1}{\sqrt{2\beta}}exp(-\frac{|x - a|}{\beta}), x \in R.\]

The cumulative distribution function is as follows:

\[\begin{split}F_{a, \beta}(x) = \left\{ \begin{array}{rcl} \frac{1}{2}exp(-\frac{|x - a|}{\beta}), x \ge a \\ 1 - \frac{1}{2}exp(-\frac{|x - a|}{\beta}), x < a \end{array}\right.\end{split}\]

class laplace#

Syntax

template<typename RealType = float, typename Method = laplace_method::by_default>
class laplace {
public:
    using method_type = Method;
    using result_type = RealType;
    laplace();
    explicit laplace(RealType a, RealType b);
    RealType a() const;
    RealType b() const;
};

Template parameters

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

  • double

typename Method = oneapi::math::rng::laplace_method::by_default

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

  • oneapi::math::rng::laplace_method::by_default

  • oneapi::math::rng::laplace_method::icdf

See description of the methods in Distributions methods template parameter.

Class Members

Routine

Description

laplace()

Default constructor

explicit laplace(RealType a, RealType b)

Constructor with parameters

RealType a() const

Method to obtain mean value

RealType b() const

Method to obtain scalefactor value

Member types

laplace::method_type = Method

Description

The type which defines transformation method for generation.

laplace::result_type = RealType

Description

The type which defines type of generated random numbers.

Constructors

laplace::laplace()

Description

Default constructor for distribution, parameters set as a = 0.0, and beta = 1.0.

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

Description

Constructor with parameters. a is a mean value, beta is a scalefactor value.

Throws

oneapi::math::invalid_argument

Exception is thrown when \(b \leq\) static_cast<RealType>(0.0)

Characteristics

RealType laplace::a() const

Return Value

Returns the distribution parameter a - mean value.

RealType laplace::b() const

Return Value

Returns the distribution parameter b - scalefactor value.

Parent topic: Host Distributions