Skip to content

Commit fe57164

Browse files
fixing error in xval function in gumbel.jl (#1859)
* 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 <[email protected]> * Update src/univariate/continuous/gumbel.jl Co-authored-by: David Widmann <[email protected]> * Update src/univariate/continuous/gumbel.jl Co-authored-by: David Widmann <[email protected]> --------- Co-authored-by: David Widmann <[email protected]>
1 parent 24de004 commit fe57164

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/univariate/continuous/gumbel.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ entropy(d::Gumbel) = log(d.θ) + 1 + MathConstants.γ
8585
#### Evaluation
8686

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

9090
function pdf(d::Gumbel, x::Real)
9191
z = zval(d, x)
@@ -98,8 +98,17 @@ function logpdf(d::Gumbel, x::Real)
9898
end
9999

100100
cdf(d::Gumbel, x::Real) = exp(-exp(-zval(d, x)))
101+
ccdf(d::Gumbel, x::Real) = -expm1(-exp(-zval(d, x)))
101102
logcdf(d::Gumbel, x::Real) = -exp(-zval(d, x))
103+
logccdf(d::Gumbel, x::Real) = log1mexp(-exp(-zval(d, x)))
102104

103-
quantile(d::Gumbel, p::Real) = d.μ - d.θ * log(-log(p))
105+
quantile(d::Gumbel, p::Real) = xval(d, -log(-log(p)))
106+
cquantile(d::Gumbel, p::Real) = xval(d, -log(-log1p(-p)))
107+
invlogcdf(d::Gumbel, lp::Real) = xval(d, -log(-lp))
108+
invlogccdf(d::Gumbel, lp::Real) = xval(d, -log(-log1mexp(lp)))
104109

105110
gradlogpdf(d::Gumbel, x::Real) = expm1(-zval(d, x)) / d.θ
111+
112+
mgf(d::Gumbel, t::Real) = gamma(1 - d.θ * t) * exp(d.μ * t)
113+
cgf(d::Gumbel, t::Real) = loggamma(1 - d.θ * t) + d.μ * t
114+
cf(d::Gumbel, t::Real) = gamma(1 - im * d.θ * t) * cis(d.μ * t)

0 commit comments

Comments
 (0)