Probability Distributions
Contents
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 atx.D::cdf_lower(x, ...)- Cumulative probability function atx.D::cdf_upper(x, ...)- Cumulative (from upper bound) probability function atx.D::invcdf_lower(P, ...)- The inverse of cumulative probability function atP.D::invcdf_lower(Q, ...)- The inverse of cumulative (from upper bound) probability function atQ.
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 |
|---|---|---|
Uniform real distribution in the range \([a,\,b]\) |
|
|
Normal/Gaussian distribution with standard deviation \(\sigma\) |
|
|
Specific to \(\sigma=1\) |
|
|
The gaussian tail distribution for \(x>a\) with standard deviation \(\sigma\) |
|
|
Specific to \(\sigma\) |
|
|
Bivariate Gaussian distribution with standard deviations \((\sigma_x, \sigma_y)\) and correlation coefficient \(\rho\) |
|
|
Lognormal distribution for \(x > 0\) |
|
|
Exponential power distribution functions with scale parameter \(a\) and exponential \(b\) |
|
|
Exponential distribution functions with mean \(\mu\) |
|
|
Laplace distribution functions with with \(a\) |
|
|
Cauchy distribution (also known as Lorentz distribution) with scale parameter \(a\) |
|
|
Rayleigh distribution with scale parameter \(\sigma\) |
|
|
Tail of Rayleigh distribution with scale parameter \(\sigma\) and a lower limit \(a\) |
|
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
-
static double pdf(double x, 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\).
-
static double pdf(double x, double sigma) noexcept
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\).
Bivariate Gaussian Distribution
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
-
static double pdf(double x, double zeta, double sigma) noexcept
Exponential Distributions
Exponential Power Distribution
-
class ExpPowDist
ExpPowDist- exponential power distribution functions with scale parameteraand exponentialb, 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\).
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\).
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)\).
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)\).
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\).