Generating model points#
This notebook generates the sample model points used by the BasicTerm_S
and BasicTerm_M
models, by using random numbers. BasicTerm_S
and BasicTerm_M
are new business models, so no duration information is included.
Columns:
point_id
: Model point identifierage_at_entry
: Issue age. The samples are distributed uniformly from 20 to 59.sex
: “M” or “F” to indicate policy holder’s sex. Not used by default.policy_term
: Policy term in years. The samples are evenly distriubted among 10, 15 and 20.policy_count
: The number of policies. Not used by default.sum_assured
: Sum assured. The samples are uniformly distributed from 10,000 to 1,000,000.
Number of model points:
10000
Click the badge below to run this notebook online on Google Colab. You need a Google account and need to be logged in to it to run this notebook on Google Colab.
The next code cell below is relevant only when you run this notebook on Google Colab. It installs lifelib and creates a copy of the library for this notebook.
[3]:
import sys, os
if 'google.colab' in sys.modules:
lib = 'basiclife'; lib_dir = '/content/'+ lib
if not os.path.exists(lib_dir):
!pip install lifelib
import lifelib; lifelib.create(lib, lib_dir)
%cd $lib_dir
[4]:
import numpy as np
from numpy.random import default_rng # Requires NumPy 1.17 or newer
rng = default_rng(12345)
# Number of Model Points
MPCount = 10000
# Issue Age (Integer): 20 - 59 year old
age_at_entry = rng.integers(low=20, high=60, size=MPCount)
# Sex (Char)
Sex = [
"M",
"F"
]
sex = np.fromiter(map(lambda i: Sex[i], rng.integers(low=0, high=len(Sex), size=MPCount)), np.dtype('<U1'))
# Policy Term (Integer): 10, 15, 20
policy_term = rng.integers(low=0, high=3, size=MPCount) * 5 + 10
# Policy Count (Integer): 1
policy_count = [1] * MPCount
# Sum Assured (Float): 10000 - 1000000
sum_assured = np.round((1000000 - 10000) * rng.random(size=MPCount) + 10000, -3)
[5]:
import pandas as pd
attrs = [
"age_at_entry",
"sex",
"policy_term",
"policy_count",
"sum_assured"
]
data = [
age_at_entry,
sex,
policy_term,
policy_count,
sum_assured
]
model_point_table = pd.DataFrame(dict(zip(attrs, data)), index=range(1, MPCount+1))
model_point_table.index.name = "policy_id"
model_point_table
[5]:
age_at_entry | sex | policy_term | policy_count | sum_assured | |
---|---|---|---|---|---|
policy_id | |||||
1 | 47 | M | 10 | 1 | 622000.0 |
2 | 29 | M | 20 | 1 | 752000.0 |
3 | 51 | F | 10 | 1 | 799000.0 |
4 | 32 | F | 20 | 1 | 422000.0 |
5 | 28 | M | 15 | 1 | 605000.0 |
... | ... | ... | ... | ... | ... |
9996 | 47 | M | 20 | 1 | 827000.0 |
9997 | 30 | M | 15 | 1 | 826000.0 |
9998 | 45 | F | 20 | 1 | 783000.0 |
9999 | 39 | M | 20 | 1 | 302000.0 |
10000 | 22 | F | 15 | 1 | 576000.0 |
10000 rows × 5 columns
[6]:
model_point_table.to_excel("model_point_table.xlsx")