From 3717cf1505bd56b5c250526fe69d73a3d2553932 Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Sun, 25 Jul 2021 21:07:05 -0500 Subject: [PATCH 1/3] mort should have a default assignmnet or error --- src/LifeContingencies.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LifeContingencies.jl b/src/LifeContingencies.jl index c1d704f..5ea60cc 100644 --- a/src/LifeContingencies.jl +++ b/src/LifeContingencies.jl @@ -69,7 +69,8 @@ struct SingleLife <: Life fractional_assump end -function SingleLife(;mort,issue_age=nothing,alive=true,fractional_assump = mt.Uniform()) +function SingleLife(;mort=nothing,issue_age=nothing,alive=true,fractional_assump = mt.Uniform()) + isnothing(mort) || ArgumentError("Need to pass a mortality vector to `mort` argument.") return SingleLife(mort;issue_age,alive,fractional_assump) end From f916214f6043b794b7c20c6f1c22728d3784ce90 Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Sun, 26 Sep 2021 21:36:11 -0500 Subject: [PATCH 2/3] spelling --- src/LifeContingencies.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/LifeContingencies.jl b/src/LifeContingencies.jl index 5ea60cc..946fbb3 100644 --- a/src/LifeContingencies.jl +++ b/src/LifeContingencies.jl @@ -100,7 +100,7 @@ abstract type JointAssumption end """ Frasier() -The assumption of independnt lives in a joint life calculation. +The assumption of independent lives in a joint life calculation. Is a subtype of `JointAssumption`. """ struct Frasier <: JointAssumption end @@ -404,7 +404,7 @@ end """ survival(Insurance) -The survorship vector for the given insurance. +The survivorship vector for the given insurance. """ function MortalityTables.survival(ins::Insurance) return [survival(ins.life,t-1) for t in timepoints(ins)] @@ -531,7 +531,7 @@ end The net premium for a whole life insurance (without second argument) or a term life insurance through `to_time`. -The net premium is based on 1 unit of insurance with the death benfit payable at the end of the year and assuming annual net premiums. +The net premium is based on 1 unit of insurance with the death benefit payable at the end of the year and assuming annual net premiums. """ premium_net(lc::LifeContingency) = A(lc) / ä(lc) premium_net(lc::LifeContingency,to_time) = A(lc,to_time) / ä(lc,to_time) @@ -560,7 +560,7 @@ end decrement(lc::LifeContingency,to_time) decrement(lc::LifeContingency,from_time,to_time) -Return the probablity of death for the given LifeContingency. +Return the probability of death for the given LifeContingency. """ mt.decrement(lc::LifeContingency,from_time,to_time) = 1 - survival(lc.life,from_time,to_time) @@ -569,7 +569,7 @@ mt.decrement(lc::LifeContingency,from_time,to_time) = 1 - survival(lc.life,from_ survival(lc::LifeContingency,from_time,to_time) survival(lc::LifeContingency,to_time) -Return the probablity of survival for the given LifeContingency. +Return the probability of survival for the given LifeContingency. """ mt.survival(lc::LifeContingency,to_time) = survival(lc.life, 0, to_time) mt.survival(lc::LifeContingency,from_time,to_time) = survival(lc.life, from_time, to_time) @@ -578,7 +578,7 @@ mt.survival(l::SingleLife,to_time) = survival(l,0,to_time) mt.survival(l::SingleLife,from_time,to_time) =survival(l.mort,l.issue_age + from_time,l.issue_age + to_time, l.fractional_assump) """ - surival(life) + survival(life) Return a survival vector for the given life. """ @@ -604,11 +604,11 @@ end Yields.discount(lc::LifeContingency,t) = discount(lc.int,t) Yields.discount(lc::LifeContingency,t1,t2) = discount(lc.int,t1,t2) -# function compostion with kwargs. +# function composition with kwargs. # https://stackoverflow.com/questions/64740010/how-to-alias-composite-function-with-keyword-arguments ⋄(f, g) = (x...; kw...)->f(g(x...; kw...)) -# unexported aliases +# un-exported aliases const V = reserve_premium_net const v = Yields.discount const A = present_value ⋄ Insurance From cb03db7e013b38eed1f07b503601f27cb5a6de81 Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Sun, 26 Sep 2021 22:00:35 -0500 Subject: [PATCH 3/3] update depreciated syntax --- src/LifeContingencies.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LifeContingencies.jl b/src/LifeContingencies.jl index 946fbb3..adaa370 100644 --- a/src/LifeContingencies.jl +++ b/src/LifeContingencies.jl @@ -253,7 +253,7 @@ end """ function N(lc::LifeContingency, from_time) range = from_time:(omega(lc)-1) - return foldxt(+,Map(from_time->D(lc, from_time)), range) + return foldxt(+,range |> Map(from_time->D(lc, from_time))) end """ @@ -264,7 +264,7 @@ Issue age is based on the issue_age in the LifeContingency `lc`. """ function M(lc::LifeContingency, from_time) range = from_time:omega(lc)-1 - return foldxt(+,Map(from_time->C(lc, from_time)), range) + return foldxt(+,range |> Map(from_time->C(lc, from_time))) end E(lc::LifeContingency, t, x) = D(lc,x + t) / D(lc,x)