Skip to content

Commit

Permalink
Small fix for boundary conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnv committed Feb 12, 2024
1 parent 75b06de commit ebd58ce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/Copula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Base.length(::Copula{d}) where d = d
# Base.eltype
function Distributions.cdf(C::Copula{d},u::VT) where {d,VT<:AbstractVector}
length(u) != d && throw(ArgumentError("Dimension mismatch between copula and input vector"))
if any(iszero,u)
return zero(u[1])
elseif all(isone,u)
return one(u[1])
end
return _cdf(C,u)
end
function Distributions.cdf(C::Copula{d},A::AbstractMatrix) where d
size(A,1) != d && throw(ArgumentError("Dimension mismatch between copula and input vector"))
return [_cdf(C,u) for u in eachcol(A)]
return [Distributions.cdf(C,u) for u in eachcol(A)]
end
function _cdf(C::CT,u) where {CT<:Copula}
if any(iszero.(u))
return zero(u[1])
elseif all(isone.(u))
return one(u[1])
end
f(x) = Distributions.pdf(C,x)
z = zeros(eltype(u),length(C))
return Cubature.hcubature(f,z,u,reltol=sqrt(eps()))[1]
Expand Down
2 changes: 0 additions & 2 deletions src/MiscellaneousCopulas/RafteryCopula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ struct RafteryCopula{d, P} <: Copula{d}
end
Base.eltype(R::RafteryCopula) = eltype(R.θ)
function _cdf(R::RafteryCopula{d,P}, u) where {d,P}

@show d
# Order the vector u
u_ordered = sort(u)
term1 = u_ordered[1]
Expand Down
1 change: 0 additions & 1 deletion test/kendall_tau_notnan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
)

for C in cops
@show C
@test !isnan(Copulas.τ(C))
end
@test_broken Copulas.τ(ArchimedeanCopula(2,i𝒲(LogNormal(),2))) # not implemented.
Expand Down
1 change: 0 additions & 1 deletion test/margins_uniformity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
n = 1000
U = Uniform(0,1)
for C in cops
@show C
d = length(C)
CT = typeof(C)
rng = StableRNG(123)
Expand Down

0 comments on commit ebd58ce

Please sign in to comment.