Fantastic work on the survival rate and expected benefit! There is one more step before us... In this lesson we will get to the most important part - actuarial present value!
Calculate the actuarial present value (APV) which is the sum of discounted expected benefits.
Use a recursive approach:
\( \text{APV(t)} = \text{expected_benefit(t)} + \text{APV(t+1)} \cdot v \)where:
Remember that for the last month (maximum t), the actuarial present value equals the expected benefit.
Fill in the code:
# model.py
from settings import settings
@variable()
def actuarial_present_value(t):
if t == settings["_____"]:
return _____
else:
v = 1 / (1 + _____)
return _____ + v * _____
Task:
By default, the results are presented in the aggregated way. However, for various reasons - such as debugging - you might want to see the results for each insured person separately.
To get results for each insured person separately, set in settings.py:
# settings.py
settings = {
"GROUP_BY": "id",
}
Task: Change the settings to get results for each insured person separately.