BioCMAMC-ST
MC::Distributions Namespace Reference

Kokkos compatible method to draw from specific probability distribution. More...

Classes

struct  LogNormal
 Represents a LogNormal (Gaussian) probability distribution. More...
 
struct  Normal
 Represents a normal (Gaussian) probability distribution. More...
 
struct  ScaledTruncatedNormal
 Represents a Scaled TruncatedNormal (Gaussian) probability distribution. More...
 
struct  SkewNormal
 Represents a SkewNormal (Gaussian) probability distribution. More...
 
struct  TruncatedNormal
 Represents a TruncatedNormal (Gaussian) probability distribution. More...
 

Concepts

concept  ProbabilityLaw
 Concept for probability distribution laws.
 

Functions

template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F erfinv (F x)
 Computes an approximation of the inverse error function.
 
template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F norminv (F p, F mean, F stddev)
 Computes the inverse CDF (probit function) of a normal distribution.
 
template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F std_normal_pdf (F x)
 Computes the standard normal probability density function (PDF).
 
template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F std_normal_cdf (F x)
 Computes the standard normal cumulative distribution function (CDF).
 

Detailed Description

Kokkos compatible method to draw from specific probability distribution.

Function Documentation

◆ erfinv()

template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F MC::Distributions::erfinv ( F x)

Computes an approximation of the inverse error function.

This function approximates the inverse error function erfinv(x) using Winitzki’s method (from A. Soranzo, E. Epure), which provides a simple and computationally efficient formula based on logarithms and square roots.

Template Parameters
FFloating-point type (must satisfy FloatingPointType).
Parameters
xInput value in the range [-1, 1].
Returns
Approximate value of erfinv(x).`.
Note
This implementation is not highly optimized for GPUs. For a more accurate and efficient implementation, see: https://people.maths.ox.ac.uk/gilesm/codes/erfinv/gems.pdf. See also bramowitz and Stegun method (Handbook of Mathematical Functions, formula 7.1.26)
Warning
This approximation is not valid for extreme values |x| close to 1.
Here is the caller graph for this function:

◆ norminv()

template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F MC::Distributions::norminv ( F p,
F mean,
F stddev )

Computes the inverse CDF (probit function) of a normal distribution.

This function returns the quantile function of a normal distribution with mean mean and standard deviation stddev, given a probability p.

Template Parameters
FFloating-point type (must satisfy FloatingPointType).
Parameters
pProbability value in the range (0,1).
meanMean of the normal distribution.
stddevStandard deviation of the normal distribution.
Returns
The corresponding value x such that P(X ≤ x) = p for X ~ N(mean, stddev).
Note
This implementation uses the inverse error function erfinv(x) for accuracy and efficiency. Extreme values may be clamped for stability.
Warning
p must be strictly in (0,1), otherwise the result is undefined.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ std_normal_cdf()

template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F MC::Distributions::std_normal_cdf ( F x)

Computes the standard normal cumulative distribution function (CDF).

The standard normal CDF is given by:

\[ \Phi(x) = \frac{1}{2} \left( 1 + \operatorname{erf} \left( \frac{x}{\sqrt{2}} \right) \right) \]

Template Parameters
FFloating-point type (must satisfy FloatingPointType).
Parameters
xInput value.
Returns
Value of the standard normal CDF at x, which is P(X ≤ x) for X ~ N(0,1).
Here is the caller graph for this function:

◆ std_normal_pdf()

template<FloatingPointType F>
KOKKOS_INLINE_FUNCTION F MC::Distributions::std_normal_pdf ( F x)

Computes the standard normal probability density function (PDF).

The standard normal PDF is given by:

\[ \phi(x) = \frac{1}{\sqrt{2\pi}} e^{-x^2 / 2} \]

Template Parameters
FFloating-point type (must satisfy FloatingPointType).
Parameters
xInput value.
Returns
Value of the standard normal PDF at x.
Note
This function is numerically stable.
Here is the caller graph for this function: