Probability Distributions

Introduction

This component provides subroutines for computing probability distribution functions (i.e., pdf, cdf, etc.). For any continuous probability distribution represented by a class D, we have the following static methods to compute different function values:

  • D::pdf(x, ...) - Probability density function at x.

  • D::cdf_lower(x, ...) - Cumulative probability function at x.

  • D::cdf_upper(x, ...) - Cumulative (from upper bound) probability function at x.

  • D::invcdf_lower(P, ...) - The inverse of cumulative probability function at P.

  • D::invcdf_lower(Q, ...) - The inverse of cumulative (from upper bound) probability function at Q.

Here ... represents the additional arguments specific to the target distribution.

Note that these methods are optional, i.e., for some distributions, not all of these methods are available.

The following variables, functions and classes are all defined within the namespace HIPP::NUMERICAL.

Example: we compute the probability density function and cumulative probability function of the Gaussian distribution by the static methods of class GaussianDist:

using namespace HIPP;
using namespace HIPP::NUMERICAL;

double sigma = 2.0;
pout << "Gaussian distribution p(x) and cumulative P(x):\n";
for( auto x : {0., 1., 2., 3., 4., 5.} )
    pout << "p(", x, ") = ",  GaussianDist::pdf(x, sigma),
        ", P(", x, ") = ", GaussianDist::cdf_lower(x, sigma), endl;

The output is:

Gaussian distribution p(x) and cumulative P(x):
p(0) = 0.199471, P(0) = 0.5
p(1) = 0.176033, P(1) = 0.691462
p(2) = 0.120985, P(2) = 0.841345
p(3) = 0.0647588, P(3) = 0.933193
p(4) = 0.0269955, P(4) = 0.97725
p(5) = 0.00876415, P(5) = 0.99379

Table of Available Distributions

We summary the available distribution class and its methods in the following table:

Class

Probability Distribution

Methods

UniformRealDist

Uniform real distribution in the range \([a,\,b]\)

pdf(x,a,b), cdf_lower(x,a,b), cdf_upper(x,a,b), invcdf_lower(P,a,b), invcdf_upper(Q,a,b)

GaussianDist

Normal/Gaussian distribution with standard deviation \(\sigma\)

pdf(x,sigma), cdf_lower(x,sigma), cdf_upper(x,sigma), invcdf_lower(P,sigma), invcdf_upper(Q,sigma)

Specific to \(\sigma=1\)

pdf_unit(x), cdf_lower_unit(x), cdf_upper_unit(x), invcdf_lower_unit(P), invcdf_upper_unit(Q)

GaussianTailDist

The gaussian tail distribution for \(x>a\) with standard deviation \(\sigma\)

pdf(x,a,sigma)

Specific to \(\sigma\)

pdf_unit(x,a)

BivariateGaussianDist

Bivariate Gaussian distribution with standard deviations \((\sigma_x, \sigma_y)\) and correlation coefficient \(\rho\)

pdf(x,y,sigma_x,sigma_y, rho)

LognormalDist

Lognormal distribution for \(x > 0\)

pdf(x,zeta,sigma), cdf_lower(x,zeta,sigma), cdf_upper(x,zeta,sigma), invcdf_lower(P,zeta,sigma), invcdf_upper(Q,zeta,sigma)

ExpPowDist

Exponential power distribution functions with scale parameter \(a\) and exponential \(b\)

pdf(x,a,b), cdf_lower(x,a,b), cdf_upper(x,a,b)

ExponentialDist

Exponential distribution functions with mean \(\mu\)

pdf(x,mu), cdf_lower(x,mu), cdf_upper(x,mu), invcdf_lower(P,mu), invcdf_upper(Q,mu)

LaplaceDist

Laplace distribution functions with with \(a\)

pdf(x,a), cdf_lower(x,a), cdf_upper(x,a), invcdf_lower(P,a), invcdf_upper(Q,a)

CauchyDist

Cauchy distribution (also known as Lorentz distribution) with scale parameter \(a\)

pdf(x,a), cdf_lower(x,a), cdf_upper(x,a), invcdf_lower(P,a), invcdf_upper(Q,a)

RayleighDist

Rayleigh distribution with scale parameter \(\sigma\)

pdf(x,sigma), cdf_lower(x,sigma), cdf_upper(x,sigma), invcdf_lower(P,sigma), invcdf_upper(Q,sigma)

RayleighTailDist

Tail of Rayleigh distribution with scale parameter \(\sigma\) and a lower limit \(a\)

pdf(x,a,sigma)

Uniform Real Distribution

class UniformRealDist

UniformRealDist - the distribution function is uniform in \([a, b]\), i.e.,

\[p(x) = \frac{1}{b-a} .\]
static double pdf(double x, double a, double b) noexcept
static double cdf_lower(double x, double a, double b) noexcept
static double cdf_upper(double x, double a, double b) noexcept
static double invcdf_lower(double P, double a, double b) noexcept
static double invcdf_upper(double Q, double a, double b) noexcept

Gaussian Distributions

Gaussian Distribution

class GaussianDist

The Normal (Gaussian) distribution with standard deviation \(\sigma\).

static double pdf(double x, double sigma) noexcept
static double cdf_lower(double x, double sigma) noexcept
static double cdf_upper(double x, double sigma) noexcept
static double invcdf_lower(double P, double sigma) noexcept
static double invcdf_upper(double Q, double sigma) noexcept

Calls for the Gaussian dist with standard deviation \(\sigma\).

static double pdf_unit(double x) noexcept
static double cdf_lower_unit(double x) noexcept
static double cdf_upper_unit(double x) noexcept
static double invcdf_lower_unit(double P) noexcept
static double invcdf_upper_unit(double Q) noexcept

Calls for the unit gaussian dist., i.e., \(\sigma = 1\).

Gaussian Tail Distribution

class GaussianTailDist

GaussianTailDist - for the gaussian tail distribution, i.e., its pdf is the upper tail of a full normal distribution \(\mathcal{N}(x|0, \sigma)\), with \(x > a\).

static double pdf(double x, double a, double sigma) noexcept
static double pdf_unit(double x, double a) noexcept

Bivariate Gaussian Distribution

class BivariateGaussianDist
static double pdf(double x, double y, double sigma_x, double sigma_y, double rho) noexcept

Lognormal Distribution

class LognormalDist

LognormalDist - the lognormal distribution for \(x > 0\), i.e.

\[p(x) = \frac{1}{ x \sqrt{ 2 \pi \sigma^2} } \exp( - \frac{( {\rm ln}(x) - \zeta )^2}{2 \sigma^2} ) .\]
static double pdf(double x, double zeta, double sigma) noexcept
static double cdf_lower(double x, double zeta, double sigma) noexcept
static double cdf_upper(double x, double zeta, double sigma) noexcept
static double invcdf_lower(double P, double zeta, double sigma) noexcept
static double invcdf_upper(double Q, double zeta, double sigma) noexcept

Exponential Distributions

Exponential Power Distribution

class ExpPowDist

ExpPowDist - exponential power distribution functions with scale parameter a and exponential b, i.e.

\[p(x) = \frac{1}{ 2 a \Gamma(1+1/b) } \exp( -| x / a |^b ),\]

for \(x >= 0\).

Special cases:

  • \(b = 1\): Laplace distribution.

  • \(b = 2\): Gaussian distribution with \(a = \sqrt{2} \sigma\).

static double pdf(double x, double a, double b) noexcept
static double cdf_lower(double x, double a, double b) noexcept
static double cdf_upper(double x, double a, double b) noexcept

Exponential Distribution

class ExponentialDist

ExponentialDist - exponential distribution functions with mean \(\mu\), i.e.,

\[p(x) = \frac{1}{\mu} \exp( - \frac{x}{\mu} ),\]

for \(x \geqslant 0\).

static double pdf(double x, double mu) noexcept
static double cdf_lower(double x, double mu) noexcept
static double cdf_upper(double x, double mu) noexcept
static double invcdf_lower(double P, double mu) noexcept
static double invcdf_upper(double Q, double mu) noexcept

Laplace Distribution

class LaplaceDist

LaplaceDist - laplace distribution functions with with \(a\), i.e.,

\[p(x) = \frac{1}{2a} \exp( -|x/a| ),\]

for \(x \in (-\infty, \infty)\).

static double pdf(double x, double a) noexcept
static double cdf_lower(double x, double a) noexcept
static double cdf_upper(double x, double a) noexcept
static double invcdf_lower(double P, double a) noexcept
static double invcdf_upper(double Q, double a) noexcept

Cauchy Distribution

class CauchyDist

Cauchy distribution (also known as Lorentz distribution) with scale parameter \(a\), i.e.,

\[p(x) = \frac{1}{a \pi ( 1 + (x/a)^2 )},\]

for \(x \in (-\infty, \infty)\).

double pdf(double x, double a) noexcept
double cdf_lower(double x, double a) noexcept
double cdf_upper(double x, double a) noexcept
double invcdf_lower(double P, double a) noexcept
double invcdf_upper(double Q, double a) noexcept

Rayleigh Distributions

Rayleigh Distribution

class RayleighDist

Rayleigh distribution with scale parameter \(\sigma\), i.e.,

\[p(x) = \frac{x}{\sigma^2} \exp( - \frac{x^2}{2 \sigma^2} ),\]

for \(x > 0\).

double pdf(double x, double sigma) noexcept
double cdf_lower(double x, double sigma) noexcept
double cdf_upper(double x, double sigma) noexcept
double invcdf_lower(double P, double sigma) noexcept
double invcdf_upper(double Q, double sigma) noexcept

Rayleigh Tail Distribution

class RayleighTailDist

Tail of Rayleigh distribution with scale parameter \(\sigma\) and a lower limit \(a\), i.e.,

\[p(x) = \frac{x}{\sigma^2} \exp( \frac{a^2-x^2}{2 \sigma^2} ),\]

for \(x > a\).

double pdf(double x, double a, double sigma) noexcept