Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Generator] PowerGenerator from any other generator #84

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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


Loading