Skip to content

Commit

Permalink
Clarify definitions of inverse CDF functions (#1814)
Browse files Browse the repository at this point in the history
* Clarify definitions of inverse CDF functions

* Such that to for which

* Wrap "generalized" in parentheses
  • Loading branch information
sethaxen authored Jan 3, 2024
1 parent b2d7652 commit 9e72f1f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/univariates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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` 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)
Expand Down Expand Up @@ -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).
"""
Expand All @@ -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))

Expand Down

0 comments on commit 9e72f1f

Please sign in to comment.