-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove overflows for bivariate gumbel density (#218)
* implement bivariate logdensity for gumbel to remove overflows. Fixes #215 * add also the cdf * add the cdf too * move the code around * nailed it ! * change comment * Add a specific file for bivariate archimedean methods
- Loading branch information
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# The Gumbel copula needs a specific bivariate method to handle large parameters. | ||
function _cdf(C::ArchimedeanCopula{2,G}, u) where {G<:GumbelGenerator} | ||
θ = C.G.θ | ||
x₁, x₂ = -log(u[1]), -log(u[2]) | ||
lx₁, lx₂ = log(x₁), log(x₂) | ||
return 1 - LogExpFunctions.cexpexp(LogExpFunctions.logaddexp(θ * lx₁, θ * lx₂) / θ) | ||
end | ||
function Distributions._logpdf(C::ArchimedeanCopula{2,G}, u) where {G<:GumbelGenerator} | ||
!all(0 .<= u .<= 1) && return eltype(u)(-Inf) # if not in range return -Inf | ||
|
||
θ = C.G.θ | ||
x₁, x₂ = -log(u[1]), -log(u[2]) | ||
lx₁, lx₂ = log(x₁), log(x₂) | ||
A = LogExpFunctions.logaddexp(θ * lx₁, θ * lx₂) | ||
B = exp(A/θ) | ||
return - B + x₁ + x₂ + (θ-1) * (lx₁ + lx₂) + A/θ - 2A + log(B + θ - 1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testitem "Extreme gumbel density test" begin | ||
using Distributions | ||
G = GumbelCopula(2, 244.3966206319112) | ||
u = [0.969034207932297,0.9638122014293545] | ||
den = pdf(G, u) | ||
@test true | ||
|
||
G = GumbelCopula(2, 1544.3966206319112) | ||
u = [0.969034207932297,0.9638122014293545] | ||
den = pdf(G, u) | ||
@test true | ||
end |