!pip install pyliferisk
Collecting pyliferisk Downloading pyliferisk-1.12.0-py3-none-any.whl (39 kB) Installing collected packages: pyliferisk Successfully installed pyliferisk-1.12.0
Print the omega (limiting age) of the both mortality tables and the qx at 50 years-old.
from pyliferisk import MortalityTable
from pyliferisk.mortalitytables import SPAININE2004, GKM95
tariff = MortalityTable(nt=SPAININE2004)
experience = MortalityTable(nt=GKM95, perc=85)
# Print the omega (limiting age) of the both tables:
print(tariff.w)
print(experience.w)
# Print the qx at 50 years old:
print(tariff.qx[50] / 1000)
print(experience.qx[50] / 1000)
101 121 0.003113 0.003662395
Plotting a surviving graph.
import matplotlib.pyplot as plt
from pyliferisk import *
from pyliferisk.mortalitytables import SPAININE2004, GKM95
tariff = MortalityTable(nt=SPAININE2004)
experience = MortalityTable(nt=GKM95, perc=75)
x = range(0, tariff.w)
y = tariff.lx[:tariff.w]
z = experience.lx[:tariff.w]
plt.plot(x,y, color = 'blue')
plt.plot(x,z, color = 'red')
plt.ylabel('lx')
plt.xlabel('age')
Text(0.5, 0, 'age')
A Life Temporal insurance for a male, 30 years-old and a horizon for 10 years, fixed annual premium (GKM95, interest 6%):
from pyliferisk import *
from pyliferisk.mortalitytables import GKM95
nt = Actuarial(nt=GKM95, i=0.06)
x = 30
n = 10
C = 1000
print(C * (Axn(nt, x, n) / annuity(nt, x, n, 0)))
1.3581166922356989