Skip to content

Commit

Permalink
First sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnv committed Nov 23, 2023
1 parent 49dc233 commit 5570e95
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ williamson_dist(G::Generator, d) = WilliamsonTransforms.𝒲₋₁(t -> ϕ(G,t),


abstract type UnivariateGenerator <: Generator end
abstract type ZeroVariateGenerator <: Generator end
abstract type ZeroVariateGenerator <: Generator end
abstract type DistordedGenerator <: Generator end
45 changes: 45 additions & 0 deletions src/Generator/DistordedGenerator/PowerGenerator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
PowerGenerator{T, TG}
Fields:
- G::Generator - another generator
- α::Real - parameter, the inner power, positive
- β::Real - parameter, the outer power, positive
Constructor
PowerGenerator(G, α, β)
The inner/outer power generator based on the generator ϕ given by
```math
\\phi_{\\alpha,\\beta}(t) = \\phi(t^\\alpha)^\\beta
```
It keeps the monotony of ϕ.
It has a few special cases:
- When α = 1 and β = 1, it returns G.
References :
Nelsen, R. B. (2006). An introduction to copulas. Springer, theorem 4.5.1 p141
"""
struct PowerGenerator{TG,T} <: DistordedGenerator
G::TG
α::T
β::T
function PowerGenerator(G, α, β)
@assert α > 0
@assert β > 0
if α == 1 && β == 1
return G

Check warning on line 35 in src/Generator/DistordedGenerator/PowerGenerator.jl

View check run for this annotation

Codecov / codecov/patch

src/Generator/DistordedGenerator/PowerGenerator.jl#L31-L35

Added lines #L31 - L35 were not covered by tests
end
α,β = promote(α,β)
return new{typeof(G),typeof(β)}(G, α, β)

Check warning on line 38 in src/Generator/DistordedGenerator/PowerGenerator.jl

View check run for this annotation

Codecov / codecov/patch

src/Generator/DistordedGenerator/PowerGenerator.jl#L37-L38

Added lines #L37 - L38 were not covered by tests
end
end
max_monotony(G::PowerGenerator) = max_monotony(G.G)
ϕ( G::PowerGenerator, t) = ϕ(G.G,t^G.α)^G.β
ϕ⁻¹(G::PowerGenerator, t) = ϕ⁻¹(G.G, t^(1/G.β))^(1/G.α)

Check warning on line 43 in src/Generator/DistordedGenerator/PowerGenerator.jl

View check run for this annotation

Codecov / codecov/patch

src/Generator/DistordedGenerator/PowerGenerator.jl#L41-L43

Added lines #L41 - L43 were not covered by tests


0 comments on commit 5570e95

Please sign in to comment.