lifetable

Life Tables - Loads and calculates life tables

MIT License. Copyright 2022-2023 Terence Lim

class actuarialmath.lifetable.LifeTable(udd: bool = True, verbose: bool = False, **kwargs)[source]

Bases: Reserves

Calculate life table, and iteratively fill in missing values

Parameters:
  • udd – assume UDD or constant force of mortality for fractional ages

  • verbose – whether to echo update steps

Notes

4 types of columns can be loaded and calculated in the life table:

  • ‘q’ : probability (x) dies in one year

  • ‘l’ : number of lives aged x

  • ‘d’ : number of deaths of age x

  • ‘p’ : probability (x) survives at least one year

set_table(radix: int = 100000, minage: int = -1, maxage: int = -1, fill: bool = True, l: Dict[int, float] | None = None, d: Dict[int, float] | None = None, p: Dict[int, float] | None = None, q: Dict[int, float] | None = None) LifeTable[source]

Update life table

Parameters:
  • l – lives at start of year x, or

  • d – deaths in year x, or

  • p – probabilities that (x) survives one year, or

  • q – probabilities that (x) dies in one year

  • fill – whether to automatically fill table cells (default is True)

  • minage – minimum age in table

  • maxage – maximum age in table

  • radix – initial number of lives

Examples:

>>> life = LifeTable(udd=True).set_table(l={90: 1000, 93: 825},
>>>                                      d={97: 72},
>>>                                      p={96: .2},
>>>                                      q={95: .4, 97: 1})
fill_table(radix: int) LifeTable[source]

Iteratively fill in missing table cells (does not check consistency)

Parameters:

radix – initial number of lives

mu_x(x: int, s: int = 0, t: int = 0) float[source]

Compute mu_x from p_x in life table

Parameters:
  • x – age of selection

  • s – years after selection

  • t – death within next t years

l_x(x: int, s: int = 0) float[source]

Lookup l_x from life table

Parameters:
  • x – age of selection

  • s – years after selection

d_x(x: int, s: int = 0, t: int = 1) float[source]

Compute deaths as lives at x_t divided by lives at x

Parameters:
  • x – age of selection

  • s – years after selection

  • t – death within next t years

p_x(x: int, s: int = 0, t: int = 1) float[source]

t_p_x = lives beginning year x+t divided lives beginning year x

Parameters:
  • x – age of selection

  • s – years after selection

  • t – death within next t years

q_x(x: int, s: int = 0, t: int = 1, u: int = 0) float[source]

Deferred mortality: u|t_q_x = (l[x+u] - l[x+u+t]) / l[x]

Parameters:
  • x – age of selection

  • s – years after selection

  • u – survive u years, then…

  • t – death within next t years

e_x(x: int, s: int = 0, n: int = -999, curtate: bool = True, moment: int = 1) float[source]

Expected curtate lifetime from sum of lives in table

Parameters:
  • x – age of selection

  • s – years after selection

  • n – future lifetime limited at n years

  • curtate – whether curtate (True) or complete (False) expectations

  • moment – whether to compute first (1) or second (2) moment

E_x(x: int, s: int = 0, t: int = 1, moment: int = 1) float[source]

Pure Endowment from life table and interest rate

Parameters:
  • x – age of selection

  • s – years after selection

  • t – survives t years

  • moment – return first (1) or second (2) moment or variance (-2)

__getitem__(col: str) Dict[int, float][source]

Returns a column of the life table

Parameters:

col – name of life table column to return

frame() DataFrame[source]

Return life table columns and values in a DataFrame