Skip to content

Commit

Permalink
fixing error in xval function in gumbel.jl (#1859)
Browse files Browse the repository at this point in the history
* fixing error in xval function in gumbel.jl

* implement Gumbel quantile function using xval

* adding Gumbel functions: ccdf, logccdf, cquantile, invlogcdf invlogccdf, mgf, cgf, cf

* Update src/univariate/continuous/gumbel.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

* Update src/univariate/continuous/gumbel.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

* Update src/univariate/continuous/gumbel.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

---------

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
  • Loading branch information
ajshephard and devmotion authored May 29, 2024
1 parent 24de004 commit fe57164
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/univariate/continuous/gumbel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ entropy(d::Gumbel) = log(d.θ) + 1 + MathConstants.γ
#### Evaluation

zval(d::Gumbel, x::Real) = (x - d.μ) / d.θ
xval(d::Gumbel, z::Real) = x * d.θ + d.μ
xval(d::Gumbel, z::Real) = z * d.θ + d.μ

function pdf(d::Gumbel, x::Real)
z = zval(d, x)
Expand All @@ -98,8 +98,17 @@ function logpdf(d::Gumbel, x::Real)
end

cdf(d::Gumbel, x::Real) = exp(-exp(-zval(d, x)))
ccdf(d::Gumbel, x::Real) = -expm1(-exp(-zval(d, x)))
logcdf(d::Gumbel, x::Real) = -exp(-zval(d, x))
logccdf(d::Gumbel, x::Real) = log1mexp(-exp(-zval(d, x)))

quantile(d::Gumbel, p::Real) = d.μ - d.θ * log(-log(p))
quantile(d::Gumbel, p::Real) = xval(d, -log(-log(p)))
cquantile(d::Gumbel, p::Real) = xval(d, -log(-log1p(-p)))
invlogcdf(d::Gumbel, lp::Real) = xval(d, -log(-lp))
invlogccdf(d::Gumbel, lp::Real) = xval(d, -log(-log1mexp(lp)))

gradlogpdf(d::Gumbel, x::Real) = expm1(-zval(d, x)) / d.θ

mgf(d::Gumbel, t::Real) = gamma(1 - d.θ * t) * exp(d.μ * t)
cgf(d::Gumbel, t::Real) = loggamma(1 - d.θ * t) + d.μ * t
cf(d::Gumbel, t::Real) = gamma(1 - im * d.θ * t) * cis(d.μ * t)

0 comments on commit fe57164

Please sign in to comment.