Fantastic work on the survival rate calculation! You are an awesome modeller! In this lesson, we will calculate two more variables: expected benefit and net single premium. Let's do it!
Define the variable expected_benefit(t) - the expected value of the benefit paid in month t.
Use the formula:
\[ \text{expected_benefit(t)} = B \cdot {}_{t-1}p_x \cdot q_{x+t-1} \]Remember that:
Complete the code below:
# model.py
@variable()
def expected_benefit(t):
if t == 0 or t > policy.get("_____"):
return 0
else:
B = policy.get("_____")
q = policy.get("_____")
return B * _____ * q
Task:
Calculate the value of the net single premium, i.e. the present value of expected benefits.
Use a recursive approach:
\[ \text{net_single_premium(t)} = \text{expected_benefit(t)} + \text{net_single_premium(t+1)} \cdot v \]where:
Note that the maximum value of t is defined in settings.py as T_MAX_CALCULATION.
Complete the code below:
# model.py
from settings import settings
@variable()
def net_single_premium(t):
if t == settings["_____"]:
return _____
else:
v = 1 / (1 + _____)
return _____ + v * _____
Task: