juliaactuary / learn Goto Github PK
View Code? Open in Web Editor NEWExamples and Tutorials using JuliaActuary packages.
Home Page: https://JuliaActuary.org/#learn
License: MIT License
Examples and Tutorials using JuliaActuary packages.
Home Page: https://JuliaActuary.org/#learn
License: MIT License
Hello,
Since power computation are very expansive, we can use incremental discount factor instead of compute it fully at each time step.
With this modification, Rust benchmark is 10 times faster.
In any case, Julia's performance is still impressive since it's almost as fast as Rust.
Thanks a lot for the benchmark.
pub fn npv(mortality_rates: &Vec<f64>, lapse_rates: &Vec<f64>, interest_rate: f64, sum_assured: f64, premium: f64, init_pols: f64, term: Option<usize>) -> f64 {
let term = term.unwrap_or_else(|| mortality_rates.len());
let mut result = 0.0;
let mut inforce = init_pols;
let v: f64 = 1.0 / (1.0 + interest_rate);
let mut discount_factor: f64 = 1.0;
for (t, (q, w)) in mortality_rates.iter().zip(lapse_rates).enumerate() {
let no_deaths = if t < term {inforce * q} else {0.0};
let no_lapses = if t < term {inforce * w} else {0.0};
let premiums = inforce * premium;
let claims = no_deaths * sum_assured;
let net_cashflow = premiums - claims;
result += net_cashflow * v.powi(t as i32);
discount_factor *= v;
inforce = inforce - no_deaths - no_lapses;
}
result
}
Jean
See more discussion in #2
Content added to this repository can also be highlighted on the JuliaActuary.org website (repository here: https://github.com/JuliaActuary/JuliaActuary.org)
Collated list of ideas for notebooks/tutorials:
Could this notebook's benchmark be made faster if everything used Float32
instead of Float64
?
Would be interesting test as there are places within the JuliaActuary ecosystem that currently wouldn't allow for anything other than Float64
Need to not be on battery and do test on comparable basis
Looking at the stochastic claims example -
Type annotations are optional, but providing them is able to coerce the values to be all plain bits (i.e. simple, non-referenced values like arrays are) when the type is constructed. This makes the whole data be stored in the stack and is an example of data-oriented design. It's much slower (~0.5 million policies per second, ~50x slower)
surely providing the types makes it faster?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.