@@ -613,9 +613,23 @@ Bestiary = filter(GenericTestFilter, Bestiary)
613613 if ! (C isa EmpiricalCopula)
614614 @test all (0 .≤ rand (rng, Dd, 2 ) .≤ 1 ) # to ensure the conditional distribution can be sampled.
615615 end
616- vals = cdf .(Ref (Dd), us)
616+ vals = cdf .(Dd, us)
617+ probs = pdf .(Dd, us)
618+ qs = quantile .(Dd, us)
619+
620+ @test all (0 .<= qs .<= 1 )
617621 @test all (0.0 .<= vals .<= 1.0 )
618622 @test all (diff (collect (vals)) .>= - 1e-10 )
623+
624+ # Check that pdf, cdf and quantile are coherent:
625+ dprobs = ForwardDiff. derivative .(Base. Fix1 (Distributions. cdf, Dd), us)
626+ for (dp, p, v, q, u) in zip (dprobs, probs, vals, qs, us)
627+ @test isfinite (dp) && isfinite (p)
628+ @test isapprox (dp, p; atol= 1e-5 , rtol= 1e-5 )
629+ @test isapprox (cdf (Dd, q), u; atol= 1e-5 , rtol= 1e-5 )
630+ @test isapprox (quantile (Dd, v), u; atol= 1e-5 , rtol= 1e-5 )
631+ end
632+
619633 if check_biv_conditioning (C) && has_spec
620634 Dgen = @invoke Copulas. DistortionFromCop (C:: Copulas.Copula{d} , (j,), (v,), i)
621635 vals_gen = cdf .(Ref (Dgen), us)
0 commit comments