Comments (2)
Proposed in #41:
mt = UltimateMortality([0.5,0.5])
# whole life insurance
ins = Insurance(
SingleLife(mort = mt,issue_age = 0),
Yields.Constant(0.05)
)
@test survival(ins) == [1.0,0.5]
@test discount(ins) == [1.0 / 1.05, 1 / 1.05^2]
@test benefit(ins) == [1.0,1.0]
@test probability(ins) == [0.5,0.25]
@test cashflows(ins) == [0.5,0.25]
@test cashflows(ins) == benefit(ins) .* probability(ins)
@test timepoints(ins) == [1.0,2.0]
@test present_value(ins) ≈ 0.5 / 1.05 + 0.5 * 0.5 / 1.05 ^ 2
Status Quo:
ins = LifeContingency(
SingleLife(
mort = mt,
issue_age = 0
),
Yields.Constant(0.05)
)
And then all you can do is this:
@test insurance(ins) ≈ 0.5 / 1.05 + 0.5 * 0.5 / 1.05 ^ 2
from lifecontingencies.jl.
Benchmarks indicate that the new API would be slower, but that's solvable (specialize on the functions, build a pipeline that doesn't allocate the intermediate steps, etc)
julia> @benchmark present_value(Insurance($ins )) #new
BenchmarkTools.Trial:
memory estimate: 111.30 KiB
allocs estimate: 1579
--------------
minimum time: 81.200 μs (0.00% GC)
median time: 83.301 μs (0.00% GC)
mean time: 92.890 μs (6.73% GC)
maximum time: 3.461 ms (96.72% GC)
--------------
samples: 10000
evals/sample: 1
julia> @benchmark insurance($ins ) #old
BenchmarkTools.Trial:
memory estimate: 83.88 KiB
allocs estimate: 740
--------------
minimum time: 35.000 μs (0.00% GC)
median time: 48.000 μs (0.00% GC)
mean time: 48.172 μs (6.57% GC)
maximum time: 2.160 ms (96.04% GC)
--------------
samples: 10000**
from lifecontingencies.jl.
Related Issues (20)
- Don't use Commutation functions for Insurance Calcs
- change API for discount rates
- Make things iterable
- Improve the `show` for Life Cont. Objects
- export `APV`
- add certain and immediate annuity HOT 1
- API definitions - intervals vs n-payments HOT 3
- Add Endowment HOT 3
- TagBot trigger issue HOT 36
- survival vector on `life`?
- Update docstrings/tests for MT v2
- Add more test cases HOT 1
- Review documentation and identify things that are unclear or need additional detail
- Pull common functions out of specific packages into a Base package HOT 1
- Error reproducing README example HOT 1
- Add additional decrements
- Use SnoopCompile to precompile more stuff
- Update for FinanceCore.jl
- Allow Fractional Age Everywhere HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lifecontingencies.jl.