diff --git a/src/Copula.jl b/src/Copula.jl index daf9b43a..5b4c8a36 100644 --- a/src/Copula.jl +++ b/src/Copula.jl @@ -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] diff --git a/src/MiscellaneousCopulas/RafteryCopula.jl b/src/MiscellaneousCopulas/RafteryCopula.jl index 37d512f9..47c1820a 100644 --- a/src/MiscellaneousCopulas/RafteryCopula.jl +++ b/src/MiscellaneousCopulas/RafteryCopula.jl @@ -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] diff --git a/test/kendall_tau_notnan.jl b/test/kendall_tau_notnan.jl index 88bc377a..9486ce07 100644 --- a/test/kendall_tau_notnan.jl +++ b/test/kendall_tau_notnan.jl @@ -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. diff --git a/test/margins_uniformity.jl b/test/margins_uniformity.jl index 05076faf..13b2b0a4 100644 --- a/test/margins_uniformity.jl +++ b/test/margins_uniformity.jl @@ -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)