Skip to content

Commit

Permalink
stash stuff out
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnv committed Feb 19, 2024
1 parent 9fd6733 commit c0b3a3c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
38 changes: 38 additions & 0 deletions src/Generator/FrailtyGenerator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
FrailtyGenerator{TX}
Fields:
* `X::TX` -- a random variable that represents the frailty distribution.
Constructor
FrailtyGenerator(X::Distributions.UnivariateDistribution)
The `FrailtyGenerator` allows to construct a completely monotonous archimedean generator from a positive random variable `X::Distributions.UnivariateDistribution`, assuming the distribution has a completely monotonous laplace transform (which will be used as the generator).
References:
* [williamson1955multiply](@cite) Williamson, R. E. (1956). Multiply monotone functions and their Laplace transforms. Duke Math. J. 23 189–207. MR0077581
* [mcneil2009](@cite) McNeil, Alexander J., and Johanna Nešlehová. "Multivariate Archimedean copulas, d-monotone functions and ℓ 1-norm symmetric distributions." (2009): 3059-3097.
* [mcneil2008](@cite) M
"""
struct FrailtyGenerator{TX} <: Generator
X::TX
function FrailtyGenerator(X)
# Check that the laplace transfrom is implemented ?
# it can be through `mgf`, `cgf = log(mgf)` or `cf`.
# the link is `mgf(t) = cf(- im * t)`

# What we want here is that laplac tranfrom, that is `mgf(-t)` or thus `real(cf(im * t))`.

# the only condition is that the support of the R.V is positive according to

# Check that X is indeed a positively supported random variable ?

# Other conditions ? We should do a thorough check here.
return new{typeof(X)}(X)
end
end
max_monotony(::FrailtyGenerator) = Inf
ϕ(G::FrailtyGenerator, t) = Distributions.mgf(G.X,t)
williamson_dist(G::FrailtyGenerator, d) = WilliamsonFromFrailty(G.X,d)

2 changes: 0 additions & 2 deletions src/UnivariateDistribution/WilliamsonFromFrailty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ function Distributions.rand(rng::Distributions.AbstractRNG, D::WilliamsonFromFra
return sy/f
end
function Distributions.cdf(D::WilliamsonFromFrailty{TF,d}, x::Real) where {TF,d}
# how to compute this cdf ?
return 1 - Distributions.expectation(
e -> Distributions.cdf(D.frailty_dist,e/x),
Distributions.Erlang(d)
)
end
function Distributions.pdf(D::WilliamsonFromFrailty{TF,d}, x::Real) where {TF,d}
# how to compute this cdf ?
return 1/x^2 * Distributions.expectation(
e -> Distributions.pdf(D.frailty_dist,e/x),
Distributions.Erlang(d)
Expand Down

0 comments on commit c0b3a3c

Please sign in to comment.