life
Life Contingent Risks - Applies probability laws
MIT License. Copyright (c) 2022-2023 Terence Lim
- class actuarialmath.life.Life(**kwargs)[source]
Bases:
Actuarial
Compute moments and probabilities
- set_interest(**interest) Life [source]
Set interest rate, which can be given in any form
- Parameters:
i – assumed annual interest rate
d – or assumed discount rate
v – or assumed discount factor
delta – or assumed contiuously compounded interest rate
v_t – or assumed discount rate as a function of time
i_m – or assumed monthly interest rate
d_m – or assumed monthly discount rate
m – m’thly frequency, if i_m or d_m are given
- static variance(a, b, var_a, var_b, cov_ab: float) float [source]
Variance of weighted sum of two r.v.
- Parameters:
a – weight on first r.v.
b – weight on other r.v.
var_a – variance of first r.v.
var_b – variance of other r.v.
cov_ab – covariance of the r.v.’s
- static covariance(a, b, ab: float) float [source]
Covariance of two r.v.
- Parameters:
a – expected value of first r.v.
b – expected value of other r.v.
ab – expected value of product of the two r.v.
- static bernoulli(p, a: float = 1, b: float = 0, variance: bool = False) float [source]
Mean or variance of bernoulli r.v. with values {a, b}
- Parameters:
p – probability of first value
a – first value
b – other value
variance – whether to return variance (True) or mean (False)
- static binomial(p: float, N: int, variance: bool = False) float [source]
Mean or variance of binomial r.v.
- Parameters:
p – probability of occurence
N – number of trials
variance – whether to return variance (True) or mean (False)
- static mixture(p, p1, p2: float, N: int = 1, variance: bool = False) float [source]
Mean or variance of binomial mixture
- Parameters:
p – probability of selecting first r.v.
p1 – probability of occurrence if first r.v.
p2 – probability of occurrence if other r.v.
N – number of trials
variance – whether to return variance (True) or mean (False)
Examples
>>> p1 = (1. - 0.02) * (1. - 0.01) # 2_p_x if vaccine given >>> p2 = (1. - 0.02) * (1. - 0.02) # 2_p_x if vaccine not given >>> math.sqrt(Life.mixture(p=.2, p1=p1, p2=p2, N=100000, variance=True))
- static conditional_variance(p, p1, p2: float, N: int = 1) float [source]
Conditional variance formula for mixture of binomials
- Parameters:
p – probability of selecting first r.v.
p1 – probability of occurence for first r.v.
p2 – probability of occurence for other r.v.
N – number of trials
Examples
>>> p1 = (1. - 0.02) * (1. - 0.01) # 2_p_x if vaccine given >>> p2 = (1. - 0.02) * (1. - 0.02) # 2_p_x if vaccine not given >>> math.sqrt(Life.mixture(p=.2, p1=p1, p2=p2, N=100000, variance=True))
- static portfolio_percentile(mean: float, variance: float, prob: float, N: int = 1) float [source]
Probability percentile of the sum of N iid r.v.’s
- Parameters:
mean – mean of each independent obsevation
variance – variance of each independent observation
prob – probability threshold
N – number of observations to sum
- static portfolio_cdf(mean: float, variance: float, value: float, N: int = 1) float [source]
Probability distribution of a value in the sum of N iid r.v.
- Parameters:
mean – mean of each independent obsevation
variance – variance of each independent observation
value – value to compute probability distribution in the sum
N – number of observations to sum