selectlife
Select and Ultimate Life Table – Loads and calculates select life tables
MIT License. Copyright 2022-2023 Terence Lim
- class actuarialmath.selectlife.SelectLife(periods: int = 0, udd: bool = True, verbose: bool = False, **kwargs)[source]
Bases:
LifeTable
Calculate select life table, and iteratively fill in missing values
- Parameters:
periods – number of select period years
verbose – whether to echo update steps
Notes
6 types of columns can be loaded and calculated in the select table:
‘q’ : probability [x]+s dies in one year
‘l’ : number of lives aged [x]+s
‘d’ : number of deaths of age [x]+s
‘A’ : whole life insurance
‘a’ : whole life annuity
‘e’ : expected future curtate lifetime of [x]+s
- __getitem__(table: str) Dict[int, float] [source]
Returns values from a select and ultimate table
- Parameters:
table – may be {‘l’, ‘q’, ‘e’, ‘d’, ‘a’, ‘A’}
- set_table(l: Dict[int, List[float]] | None = None, d: Dict[int, List[float]] | None = None, q: Dict[int, List[float]] | None = None, A: Dict[int, List[float]] | None = None, a: Dict[int, List[float]] | None = None, e: Dict[int, List[float]] | None = None, fill: bool = True, radix: int = 100000) SelectLife [source]
Update from table, every age has row for all select durations
- Parameters:
q – probability [x]+s dies in one year
l – number of lives aged [x]+s
d – number of deaths of [x]+s
A – whole life insurance, or
a – whole life annuity, or
e – expected future lifetime of [x]+s
radix – initial number of lives
fill – whether to fill missing values using recursion formulas
Examples
>>> life = SelectLife().set_table(l={55: [10000, 9493, 8533, 7664], >>> 56: [8547, 8028, 6889, 5630], >>> 57: [7011, 6443, 5395, 3904], >>> 58: [5853, 4846, 3548, 2210]}, >>> e={57: [None, None, None, 1]}) >>> print(life.e_r(58, s=2))
- set_select(s: int, age_selected: bool, radix: int = 100000, fill: bool = False, l: Dict[int, float] | None = None, d: Dict[int, float] | None = None, q: Dict[int, float] | None = None, A: Dict[int, float] | None = None, a: Dict[int, float] | None = None, e: Dict[int, float] | None = None) SelectLife [source]
Update a table column, for a particular duration s in the select period
- Parameters:
s – column to populate - n is ultimate, 0..n-1 is year after select
age_selected – is indexed by age selected or actual (False, default)
radix – initial number of lives
fill – whether to fill missing values using recursion formulas
q – probabilities [x]+s dies in next year, by age
l – number of lives aged [x]+s, by age
d – number of deaths of [x]+s, by age
A – whole life insurance of [x]+s, by age
a – whole life annuity of [x]+s, by age
e – expected future lifetime of [x]+s, by age
- fill_table(radix: int = 100000) SelectLife [source]
Fills in missing table values (does not check for consistency)
- Parameters:
radix – initial number of lives
- A_x(x: int, s: int = 0, moment: int = 1, discrete: bool = True, **kwargs) float [source]
Returns insurance value computed from select table
- Parameters:
x – age of selection
s – years after selection
- a_x(x: int, s: int = 0, moment: int = 1, discrete: bool = True, **kwargs) float [source]
Returns annuity value computed from select table
- Parameters:
x – age of selection
s – years after selection
- l_x(x: int, s: int = 0) float [source]
Returns number of lives aged [x]+s computed from select table
- Parameters:
x – age of selection
s – years after selection
- p_x(x: int, s: int = 0, t: int = 1) float [source]
t_p_[x]+s by chain rule: prod(1_p_[x]+s+y) for y in range(t)
- Parameters:
x – age of selection
s – years after selection
t – survives t years
- q_x(x: int, s: int = 0, t: int = 1, u: int = 0) float [source]
t|u_q_[x]+s = [x]+s survives u years, does not survive next t
- Parameters:
x – age of selection
s – years after selection
u – survives u years, then
t – dies within next t years
- e_x(x: int, s: int = 0, t: int = -999, curtate: int = True) float [source]
Returns expected life time computed from select table
- Parameters:
x – age of selection
s – years after selection
t – limit of expected future lifetime
- frame(table: str = 'l') DataFrame [source]
Returns select and ultimate table values as a DataFrame
- Parameters:
table – table to return, one of [‘A’, ‘a’, ‘q’, ‘d’, ‘e’, ‘l’]
Examples
>>> table={21: [.00120, .00150, .00170, .00180], >>> 22: [.00125, .00155, .00175, .00185], >>> 23: [.00130, .00160, .00180, .00195]} >>> life = SelectLife(verbose=True).set_table(q=table) >>> print(life.frame('l').round(1)) >>> print(life.frame('q').round(6))