Skip to content

Commit

Permalink
fix time zero when given distribution of deaths
Browse files Browse the repository at this point in the history
  • Loading branch information
alecloudenback committed Jun 4, 2020
1 parent f0a1ef9 commit 939ebbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/death_distribution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ A function to calculate non-whole year survivorship, where you must
mortaility applies through the rest of the year.
"""
function p(tbl, issue_age, duration, time, dist::Uniform)

if time > 1
if time == 0
return 1.0

elseif time > 1
whole_time = trunc(Int, time)
p′ = p(tbl, issue_age, duration, whole_time)
return p′ *
Expand Down
4 changes: 4 additions & 0 deletions test/distribution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
round(1 - target[i], digits = 4)
end
end

# test time zero when given distribution of deaths
@test q(soa_mort,0,1,0,Uniform()) == 0.0
@test p(soa_mort,0,1,0,Uniform()) == 1.0
end
@testset "Multi-year examples" begin
mort = UltimateMortality([0.20, 0.50])
Expand Down

0 comments on commit 939ebbe

Please sign in to comment.