It's a certain virus, it seems that moss will grow on my body soon because I refrain from going out ... By the way, I was studying for an actuary exam recently, and I thought, "By the way, I wonder if Python has a library for actuarial science," so I made it because it didn't seem like I was googled.
・ To deepen understanding of actuarial science. ・ To simplify numerical calculations using actuarial science. ・ I've never given my own library to PyPI in Python, so let's try it. ・ ~~ I was free ~~
Installation is possible with pip
pip install amaryllis
Calculate the expected value of insurance premiums. It implements each type of insurance algorithm, but the function arguments are different.
i :Annual interest rate,The default value is 0.03
x :The insured's age at the time of the insurance contract,The default value is 30
n :Insurance contract period,The default value is 20
f :Deferment period,The default value is 10
lifespan :Last age,The default value is 112
population :Surviving population from 0 to final age, default value is the 20th example life table(Man)Created with reference to.
Note that it is not actual data
It has become.
>>> from amaryllis.models.pension import *
>>> import numpy as np
>>> population = np.array([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0])
>>> x = 0
>>> n = 3
>>> lifespan = 10
>>> f = 0
>>> a = life_annuity(population=population, x=x, n=n, f=f, lifespan=lifespan)
>>> print("a = {}".format(a))
a = 2.6278631350739943
>>> from amaryllis.models.single import *
>>> import numpy as np
>>> population = np.array([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0])
>>> i = 0.03
>>> x = 0
>>> n = 3
>>> f = 1
>>> lifespan = 10
>>> A = single_term_insurance(i=i, population=population, x=x, n=n, f=f, lifespan=lifespan)
>>> print("A = {}".format(A))
A = 0.2746224616402602
Since each insurance is implemented by type, see github (https://github.com/yk-amarly-20/Amaryllis) for detailed function documentation.
I haven't implemented much of the content related to survival time analysis, so I plan to implement it from now on. Also, all the documents in the function are still in Japanese, so I have to change it to English (~~ troublesome ~~)
Recommended Posts