Skip to content

Commit

Permalink
Merge pull request #28 from UofTActuarial/dev-0.3.2
Browse files Browse the repository at this point in the history
Dev 0.3.2
  • Loading branch information
sparktseung authored Dec 28, 2022
2 parents 2a86125 + 0d0321d commit 97ecf4e
Show file tree
Hide file tree
Showing 41 changed files with 2,460 additions and 1,185 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: CI
on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
Expand All @@ -17,6 +14,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.4' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LRMoE"
uuid = "b6847444-3cfa-4637-857f-9c8c615f8351"
authors = ["Spark Tseung <[email protected]>"]
version = "0.3.1"
version = "0.3.2"

[deps]
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
Expand Down
42 changes: 0 additions & 42 deletions appveyor.yml

This file was deleted.

3 changes: 0 additions & 3 deletions docs/src/dummytest.md

This file was deleted.

7 changes: 1 addition & 6 deletions src/LRMoE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ export
# loglikelihood functions
pdf, logpdf,
cdf, logcdf,
rowlogsumexp, expert_ll_pos,
expert_tn_pos,
expert_tn_bar_pos,
rowlogsumexp,
expert_ll,
expert_tn,
expert_tn_bar,
expert_ll_pos_list,
expert_tn_pos_list,
expert_tn_bar_pos_list,
expert_ll_list,
expert_tn_list,
expert_tn_bar_list, loglik_aggre_dim,
Expand Down
11 changes: 8 additions & 3 deletions src/experts/continuous/burr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ mean(d::BurrExpert) = mean(LRMoE.Burr(d.k, d.c, d.λ))
var(d::BurrExpert) = var(LRMoE.Burr(d.k, d.c, d.λ))
quantile(d::BurrExpert, p) = quantile(LRMoE.Burr(d.k, d.c, d.λ), p)
function lev(d::BurrExpert, u)
uu = 1 / (1 + (u / d.λ)^d.c)
return d.λ * gamma(float(1 + 1 / d.c)) * gamma(float(d.k - 1 / d.c)) /
gamma(float(d.k)) * beta_inc(1 + 1 / d.c, d.k - 1 / d.c, 1 - uu)[1] + u * uu^d.k
if isinf(u)
return mean(d)
else
uu = 1 / (1 + (u / d.λ)^d.c)
return d.λ * gamma(float(1 + 1 / d.c)) * gamma(float(d.k - 1 / d.c)) /
gamma(float(d.k)) * beta_inc(1 + 1 / d.c, d.k - 1 / d.c, 1 - uu)[1] +
u * uu^d.k
end
end
excess(d::BurrExpert, u) = mean(d) - lev(d, u)

Expand Down
10 changes: 7 additions & 3 deletions src/experts/continuous/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
## Outer constructors
GammaExpert(k::Real, θ::Real) = GammaExpert(promote(k, θ)...)
GammaExpert(k::Integer, θ::Integer) = GammaExpert(float(k), float(θ))
GammaExpert() = GammaExpert(1.0, 1.0)
GammaExpert() = GammaExpert(2.0, 1.0)

## Conversion
function convert(::Type{GammaExpert{T}}, k::S, θ::S) where {T<:Real,S<:Real}
Expand Down Expand Up @@ -135,8 +135,12 @@ mean(d::GammaExpert) = mean(Distributions.Gamma(d.k, d.θ))
var(d::GammaExpert) = var(Distributions.Gamma(d.k, d.θ))
quantile(d::GammaExpert, p) = quantile(Distributions.Gamma(d.k, d.θ), p)
function lev(d::GammaExpert, u)
return d.θ * d.k * gamma_inc(float(d.k + 1), u / d.θ, 0)[1] +
u * (1 - gamma_inc(float(d.k), u / d.θ, 0)[1])
if isinf(u)
return mean(d)
else
return d.θ * d.k * gamma_inc(float(d.k + 1), u / d.θ, 0)[1] +
u * (1 - gamma_inc(float(d.k), u / d.θ, 0)[1])
end
end
excess(d::GammaExpert, u) = mean(d) - lev(d, u)

Expand Down
12 changes: 8 additions & 4 deletions src/experts/continuous/inversegaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ mean(d::InverseGaussianExpert) = mean(Distributions.InverseGaussian(d.μ, d.λ))
var(d::InverseGaussianExpert) = var(Distributions.InverseGaussian(d.μ, d.λ))
quantile(d::InverseGaussianExpert, p) = quantile(Distributions.InverseGaussian(d.μ, d.λ), p)
function lev(d::InverseGaussianExpert, u)
z = (u - d.μ) / d.μ
y = (u + d.μ) / d.μ
return u - d.μ * z * cdf.(Normal(0, 1), z * (d.λ / u)^0.5) -
d.μ * y * exp(2 * d.λ / d.μ) * cdf.(Normal(0, 1), -y * (d.λ / u)^0.5)
if isinf(u)
return mean(d)
else
z = (u - d.μ) / d.μ
y = (u + d.μ) / d.μ
return u - d.μ * z * cdf.(Normal(0, 1), z * (d.λ / u)^0.5) -
d.μ * y * exp(2 * d.λ / d.μ) * cdf.(Normal(0, 1), -y * (d.λ / u)^0.5)
end
end
excess(d::InverseGaussianExpert, u) = mean(d) - lev(d, u)

Expand Down
12 changes: 8 additions & 4 deletions src/experts/continuous/lognormal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ mean(d::LogNormalExpert) = mean(Distributions.LogNormal(d.μ, d.σ))
var(d::LogNormalExpert) = var(Distributions.LogNormal(d.μ, d.σ))
quantile(d::LogNormalExpert, p) = quantile(Distributions.LogNormal(d.μ, d.σ), p)
function lev(d::LogNormalExpert, u)
return exp(d.μ + 0.5 * d.σ^2) * cdf.(Normal(d.μ + d.σ^2, d.σ), log(u)) +
u * (1 - cdf.(Normal(d.μ, d.σ), log(u)))
if isinf(u)
return mean(d)
else
return exp(d.μ + 0.5 * d.σ^2) * cdf.(Normal(d.μ + d.σ^2, d.σ), log(u)) +
u * (1 - cdf.(Normal(d.μ, d.σ), log(u)))
end
end
excess(d::LogNormalExpert, u) = mean(d) - lev(d, u)

Expand All @@ -131,7 +135,7 @@ function _int_obs_logY(d::LogNormalExpert, yl, yu, expert_ll)
return log(yl)
else
return exp(-expert_ll) * (
d.σ * invsqrt2π * 0.5 * _diff_dens_series(d, yl, yu) +
d.σ * invsqrt2π * _diff_dens_series(d, yl, yu) +
d.μ * _diff_dist_series(d, yl, yu)
)
end
Expand All @@ -140,7 +144,7 @@ end
function _int_lat_logY(d::LogNormalExpert, tl, tu, expert_tn_bar)
return exp(-expert_tn_bar) * (
d.μ - (
d.σ * invsqrt2π * 0.5 * _diff_dens_series(d, tl, tu) +
d.σ * invsqrt2π * _diff_dens_series(d, tl, tu) +
d.μ * _diff_dist_series(d, tl, tu)
)
)
Expand Down
8 changes: 6 additions & 2 deletions src/experts/continuous/weibull.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ mean(d::WeibullExpert) = mean(Distributions.Weibull(d.k, d.θ))
var(d::WeibullExpert) = var(Distributions.Weibull(d.k, d.θ))
quantile(d::WeibullExpert, p) = quantile(Distributions.Weibull(d.k, d.θ), p)
function lev(d::WeibullExpert, u)
return d.θ * gamma_inc(float(1 / d.k + 1), (u / d.θ)^d.k, 0)[1] *
gamma(float(1 / d.k + 1)) + u * exp(-(u / d.θ)^d.k)
if isinf(u)
return mean(d)
else
return d.θ * gamma_inc(float(1 / d.k + 1), (u / d.θ)^d.k, 0)[1] *
gamma(float(1 / d.k + 1)) + u * exp(-(u / d.θ)^d.k)
end
end
excess(d::WeibullExpert, u) = mean(d) - lev(d, u)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions test/dummytest.jl

This file was deleted.

Loading

2 comments on commit 97ecf4e

@sparktseung
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch=main

Release notes:

Bug fix:

Internal:

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74716

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" 97ecf4e006362704b0d494d151d4a88e4ede4ed5
git push origin v0.3.2

Please sign in to comment.