survival

Survival models - Computes survival and mortality functions

MIT License. Copyright (c) 2022-2023 Terence Lim

class actuarialmath.survival.Survival(**kwargs)[source]

Bases: Life

Set and derive basic survival and mortality functions

set_survival(S: Callable[[int, float, float], float] | None = None, f: Callable[[int, float, float], float] | None = None, l: Callable[[int, float], float] | None = None, mu: Callable[[int, float], float] | None = None, minage: int = 0, maxage: int = 1000) Survival[source]

Construct the basic survival and mortality functions given any one form

Parameters:
  • S – probability [x]+s survives t years

  • f – or lifetime density function of [x]+s after t years

  • l – or number of lives aged (x+t)

  • mu – or force of mortality at age (x+t)

  • maxage – maximum age

  • minage – minimum age

Examples:

>>> B, c = 0.00027, 1.1
>>> def S(x,s,t): return (math.exp(-B * c**(x+s) * (c**t - 1)/math.log(c)))
>>> life = Survival().set_survival(S=S)
>>> def ell(x,s): return (1 - (x+s) / 60)**(1 / 3)
>>> life = Survival().set_survival(l=ell)
l_x(x: int, s: int = 0) float[source]

Number of lives at integer age [x]+s: l_[x]+s

Parameters:
  • x – age of selection

  • s – years after selection

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

Number of deaths at integer age [x]+s: d_[x]+s

Parameters:
  • x – age of selection

  • s – years after selection

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

Probability that [x]+s lives another t years: : t_p_[x]+s

Parameters:
  • x – age of selection

  • s – years after selection

  • t – survives at least t years

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

Probability that [x]+s lives for u, but not t+u years: u|t_q_[x]+s

Parameters:
  • x – age of selection

  • s – years after selection

  • u – survives u years, then

  • t – dies within next t years

Examples:

>>> def ell(x,s): return (1-((x+s)/250)) if x+s < 40 else (1-((x+s)/100)**2)
>>> q = Survival().set_survival(l=ell).q_x(30, t=20)
f_x(x: int, s: int = 0, t: int = 0) float[source]

Lifetime density function of [x]+s after t years: f_[x]+s(t)

Parameters:
  • x – age of selection

  • s – years after selection

  • t – dies at year t

Examples:

>>> B, c = 0.00027, 1.1
>>> def S(x,s,t): return (math.exp(-B * c**(x+s) * (c**t - 1)/math.log(c)))
>>> f = Survival().set_survival(S=S).f_x(x=50, t=10)
mu_x(x: int, s: int = 0, t: int = 0) float[source]

Force of mortality of [x] at s+t years: mu_[x](s+t)

Parameters:
  • x – age of selection

  • s – years after selection

  • t – force of mortality at year t

Examples

>>> def ell(x, s): return (1 - (x+s) / 60)**(1 / 3)
>>> print(Survival().set_survival(l=ell).mu_x(35))