14.7 Cumulative distribution functions
For most of the univariate probability functions, there is a corresponding cumulative distribution function, log cumulative distribution function, and log complementary cumulative distribution function.
For a univariate random variable Y with probability function pY(y|θ), the cumulative distribution function (CDF) FY is defined by FY(y) = Pr[Y≤y] = ∫y−∞p(y|θ) dy. The complementary cumulative distribution function (CCDF) is defined as Pr[Y>y] = 1−FY(y). The reason to use CCDFs instead of CDFs in floating-point arithmetic is that it is possible to represent numbers very close to 0 (the closest you can get is roughly 10−300), but not numbers very close to 1 (the closest you can get is roughly 1−10−15).
In Stan, there is a cumulative distribution function for each
probability function. For instance, normal_cdf(y, mu, sigma)
is
defined by ∫y−∞Normal(y|μ,σ) dy. There are also log forms of the CDF and CCDF for most
univariate distributions. For example, normal_lcdf(y | mu, sigma)
is defined by log(∫y−∞Normal(y|μ,σ) dy) and normal_lccdf(y | mu, sigma)
is defined by log(1−∫y−∞Normal(y|μ,σ) dy).