Skip to content

Commit c974872

Browse files
authored
[Feat] Archimedean conditionals: remove superfluous type parameters (lrnv#339)
1 parent 504529d commit c974872

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/Generator.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ end
485485

486486

487487
"""
488-
TiltedGenerator(G, p, sJ) <: Generator
488+
TiltedGenerator(G, p, sJ)
489489
490490
Archimedean generator tilted by conditioning on `p` components fixed at values
491491
with cumulative generator sum `sJ = ∑ ϕ⁻¹(u_j)`. It defines
@@ -500,19 +500,20 @@ which yields the conditional copula within the Archimedean family for the
500500
remaining d-p variables.
501501
You will get a TiltedGenerator if you condition() an archimedean copula.
502502
"""
503-
struct TiltedGenerator{TG, T, p} <: Generator
503+
struct TiltedGenerator{TG, T} <: Generator
504504
G::TG
505+
p::Int
505506
sJ::T
506507
den::T
507508
function TiltedGenerator(G::Generator, p::Int, sJ::T) where {T<:Real}
508509
den = ϕ⁽ᵏ⁾(G, p, sJ)
509-
return new{typeof(G), T, p}(G, sJ, den)
510+
return new{typeof(G), T}(G, p, sJ, den)
510511
end
511512
end
512-
max_monotony(G::TiltedGenerator{TG, T, p}) where {TG, T, p} = max(0, max_monotony(G.G) - p)
513-
ϕ(G::TiltedGenerator{TG, T, p}, t) where {TG, T, p} = ϕ⁽ᵏ⁾(G.G, p, G.sJ + t) / G.den
514-
ϕ⁻¹(G::TiltedGenerator{TG, T, p}, x) where {TG, T, p} = ϕ⁽ᵏ⁾⁻¹(G.G, p, x * G.den; start_at = G.sJ) - G.sJ
515-
ϕ⁽ᵏ⁾(G::TiltedGenerator{TG, T, p}, k::Int, t) where {TG, T, p} = ϕ⁽ᵏ⁾(G.G, k + p, G.sJ + t) / G.den
516-
ϕ⁽ᵏ⁾⁻¹(G::TiltedGenerator{TG, T, p}, k::Int, y; start_at = G.sJ) where {TG, T, p} = ϕ⁽ᵏ⁾⁻¹(G.G, k + p, y * G.den; start_at = start_at+G.sJ) - G.sJ
517-
ϕ⁽¹⁾(G::TiltedGenerator{TG, T, p}, t) where {TG, T, p} = ϕ⁽ᵏ⁾(G, 1, t)
513+
max_monotony(G::TiltedGenerator{TG, T}) where {TG, T} = max(0, max_monotony(G.G) - G.p)
514+
ϕ(G::TiltedGenerator{TG, T}, t) where {TG, T} = ϕ⁽ᵏ⁾(G.G, G.p, G.sJ + t) / G.den
515+
ϕ⁻¹(G::TiltedGenerator{TG, T}, x) where {TG, T} = ϕ⁽ᵏ⁾⁻¹(G.G, G.p, x * G.den; start_at = G.sJ) - G.sJ
516+
ϕ⁽ᵏ⁾(G::TiltedGenerator{TG, T}, k::Int, t) where {TG, T} = ϕ⁽ᵏ⁾(G.G, k + G.p, G.sJ + t) / G.den
517+
ϕ⁽ᵏ⁾⁻¹(G::TiltedGenerator{TG, T}, k::Int, y; start_at = G.sJ) where {TG, T} = ϕ⁽ᵏ⁾⁻¹(G.G, k + G.p, y * G.den; start_at = start_at+G.sJ) - G.sJ
518+
ϕ⁽¹⁾(G::TiltedGenerator{TG, T}, t) where {TG, T} = ϕ⁽ᵏ⁾(G, 1, t)
518519
Distributions.params(G::TiltedGenerator) = (Distributions.params(G.G)..., sJ = G.sJ)
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
###########################################################################
22
##### ArchimedeanCopula fast-paths
33
###########################################################################
4-
struct ArchimedeanDistortion{TG, T, p} <: Distortion
4+
struct ArchimedeanDistortion{TG, T} <: Distortion
55
G::TG
6+
p::Int
67
sJ::T
78
den::T
8-
ArchimedeanDistortion(G::TG, p::Int, sJ::T, den::T) where {T<:Real, TG} = new{TG, T, p}(G, sJ, den)
9+
ArchimedeanDistortion(G::TG, p::Int, sJ::T, den::T) where {T<:Real, TG} = new{TG, T}(G, p, sJ, den)
910
end
10-
function Distributions.cdf(D::ArchimedeanDistortion{TG, T, p}, u::Real) where {TG, T, p}
11-
return ϕ⁽ᵏ⁾(D.G, p, D.sJ + ϕ⁻¹(D.G, float(u))) / D.den
11+
function Distributions.cdf(D::ArchimedeanDistortion{TG, T}, u::Real) where {TG, T}
12+
return ϕ⁽ᵏ⁾(D.G, D.p, D.sJ + ϕ⁻¹(D.G, float(u))) / D.den
1213
end
13-
function Distributions.quantile(D::ArchimedeanDistortion{TG, T, p}, α::Real) where {TG, T, p}
14-
y = ϕ⁽ᵏ⁾⁻¹(D.G, p, α * D.den; start_at = D.sJ)
14+
function Distributions.quantile(D::ArchimedeanDistortion{TG, T}, α::Real) where {TG, T}
15+
y = ϕ⁽ᵏ⁾⁻¹(D.G, D.p, α * D.den; start_at = D.sJ)
1516
return ϕ(D.G, y - D.sJ)
1617
end
1718
## ConditionalCopula moved next to ArchimedeanCopula definition

0 commit comments

Comments
 (0)