-
Notifications
You must be signed in to change notification settings - Fork 12
Complete PowerGenerator implementation for Archimedean copulas #285
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
cdf25d3
3550d11
101e6fd
2217786
bf5fba7
e89d484
b892087
4190384
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """ | ||
| PowerGenerator{TG,T} | ||
|
|
||
| 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 : | ||
| * [nelsen2006](@cite) Nelsen, R. B. (2006). An introduction to copulas. Springer, theorem 4.5.1 p141 | ||
| """ | ||
| struct PowerGenerator{TG,T} <: Generator | ||
| G::TG | ||
| α::T | ||
| β::T | ||
| function PowerGenerator(G, α, β) | ||
| @assert α > 0 | ||
| @assert β > 0 | ||
| if α == 1 && β == 1 | ||
| return G | ||
| end | ||
| α,β = promote(α,β) | ||
| return new{typeof(G),typeof(β)}(G, α, β) | ||
| end | ||
| end | ||
|
|
||
| # Parameter extraction for consistency with other generators | ||
| Distributions.params(G::PowerGenerator) = (G.α, G.β) | ||
|
|
||
| # Maximum monotony is preserved from the underlying generator | ||
| max_monotony(G::PowerGenerator) = max_monotony(G.G) | ||
|
|
||
| # Core generator function: ϕ(t) = ϕ_G(t^α)^β | ||
| # Use exp/log trick to avoid underflow/overflow | ||
| ϕ(G::PowerGenerator, t) = exp(G.β * log(ϕ(G.G, t^G.α))) | ||
|
|
||
lrnv marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Inverse function: if y = ϕ_G(t^α)^β, then t = (ϕ_G⁻¹(y^(1/β)))^(1/α) | ||
| ϕ⁻¹(G::PowerGenerator, y) = (ϕ⁻¹(G.G, y^(1/G.β)))^(1/G.α) | ||
|
||
|
|
||
lrnv marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # First derivative: ϕ'(t) = β * α * t^(α-1) * ϕ_G'(t^α) * ϕ_G(t^α)^(β-1) | ||
| ϕ⁽¹⁾(G::PowerGenerator, t) = G.β * G.α * t^(G.α - 1) * ϕ⁽¹⁾(G.G, t^G.α) * ϕ(G.G, t^G.α)^(G.β - 1) | ||
|
||
|
|
||
| # First derivative of inverse function | ||
| ϕ⁻¹⁽¹⁾(G::PowerGenerator, y) = (1/G.α) * (ϕ⁻¹(G.G, y^(1/G.β)))^(1/G.α - 1) * ϕ⁻¹⁽¹⁾(G.G, y^(1/G.β)) * (1/G.β) * y^(1/G.β - 1) | ||
|
||
|
|
||
| # Higher order derivatives - use the default implementation which uses ForwardDiff | ||
| # The analytical form is complex due to nested chain rule applications | ||
|
|
||
| # Kendall's tau - preserved from the underlying generator according to the theory | ||
| τ(G::PowerGenerator) = τ(G.G) | ||
|
||
|
|
||
| # Williamson distribution - use default numerical computation | ||
| # The Williamson transform of ϕ(t) = ϕ_G(t^α)^β is not simply the transform of ϕ_G | ||
| # Let the default implementation handle this numerically | ||
Uh oh!
There was an error while loading. Please reload this page.