diff --git a/src/EllipticalCopula.jl b/src/EllipticalCopula.jl index b60b2f35..703bbbbc 100644 --- a/src/EllipticalCopula.jl +++ b/src/EllipticalCopula.jl @@ -49,7 +49,7 @@ abstract type EllipticalCopula{d,MT} <: Copula{d} end Base.eltype(C::CT) where CT<:EllipticalCopula = Base.eltype(N(CT)(C.Σ)) function Distributions._rand!(rng::Distributions.AbstractRNG, C::CT, x::AbstractVector{T}) where {T<:Real, CT <: EllipticalCopula} Random.rand!(rng,N(CT)(C.Σ),x) - x .= Distributions.cdf.(U(CT),x) + x .= clamp.(Distributions.cdf.(U(CT),x),0,1) return x end function Distributions._rand!(rng::Distributions.AbstractRNG, C::CT, A::DenseMatrix{T}) where {T<:Real, CT<:EllipticalCopula} @@ -57,7 +57,7 @@ function Distributions._rand!(rng::Distributions.AbstractRNG, C::CT, A::DenseMat n = N(CT)(C.Σ) u = U(CT) Random.rand!(rng,n,A) - A .= Distributions.cdf.(u,A) + A .= clamp.(Distributions.cdf.(u,A),0,1) return A end function Distributions._logpdf(C::CT, u) where {CT <: EllipticalCopula} diff --git a/src/SklarDist.jl b/src/SklarDist.jl index 1cd85e89..be155ae3 100644 --- a/src/SklarDist.jl +++ b/src/SklarDist.jl @@ -59,7 +59,7 @@ function Distributions._rand!(rng::Distributions.AbstractRNG, S::SklarDist{CT,Tp x .= Distributions.quantile.(S.m,x) end function Distributions._logpdf(S::SklarDist{CT,TplMargins},u) where {CT,TplMargins} - sum(Distributions.logpdf(S.m[i],u[i]) for i in 1:length(u)) + Distributions.logpdf(S.C,Distributions.cdf.(S.m,u)) + sum(Distributions.logpdf(S.m[i],u[i]) for i in 1:length(u)) + Distributions.logpdf(S.C,clamp.(Distributions.cdf.(S.m,u),0,1)) end