From 68c65943acbd72d6ce0f71ca33b130f2f5676221 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Mon, 1 Jan 2024 11:35:47 +0100 Subject: [PATCH 1/3] Clarify definitions of inverse CDF functions --- src/univariates.jl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/univariates.jl b/src/univariates.jl index ca83d727e..46c3a51fe 100644 --- a/src/univariates.jl +++ b/src/univariates.jl @@ -182,7 +182,8 @@ std(d::UnivariateDistribution) = sqrt(var(d)) """ median(d::UnivariateDistribution) -Return the median value of distribution `d`. The median is the smallest `x` such that `cdf(d, x) ≥ 1/2`. +Return the median value of distribution `d`. The median is the smallest `x` in the support +of `d` such that `cdf(d, x) ≥ 1/2`. Corresponding to this definition as 1/2-quantile, a fallback is provided calling the `quantile` function. """ median(d::UnivariateDistribution) = quantile(d, 1//2) @@ -381,7 +382,10 @@ logccdf(d::UnivariateDistribution, x::Real) = log(ccdf(d, x)) """ quantile(d::UnivariateDistribution, q::Real) -Evaluate the inverse cumulative distribution function at `q`. +Evaluate the generalized inverse cumulative distribution function at `q`. + +For a given `0 ≤ q ≤ 1`, `quantile(d, q)` is the smallest value `x` in the support of `d` +for which `cdf(d, x) ≥ q`. See also: [`cquantile`](@ref), [`invlogcdf`](@ref), and [`invlogccdf`](@ref). """ @@ -397,14 +401,20 @@ cquantile(d::UnivariateDistribution, p::Real) = quantile(d, 1.0 - p) """ invlogcdf(d::UnivariateDistribution, lp::Real) -The inverse function of logcdf. +The generalized inverse function of [`logcdf`](@ref). + +For a given `lp ≤ 0`, `invlogcdf(d, lp)` is the smallest value `x` in the support of `d` for +which `logcdf(d, x) ≥ lp`. """ invlogcdf(d::UnivariateDistribution, lp::Real) = quantile(d, exp(lp)) """ invlogccdf(d::UnivariateDistribution, lp::Real) -The inverse function of logccdf. +The generalized inverse function of [`logccdf`](@ref). + +For a given `lp ≤ 0`, `invlogccdf(d, lp)` is the smallest value `x` in the support of `d` +for which `logccdf(d, x) ≤ lp`. """ invlogccdf(d::UnivariateDistribution, lp::Real) = quantile(d, -expm1(lp)) From 9d8228791b373ebc708282b96c7a7ea3ac851a98 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Tue, 2 Jan 2024 08:27:08 +0100 Subject: [PATCH 2/3] Such that to for which --- src/univariates.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/univariates.jl b/src/univariates.jl index 46c3a51fe..5b4fef883 100644 --- a/src/univariates.jl +++ b/src/univariates.jl @@ -183,7 +183,7 @@ std(d::UnivariateDistribution) = sqrt(var(d)) median(d::UnivariateDistribution) Return the median value of distribution `d`. The median is the smallest `x` in the support -of `d` such that `cdf(d, x) ≥ 1/2`. +of `d` for which `cdf(d, x) ≥ 1/2`. Corresponding to this definition as 1/2-quantile, a fallback is provided calling the `quantile` function. """ median(d::UnivariateDistribution) = quantile(d, 1//2) From 25c8c07ff711e25802a2fb53106342b167d6dffa Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Tue, 2 Jan 2024 12:29:48 +0100 Subject: [PATCH 3/3] Wrap "generalized" in parentheses --- src/univariates.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/univariates.jl b/src/univariates.jl index 5b4fef883..b60e5a294 100644 --- a/src/univariates.jl +++ b/src/univariates.jl @@ -382,7 +382,7 @@ logccdf(d::UnivariateDistribution, x::Real) = log(ccdf(d, x)) """ quantile(d::UnivariateDistribution, q::Real) -Evaluate the generalized inverse cumulative distribution function at `q`. +Evaluate the (generalized) inverse cumulative distribution function at `q`. For a given `0 ≤ q ≤ 1`, `quantile(d, q)` is the smallest value `x` in the support of `d` for which `cdf(d, x) ≥ q`. @@ -401,7 +401,7 @@ cquantile(d::UnivariateDistribution, p::Real) = quantile(d, 1.0 - p) """ invlogcdf(d::UnivariateDistribution, lp::Real) -The generalized inverse function of [`logcdf`](@ref). +The (generalized) inverse function of [`logcdf`](@ref). For a given `lp ≤ 0`, `invlogcdf(d, lp)` is the smallest value `x` in the support of `d` for which `logcdf(d, x) ≥ lp`. @@ -411,7 +411,7 @@ invlogcdf(d::UnivariateDistribution, lp::Real) = quantile(d, exp(lp)) """ invlogccdf(d::UnivariateDistribution, lp::Real) -The generalized inverse function of [`logccdf`](@ref). +The (generalized) inverse function of [`logccdf`](@ref). For a given `lp ≤ 0`, `invlogccdf(d, lp)` is the smallest value `x` in the support of `d` for which `logccdf(d, x) ≤ lp`.