Awesome work on the input data preparation! Now, we will move the core part of the model. Let's do this!
First, import the input data from the file input.py. Open the file model.py.
In the file model.py, you will find an example variable. You may comment it out or remove it to keep the file clean.
Import the following data:
In your script, complete the code below:
# model.py
from input import _____, _____
Create a variable survival_rate(t) that calculates the probability of surviving t months from the start of the contract.
Use the following recursive relationship.
\[ \text{survival_rate(t)} = {}_tp_x = {}_{t-1}p_x \cdot (1-q_{x+t-1}) \]Assume that:
Complete the function below:
# model.py
@variable()
def survival_rate(t):
if t == 0:
return 1
else:
q = policy.get("_____")
return survival_rate(t - 1) * (_____ )
Task: