insurance
Life insurance - Computes present values of insurance benefits
MIT License. Copyright (c) 2022-2023 Terence Lim
- class actuarialmath.insurance.Insurance(udd: bool = True, **kwargs)[source]
Bases:
Fractional
Compute expected present values of life insurance
- E_x(x: int, s: int = 0, t: int = 1, endowment: int = 1, moment: int = 1) float [source]
Pure endowment: t_E_x
- Parameters:
x – age of selection
s – years after selection
t – term of pure endowment
endowment – amount of pure endowment
moment – compute first or second moment
Examples:
>>> life = Insurance().set_survival(mu=lambda x,t: .02*t).set_interest(i=.03) >>> var = life.E_x(0, t=15, moment=life.VARIANCE, endowment=10000)
- A_x(x: int, s: int = 0, t: int = -999, u: int = 0, benefit: ~typing.Callable = <function Insurance.<lambda>>, endowment: float = 0.0, moment: int = 1, discrete: bool = True) float [source]
Numerically compute EPV of insurance from basic survival functions
- Parameters:
x – age of selection
s – years after selection
u – year deferred
t – term of insurance
benefit – benefit as a function of age and year
endowment – amount of endowment for endowment insurance
moment – compute first or second moment
discrete – benefit paid yearend (True) or moment of death (False)
Examples:
>>> life = Insurance().set_interest(delta=.05) >>> .set_survival(mu=lambda x,s: .03) >>> benefit = lambda x,t: math.exp(0.04 * t) >>> A = life.A_x(0, benefit=benefit) >>> print(A) # 0.75 >>> A2 = life.A_x(0, moment=2, benefit=benefit) >>> print(A2) #0.60
- static insurance_variance(A2: float, A1: float, b: float = 1) float [source]
Compute variance of insurance given moments and benefit
- Parameters:
A2 – second moment of insurance r.v.
A1 – first moment of insurance r.v.
b – benefit amount
- whole_life_insurance(x: int, s: int = 0, moment: int = 1, b: int = 1, discrete: bool = True) float [source]
Whole life insurance: A_x
- Parameters:
x – age of selection
s – years after selection
b – amount of benefit
moment – compute first or second moment
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.whole_life_insurance(x=0)
- term_insurance(x: int, s: int = 0, t: int = 1, b: int = 1, moment: int = 1, discrete: bool = True) float [source]
Term life insurance: A_x:t^1
- Parameters:
x – age of selection
s – years after selection
t – term of insurance
b – amount of benefit
moment – compute first or second moment
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.term_insurance(x=0, t=30)
- deferred_insurance(x: int, s: int = 0, u: int = 0, t: int = -999, b: int = 1, moment: int = 1, discrete: bool = True) float [source]
Deferred insurance n|_A_x:t^1 = discounted term or whole life
- Parameters:
x – age of selection
s – years after selection
u – year deferred
t – term of insurance
b – amount of benefit
moment – compute first or second moment
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.deferred_insurance(x=0, u=10, t=20)
- endowment_insurance(x: int, s: int = 0, t: int = 1, b: int = 1, endowment: int = -1, moment: int = 1, discrete: bool = True) float [source]
Endowment insurance: A_x^1:t = term insurance + pure endowment
- Parameters:
x – age of selection
s – years after selection
t – term of insurance
b – amount of benefit
endowment – amount of endowment paid at end of term if survive
moment – compute first or second moment
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.endowment_insurance(x=0, t=10)
- increasing_insurance(x: int, s: int = 0, t: int = -999, b: int = 1, discrete: bool = True) float [source]
Increasing life insurance: (IA)_x
- Parameters:
x – age of selection
s – years after selection
t – term of insurance
b – amount of benefit in first year
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.increasing_insurance(x=0, t=10)
- decreasing_insurance(x, s: int = 0, t: int = 1, b: int = 1, discrete: bool = True) float [source]
Decreasing life insurance: (DA)_x
- Parameters:
x – age of selection
s – years after selection
t – term of insurance
b – amount of benefit in first year
discrete – benefit paid year-end (True) or moment of death (False)
Examples:
>>> life.decreasing_insurance(x=0, t=10)
- Z_x(x, s: int = 0, t: float = 0.0, discrete: bool = True)[source]
EPV of year t insurance death benefit for life aged [x]+s: b_x[s]+s(t)
- Parameters:
x – age of selection
s – years after selection
t – year of benefit
discrete – benefit paid year-end (True) or moment of death (False)
- Z_t(x: int, prob: float, discrete: bool = True) float [source]
T_x, given the prob of the PV of life insurance, i.e. r.v. Z(t)
- Parameters:
x – age initially insured
prob – desired probability threshold
discrete – benefit paid year-end (True) or moment of death (False)
- Returns:
T s.t. S(t)==prob; if discrete, return K=floor(T) s.t. S(K)>=prob
Examples
>>> t = life.Z_t(x=20, prob=0.8, discrete=True)
- Z_from_t(t: float, discrete: bool = True) float [source]
PV of annual or continuous insurance payment Z(t) at t=T_x
- Parameters:
t – year of death
b – benefit paid at t
discrete – benefit paid year-end (True) or moment of death (False)
Examples
>>> t = life.Z_t(x=20, prob=0.8, discrete=True) >>> print(Z, life.Z_from_t(t, discrete=True))
- Z_from_prob(x: int, prob: float, discrete: bool = True) float [source]
Percentile of annual or continuous WL insurance PV r.v. Z given probability
- Parameters:
x – age initially insured
prob – threshold for probability of survival
discrete – benefit paid year-end (True) or moment of death (False)
Examples
>>> Z = life.Z_from_prob(x=20, prob=0.8, discrete=True)
- Z_to_t(Z: float) float [source]
T_x s.t. PV of continuous WL insurance payment is Z
- Parameters:
Z – Present value of benefit paid
Examples
>>> t = life.Z_t(x=20, prob=0.8, discrete=False) >>> Z = life.Z_from_prob(x=20, prob=0.8, discrete=False) >>> print(t, life.Z_to_t(Z))
- Z_to_prob(x: int, Z: float) float [source]
Probability that continuous WL insurance PV r.v. is no more than Z
- Parameters:
x – age initially insured
Z – present value of benefit paid
Examples
>>> Z = life.Z_from_prob(x=20, prob=0.8, discrete=False) >>> print(life.Z_to_prob(x=20, Z=Z))
- Z_plot(x: int, s: int = 0, stop: int = 0, benefit: ~typing.Callable = <function Insurance.<lambda>>, T: float | None = None, discrete: bool = True, ax: ~typing.Any = None, dual: bool = False, title: str | None = None, color: str = 'r', alpha: float = 0.3) float | None [source]
Plot of PV of insurance r.v. Z vs t
- Parameters:
x – age of selection
s – years after selection
stop – time to end plot
benefit – benefit as a function of age and time
T – specific time to annotate
insurance (discrete discrete or continuous) –
ax – figure object to plot in
dual – whether to plot survival function on secondary axis
color – color of primary plot
alpha – transparency of plot area
title – title of plot