{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Generating model points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook generates the sample model points used by the `BasicTerm_S` and `BasicTerm_M` models, by using random numbers.\n", "`BasicTerm_S` and `BasicTerm_M` are new business models, so no duration information is included.\n", "\n", "**Columns:**\n", "\n", "* `point_id`: Model point identifier\n", "* `age_at_entry`: Issue age. The samples are distributed uniformly from 20 to 59.\n", "* `sex`: \"M\" or \"F\" to indicate policy holder's sex. Not used by default.\n", "* `policy_term`: Policy term in years. The samples are evenly distriubted among 10, 15 and 20.\n", "* `policy_count`: The number of policies. Not used by default. \n", "* `sum_assured`: Sum assured. The samples are uniformly distributed from 10,000 to 1,000,000.\n", "\n", "**Number of model points:**\n", "\n", "* 10000\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from numpy.random import default_rng # Requires NumPy 1.17 or newer\n", "\n", "rng = default_rng(12345)\n", "\n", "# Number of Model Points\n", "MPCount = 10000\n", "\n", "# Issue Age (Integer): 20 - 59 year old\n", "\n", "age_at_entry = rng.integers(low=20, high=60, size=MPCount)\n", "\n", "# Sex (Char)\n", "\n", "Sex = [\n", " \"M\",\n", " \"F\"\n", "]\n", "\n", "sex = np.fromiter(map(lambda i: Sex[i], rng.integers(low=0, high=len(Sex), size=MPCount)), np.dtype('\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
age_at_entrysexpolicy_termpolicy_countsum_assured
policy_id
147M101622000.0
229M201752000.0
351F101799000.0
432F201422000.0
528M151605000.0
..................
999647M201827000.0
999730M151826000.0
999845F201783000.0
999939M201302000.0
1000022F151576000.0
\n", "

10000 rows × 5 columns

\n", "" ], "text/plain": [ " age_at_entry sex policy_term policy_count sum_assured\n", "policy_id \n", "1 47 M 10 1 622000.0\n", "2 29 M 20 1 752000.0\n", "3 51 F 10 1 799000.0\n", "4 32 F 20 1 422000.0\n", "5 28 M 15 1 605000.0\n", "... ... .. ... ... ...\n", "9996 47 M 20 1 827000.0\n", "9997 30 M 15 1 826000.0\n", "9998 45 F 20 1 783000.0\n", "9999 39 M 20 1 302000.0\n", "10000 22 F 15 1 576000.0\n", "\n", "[10000 rows x 5 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "attrs = [\n", " \"age_at_entry\",\n", " \"sex\",\n", " \"policy_term\",\n", " \"policy_count\",\n", " \"sum_assured\"\n", "]\n", "\n", "data = [\n", " age_at_entry,\n", " sex,\n", " policy_term,\n", " policy_count,\n", " sum_assured\n", "]\n", "\n", "model_point_table = pd.DataFrame(dict(zip(attrs, data)), index=range(1, MPCount+1))\n", "model_point_table.index.name = \"policy_id\"\n", "model_point_table" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "model_point_table.to_excel(\"model_point_table.xlsx\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }