{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "markdown", "id": "c15ecb78", "metadata": { "id": "c15ecb78" }, "source": [ "# Librería actuarial pyliferisk\n", "[pyliferisk](https://pypi.org/project/pyliferisk)" ] }, { "cell_type": "code", "execution_count": 1, "id": "4071948c", "metadata": { "id": "4071948c", "outputId": "61633ed1-b929-4a3e-b6a0-52575b66a5ea", "colab": { "base_uri": "https://localhost:8080/" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Collecting pyliferisk\n", " Downloading pyliferisk-1.12.0-py3-none-any.whl (39 kB)\n", "Installing collected packages: pyliferisk\n", "Successfully installed pyliferisk-1.12.0\n" ] } ], "source": [ "!pip install pyliferisk" ] }, { "cell_type": "markdown", "id": "0cd40427", "metadata": { "id": "0cd40427" }, "source": [ "### Example 1\n", "Print the omega (limiting age) of the both mortality tables and the qx at 50 years-old." ] }, { "cell_type": "code", "execution_count": null, "id": "53887354", "metadata": { "id": "53887354", "outputId": "a445e67e-34f4-44c6-9b17-204cc676bb15" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "101\n", "121\n", "0.003113\n", "0.003662395\n" ] } ], "source": [ "from pyliferisk import MortalityTable\n", "from pyliferisk.mortalitytables import SPAININE2004, GKM95\n", "\n", "tariff = MortalityTable(nt=SPAININE2004)\n", "experience = MortalityTable(nt=GKM95, perc=85)\n", "\n", "# Print the omega (limiting age) of the both tables:\n", "print(tariff.w)\n", "print(experience.w)\n", "\n", "# Print the qx at 50 years old:\n", "print(tariff.qx[50] / 1000)\n", "print(experience.qx[50] / 1000)" ] }, { "cell_type": "markdown", "id": "b1076f4a", "metadata": { "id": "b1076f4a" }, "source": [ "### Example 2\n", "Plotting a surviving graph." ] }, { "cell_type": "code", "execution_count": null, "id": "2986bdfb", "metadata": { "id": "2986bdfb", "outputId": "3041327d-92f7-45d0-a4cc-8f8d8bbb4c66" }, "outputs": [ { "data": { "text/plain": [ "Text(0.5, 0, 'age')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAEGCAYAAABYV4NmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAsKElEQVR4nO3deXhU5fn/8fedhCWsSUhAFhGquAAKQkpFrVopSFsUUbG4gYoi/Kz7UnCpK1aKC4JFiyiiFUEpVmyLyhe3WhXFDRAEogiGHRJ2BEKe3x/PCWSZYITMnMnk87qu05l5zjmT+xTMzbObcw4REZHKlhR2ACIikpiUYEREJCqUYEREJCqUYEREJCqUYEREJCpSwg4gXmRmZrpWrVqFHYaISJXy6aefrnfOZUU6pwQTaNWqFXPmzAk7DBGRKsXMlpV3Tk1kIiISFUowIiISFUowIiISFUowIiISFUowIiISFVFLMGb2jJmtNbP5xcoyzGymmS0JXtOLnRtmZjlmtsjMzihW3tnM5gXnRpuZBeW1zGxKUD7bzFoVu2dA8DOWmNmAaD2jiIiUL5o1mGeBnqXKhgKznHNtgFnBZ8ysLdAPaBfcM9bMkoN7ngAGAW2Co+g7BwL5zrkjgEeBEcF3ZQB3Ab8AugB3FU9kIiISG1GbB+Oce694rSLQGzgteD8ReAf4Y1A+2Tm3E1hqZjlAFzP7DmjgnPsQwMyeA84GZgT33B1811Tg8aB2cwYw0zmXF9wzE5+UXqzsZwQo3LKNWT1G0KIFtGoFqanR+ClRkpwMjRpBZmbZo3btsKMTkSou1hMtmzjnVgE451aZWeOgvDnwUbHrcoOy3cH70uVF93wffFeBmW0CGhUvj3BPCWY2CF87omXLlgf0QLmLt9Pto/v3fi48oG/ZP9v7P5X8vfvZC6gwtS57MjJxGZm4zEwsK5OkxpkkN/bv9yamRo32HUpKIlJMvMzkj/Tr0+2n/EDvKVno3DhgHEB2dvYB7bzWsnMW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o557YGNZhX8NtBvBJ2XCIVpRqMSPy628y+AOYDS/H7d4hUGarBiIhIVKgGIyIiUaEEIyIiUaEEIyIiUaEEIyIiUaEEIyIiUfH/Ac4uztoPbaxgAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import matplotlib.pyplot as plt\n", "from pyliferisk import *\n", "from pyliferisk.mortalitytables import SPAININE2004, GKM95\n", "\n", "tariff = MortalityTable(nt=SPAININE2004)\n", "experience = MortalityTable(nt=GKM95, perc=75)\n", "x = range(0, tariff.w)\n", "y = tariff.lx[:tariff.w]\n", "z = experience.lx[:tariff.w]\n", "\n", "plt.plot(x,y, color = 'blue')\n", "plt.plot(x,z, color = 'red')\n", "plt.ylabel('lx')\n", "plt.xlabel('age')" ] }, { "cell_type": "markdown", "id": "a7985487", "metadata": { "id": "a7985487" }, "source": [ "### Example 3\n", "A Life Temporal insurance for a male, 30 years-old and a horizon for 10 years, fixed annual premium (GKM95, interest 6%):" ] }, { "cell_type": "code", "execution_count": null, "id": "3b644d2d", "metadata": { "id": "3b644d2d", "outputId": "339554a3-1a48-435e-e04c-9da13f56042f" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.3581166922356989\n" ] } ], "source": [ "from pyliferisk import *\n", "from pyliferisk.mortalitytables import GKM95\n", "\n", "nt = Actuarial(nt=GKM95, i=0.06)\n", "x = 30\n", "n = 10\n", "C = 1000\n", "\n", "print(C * (Axn(nt, x, n) / annuity(nt, x, n, 0)))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.11" }, "colab": { "name": "0230_libreria_pyliferisk.ipynb", "provenance": [], "include_colab_link": true } }, "nbformat": 4, "nbformat_minor": 5 }