<h1>NumberCommutation</h1>
Pyrisky is an easy-to-use python library for actuarial calculations, focused on mortality tables and annuity calculations.
Date: 2024-02-12<br/>
Version: 0.0.3<br/>
Author: Pedro Cavalcante<br/>
Introduction
------------
**NumberCommutation** is an open library written in Python for calculating annuities and actuarial tables, based on methodologies commonly used among Brazilian actuaries.
This library consists of only one file module and has dependencies on the Pandas and Numpy libraries.
Installation
------------
Once Pyhon is running, just install this library with ``pip install NumberCommutation``
Quick Start
------------
The import process boils down to the command ``from NumberCommutation import Pyrisky``
The names of functions and variables follow the Actuarial Notation of switching numbers: lx, dx, qx, px, Lx, Tx, Ex, Dx, Nx, Cx, Mx, Sx, äx, ax.
The functions created were as follows:
To create a complete mortality table we have ``AllTable()``:
* ``lx`` = The actuarial table used to estimate the number of people alive at age X.
* ``taxa`` = interest rate in one year.
The ``idade_inicio`` variable can be omitted, in this case it will be 0 by default. It indicates the age at which lx begins.
This formula must include at least 2 variables: lx and taxa
If necessary, the idade_inicio variable must be included if the informed lx does not start at age 0.
There is also a way to calculate an individual commutation number at a specific age x, through ``Commutation()``:
* ``idade`` = Series of data referring to age(x) according to the probability data entered.
* ``dados`` = Data series referring to probabilistic survival or death data
The variable ``data_type`` defaults to 'q', indicating that the data are probabilities of death (qx). However, this variable accepts three more arguments: 'p' (px), 'd' (dx) and 'l' (lx).
There is also the variable ``amostra``, which defaults to 1000000. Indicating the radix of the sample or the initial number of people at age 0.
That said, we have the switching functions that come with ``Commutation``:
Those that only need to inform the age (X) sought are:
lx = Number of living people aged x
px = A person's probability of survival aged 𝑥 before reaching age 𝑥 + 1.
qx = Probability of death of a person aged 𝑥 before of reaching the age of 𝑥 + 1 years.
dx = Number of people who died between ages 𝑥 and 𝑥 + 1.
Lx = Time lived in the age range 𝑥 to 𝑥 + 1 (amount of person-years between ages 𝑥 and 𝑥 + 1).
Tx = Time lived from age 𝑥 (number of person-years to from age 𝑥).
ex = Average number of years someone of x age should live.
And those that only need to inform the age (X) and the interest rate sought are:
Dx = Indicates how many individuals from a given cohort (group of people) will survive from age x to age x + n, where n is the age range.
Nx = The expected number of deaths between age x and age x + 1.
Cx = The remaining life expectancy of a person who has already reached age x.
Mx = Represents the probability that a person of exactly x years of age will die before reaching the next oldest age, that is, the probability that a person will die during the interval of one year.
**Example 1:**
Print the complete mortality table. Based on the lx of the BR-EMSsb-2021-m table and an interest rate of 5%:
```python
from NumberCommutation import Pyrisky
import pandas as pd
# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems
Tabua = pd.read_excel("tabuas-br-ems-2010-2015-2021-010721.xlsx", sheet_name = "BR-EMSsb-2021-m ",skiprows=5)
print(TableAnnuity(Tabua["lx"],0.05).AllTable())
```
**Example 2:**
Calculating the Time lived in the age range of 10 to 11 years and the Time lived from age 10 onwards:
```python
from NumberCommutation import Pyrisky
import pandas as pd
# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems
Tabua = pd.read_excel("tabuas-br-ems-2010-2015-2021-010721.xlsx", sheet_name = "BR-EMSsb-2021-m ",skiprows=5)
print(Comutation(Tabua["Idade"], Tabua["qx"], data_type='q').Lx(10))
print(Comutation(Tabua["Idade"], Tabua["lx"], data_type='l').Tx(10))
```
**Example 3:**:
Calculating the expected number of deaths between age 10 and age 11 years old, at a rate of 5%::
```python
from NumberCommutation import Pyrisky
import pandas as pd
# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems
Tabua = pd.read_excel("tabuas-br-ems-2010-2015-2021-010721.xlsx", sheet_name = "BR-EMSsb-2021-m ",skiprows=5)
print(Comutation(Tabua["Idade"],1 - Tabua["qx"], data_type='p').Nx(10, 0.05))
```
Requeriments
------------
It can be used in both Python versions 2.7 and 3.6.
Pylirisky has dependencies on the Pandas and Numpy Libraries.
Contributions
-------------
Any comments, suggestions or improvements are very welcome.
For this purpose, I remain at your disposal through my email: ph.cavalcante29@gmail.com.
Raw data
{
"_id": null,
"home_page": null,
"name": "NumberCommutation",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Matem\u00e1tica Atuarial, N\u00fameros de comuta\u00e7\u00e3o",
"author": "Pedro Cavalcante",
"author_email": "ph.cavalcante29@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7f/dd/6eaf89e2ac3af3c5ecccf5f4b9268dfd186f531be554b004bfdc2598ad9f/NumberCommutation-0.0.3.tar.gz",
"platform": null,
"description": "<h1>NumberCommutation</h1>\r\nPyrisky is an easy-to-use python library for actuarial calculations, focused on mortality tables and annuity calculations.\r\n\r\nDate: 2024-02-12<br/>\r\nVersion: 0.0.3<br/>\r\nAuthor: Pedro Cavalcante<br/>\r\n\r\nIntroduction\r\n------------\r\n**NumberCommutation** is an open library written in Python for calculating annuities and actuarial tables, based on methodologies commonly used among Brazilian actuaries.\r\n\r\nThis library consists of only one file module and has dependencies on the Pandas and Numpy libraries.\r\n\r\nInstallation\r\n------------\r\nOnce Pyhon is running, just install this library with ``pip install NumberCommutation`` \r\n\r\nQuick Start\r\n------------\r\n\r\nThe import process boils down to the command ``from NumberCommutation import Pyrisky``\r\n\r\nThe names of functions and variables follow the Actuarial Notation of switching numbers: lx, dx, qx, px, Lx, Tx, Ex, Dx, Nx, Cx, Mx, Sx, \u00e4x, ax.\r\n\r\nThe functions created were as follows:\r\n\r\nTo create a complete mortality table we have ``AllTable()``:\r\n\r\n* ``lx`` = The actuarial table used to estimate the number of people alive at age X.\r\n\r\n* ``taxa`` = interest rate in one year.\r\n\r\nThe ``idade_inicio`` variable can be omitted, in this case it will be 0 by default. It indicates the age at which lx begins.\r\n\r\nThis formula must include at least 2 variables: lx and taxa\r\nIf necessary, the idade_inicio variable must be included if the informed lx does not start at age 0.\r\n\r\nThere is also a way to calculate an individual commutation number at a specific age x, through ``Commutation()``:\r\n\r\n* ``idade`` = Series of data referring to age(x) according to the probability data entered.\r\n\r\n* ``dados`` = Data series referring to probabilistic survival or death data\r\n\r\nThe variable ``data_type`` defaults to 'q', indicating that the data are probabilities of death (qx). However, this variable accepts three more arguments: 'p' (px), 'd' (dx) and 'l' (lx).\r\n\r\nThere is also the variable ``amostra``, which defaults to 1000000. Indicating the radix of the sample or the initial number of people at age 0.\r\n\r\nThat said, we have the switching functions that come with ``Commutation``:\r\n\r\nThose that only need to inform the age (X) sought are:\r\n\r\nlx = Number of living people aged x\r\npx = A person's probability of survival aged \ud835\udc65 before reaching age \ud835\udc65 + 1.\r\nqx = Probability of death of a person aged \ud835\udc65 before of reaching the age of \ud835\udc65 + 1 years.\r\ndx = Number of people who died between ages \ud835\udc65 and \ud835\udc65 + 1.\r\nLx = Time lived in the age range \ud835\udc65 to \ud835\udc65 + 1 (amount of person-years between ages \ud835\udc65 and \ud835\udc65 + 1).\r\nTx = Time lived from age \ud835\udc65 (number of person-years to from age \ud835\udc65).\r\nex = Average number of years someone of x age should live.\r\n\r\nAnd those that only need to inform the age (X) and the interest rate sought are:\r\n\r\nDx = Indicates how many individuals from a given cohort (group of people) will survive from age x to age x + n, where n is the age range.\r\nNx = The expected number of deaths between age x and age x + 1.\r\nCx = The remaining life expectancy of a person who has already reached age x.\r\nMx = Represents the probability that a person of exactly x years of age will die before reaching the next oldest age, that is, the probability that a person will die during the interval of one year.\r\n\r\n**Example 1:**\r\nPrint the complete mortality table. Based on the lx of the BR-EMSsb-2021-m table and an interest rate of 5%:\r\n```python\r\nfrom NumberCommutation import Pyrisky\r\nimport pandas as pd\r\n\r\n# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems\r\n\r\nTabua = pd.read_excel(\"tabuas-br-ems-2010-2015-2021-010721.xlsx\", sheet_name = \"BR-EMSsb-2021-m \",skiprows=5)\r\n\r\nprint(TableAnnuity(Tabua[\"lx\"],0.05).AllTable())\r\n```\r\n\r\n**Example 2:**\r\nCalculating the Time lived in the age range of 10 to 11 years and the Time lived from age 10 onwards:\r\n```python\r\nfrom NumberCommutation import Pyrisky\r\nimport pandas as pd\r\n\r\n# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems\r\n\r\nTabua = pd.read_excel(\"tabuas-br-ems-2010-2015-2021-010721.xlsx\", sheet_name = \"BR-EMSsb-2021-m \",skiprows=5)\r\n\r\nprint(Comutation(Tabua[\"Idade\"], Tabua[\"qx\"], data_type='q').Lx(10))\r\nprint(Comutation(Tabua[\"Idade\"], Tabua[\"lx\"], data_type='l').Tx(10))\r\n\r\n```\r\n\r\n**Example 3:**:\r\nCalculating the expected number of deaths between age 10 and age 11 years old, at a rate of 5%::\r\n```python\r\nfrom NumberCommutation import Pyrisky\r\nimport pandas as pd\r\n\r\n# To download the table go to: https://www.gov.br/susep/pt-br/assuntos/informacoes-ao-mercado/informacoes-tecnicas-e-planos-padroes/tabuas-biometricas-br-ems\r\n\r\nTabua = pd.read_excel(\"tabuas-br-ems-2010-2015-2021-010721.xlsx\", sheet_name = \"BR-EMSsb-2021-m \",skiprows=5)\r\n\r\nprint(Comutation(Tabua[\"Idade\"],1 - Tabua[\"qx\"], data_type='p').Nx(10, 0.05))\r\n```\r\n\r\nRequeriments\r\n------------\r\nIt can be used in both Python versions 2.7 and 3.6.\r\nPylirisky has dependencies on the Pandas and Numpy Libraries.\r\n\r\nContributions\r\n-------------\r\n\r\nAny comments, suggestions or improvements are very welcome.\r\n\r\nFor this purpose, I remain at your disposal through my email: ph.cavalcante29@gmail.com.\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Um agrupamento de calculos atuariais",
"version": "0.0.3",
"project_urls": null,
"split_keywords": [
"matem\u00e1tica atuarial",
" n\u00fameros de comuta\u00e7\u00e3o"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dc6fde5952f030d8422312aa47e6043d88de01140675f783c39fb14d4ddb5f07",
"md5": "255bf31c83d09b166e7cd44145a36abb",
"sha256": "5bf936de0ce895b640dd5491e28e068c30f30a7d637d6f02a57f1f22dc0d41e2"
},
"downloads": -1,
"filename": "NumberCommutation-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "255bf31c83d09b166e7cd44145a36abb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6090,
"upload_time": "2024-04-01T23:13:23",
"upload_time_iso_8601": "2024-04-01T23:13:23.476821Z",
"url": "https://files.pythonhosted.org/packages/dc/6f/de5952f030d8422312aa47e6043d88de01140675f783c39fb14d4ddb5f07/NumberCommutation-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7fdd6eaf89e2ac3af3c5ecccf5f4b9268dfd186f531be554b004bfdc2598ad9f",
"md5": "e58327687f0b31726073a5bd826f88cf",
"sha256": "16d90ab011f68280378431d467e3ead72028fc6f168e23ba34996e64aa1f6236"
},
"downloads": -1,
"filename": "NumberCommutation-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "e58327687f0b31726073a5bd826f88cf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5808,
"upload_time": "2024-04-01T23:13:25",
"upload_time_iso_8601": "2024-04-01T23:13:25.541391Z",
"url": "https://files.pythonhosted.org/packages/7f/dd/6eaf89e2ac3af3c5ecccf5f4b9268dfd186f531be554b004bfdc2598ad9f/NumberCommutation-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-01 23:13:25",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "numbercommutation"
}