# Intro
Want to know how much we should charge now for the future payment. There are two uncertainties:
1. When will it be paid
2. Whether it will be paid
***
## Introduction to life insurance (self-learning)
### Summary
### Background
*Earliest life insurance policy*:
The **policyholder投保人** pay **premium保费** to the **insurer保险公司**. If the named life insured died during the year that the contract was in force, the insurer would pay a predetermined lump sum, the **sum insured**, to the policyholder or his or her estate.

*Life Table*:
It summurizes a **survival model** by specifying the proportion of lives that are expected to survive to each age.
>**e.g.**
>each new life had a probability of 40% of surviving to age 16
>and a probability of 1% of surviving to age 76

### Life insurance and annuity contracts
#### Intro
#### Traditional insurance contracts
##### Term insurance定期寿险
The insurer pays a lump sum benefit on the death of the policyholder, if death occurs before the end of a specified term.

- *Level term insurance定期定额寿险*: a level sum insured and regular, level premiums.
死亡保险金在整个保险期间保持不变。
>**e.g.**
>张三投保了一份保额为10万元的10年期定额定期保单，如果张三在未来10年内死亡，且保单仍然属于有效保单，则保险人将支付保单受益人10万元的死亡保险金。

- *Decreasing term insurance递减定期寿险*: a decreasing sum insured, (usually) as well as the premiums.
保险金缴纳金额随着年份的增大而减少，死亡保险金也不断减少。

    话说递增的去哪里了

- *Renewable term insurance可续保定期寿险*: without further evidence of the policyholder’s health status, an option to renew the policy at the end of the original term.
一个term结束之后可以重新开始一个一样的。

- *Convertible term insurance可转换定期寿险*: without further evidence of the policyholder’s health status, an option to convert to a whole life or endowment insurance at the end of the original term.
一个term结束之后可以换成终身寿险。

##### Whole life insurance终身寿险
The insurer pays a lump sum benefit on the death of the policyholder whenever it occurs.
>**Note**
>Regularly, the premium is payable up to some maximum age, such as 80, in case that the older lives may be less able to pay the premiums.

##### Endowment insurance定期人寿保险
The insurer pays a lump sum benefit either on the death of the policyholder or at the end of a specified term, whichever occurs first.

#### Modern insurance contracts
- *Universal life insurance万能险*: investment + life insurance.
  1. The policyholder determines the premium and the level of life insurance cover.
  2. The premium is used to fund the life insurance and the rest is paid into an investment fund.
  3. The premium is flexible but at least to cover the designated sum insured.

- *Unitized with-profit*:
  1. Premiums are used to purchase units (shares) of an investment fund, called the **with-profit fund**.
  2. The fund earns investment return, and the shares increase in value.

- *Equity-linked insurance权益连结保险，投资连结保险*: benefit linked to the performance of an investment fund.
  - Form A: the premiums are invested in an open-ended investment company style account.
    1. At maturity, the benefit is the accumulated value of the premiums.
    2. If the policyholder dies before the contract matures, there is a minimum death benefit.
    3. Other cases, there is a minimum maturity benefit.
  - Form B: *Equity-Indexed Annuity* (EIA): with guaranteed minimum return on the premium.
    1. At maturity, the policyholder receives a proportion of the return on a specified stock index, if that is greater than the guaranteed minimum return.
    2. But at least the guaranteed amount.

#### Distribution methods
**Broker保险代理人**, are often remunerated through a commission system, and the commission is a percentage of the premium paid. Normally they get more on the first premium, referred as a **front-end load**.
卖多少，拿提成。

Another way is **direct marketing**, that insurers sell via telemarketing method (TV...) directly to the public.
电视卖保险。

Another insurance is **loan or credit insurance**. The insurer covers loan or credit card payments in the event of the borrower’s death, disability or unemployment.
我炸了你就替我还债。

#### Underwriting
**Premium rates**: how much we charge, depending on the size of the policy and **rating factors**, which are assessed by **proposal form投保单**, generally including age, gender, smoking habits, occupation, any dangerous hobbies, and personal and family health history.

Then to evaluate this infomation, is underwriting. Purpose:
- classify potential policyholders
- assess additional premium

Categories
- preferred lives
- normal lives
- rated lives: with one or more risk factors, additional premium may be charged.
- uninsurable lives: the insurer will not enter an insurance contract at any price.

#### Premiums
1. One single premium, at the outset of the contract
2. A regular series of premium if the policyholder survives, may go with a end date.

**An important feature**:
All premiums is paid at the *START* of each period.

>**e.g.**
>A policyholder contracts to pay annual premiums for a 10-year insurance contract. The premiums will be paid at the start of the contract, and then at the start of each subsequent year provided the policyholder is alive. Thus he should pay at $t=0,1, \dots 9$.

#### Life annuities终身年金
when an annuity depends on the survival of the recipient, **annuitant**.
- whole life annuity: annuity continues until the death of the annuitant.
- term life annuity: annuity is paid for some maximum period, provided that the annuitant survives.

- *Single Premium Deferred Annuity* (SPDA)
  1. policyholder pays a single premium for an annuity in a specified future date.
  买保险，之后过几年领钱。
  2. the annuity is paid only if the policyholder survives to the payment dates, **life contingent**.
  不过你得活着才能领。
  3. policyholder dies before the annuity commences, then there's a death benefit.
  没开始领就挂了，补偿一点。
  4. policyholder dies soon after the annuity commences, then there's a guaranteed period, annuity will be paid to its estate.
  领了一会就挂了，后代还能再领几年。

- *Single Premium Immediate Annuity* (SPIA)
Same with SPDA, except that, the annuity commences as soon as the contract is effected.
买保险之后就可以一直领钱。

- *Regular Premium DeferredAnnuity* (RPDA)
Same with SPDA, except that, the premium is paid through the deferred period.
分期买保险。

- *Joint life annuity*
No matter it is single premium or regular premium, immediate or deferred period, it is issued to *TWO* people. It ceases on the first death of the couple.

- *Last survivor annuity*
Same with Joint life annuity but ceases on the second death of the couple.

- *Reversionary annuity*
Still a couple, one as the annuitant, the other as the insured. On the death of the insured life, if the annuitant is still alive, the annuitant receives an annuity for the remainder of his or her life.

### Other insurance contracts
- *Income protection insurance*: Income protection policies replace at least some income during periods of sickness. They usually cease at retirement age.
- *Critical illness insurance*: Critical illness insurance pays a benefit on diagnosis of one of a number of severe conditions. The benefit is usually in the form of a lump sum.
- *Long-term care insurance*: to cover the costs of care in old age, when the insured life is unable to continue living independently. As an annuity benefit, the benefit is in the form of long-term care costs.

### Pension benefits退休金
usually sponsored by an employer

#### Defined benefit and defined contribution pensions
*Defined Benefit* (DB) *pensions*: a defined formula based on service and salary with an employer.
> **e.g.**
> An employee reaches retirement age with $n$ years of service, $i.e.$, the membership of the pension plan, with pensionable salary averaging $S$.
> Then the **final salary** plan offer an annual pension at retirement of $B = Sn\alpha$, where $\alpha$ is called the **accrual rate**, usually around $1\%-2\%$.

The contributions are invested and accumulated. But it must be enough to pay the pensions when they become due.

*Defined Contribution* (DC) *pensions*: more like a bank account. The employee and employer pay a predetermined contribution (usually a fixed percentage of salary) into a fund, and the fund earns interest. When the employee leaves or retires, the proceeds are available to provide income throughout retirement.

#### Defined benefit pension design
*Career average salary* plans: with benefit formula same with the final salary formula above, except that the average salary over the employee’s entire career is used in place of the final salary.

*Withdrawal benefit*: if employees leave their jobs before retirement, a pension based on the same formula as the age retirement benefit, but with the start date deferred until the employee reaches the normal retirement age.

*death-in-service benefit*: if employees die during the employment, a lump sum might be paid, often based on salary or service.

### Mutual and proprietary insurers
*Mutual insurance company*: one that has no shareholders. The insurer is owned by the with-profit policyholders. All profits are distributed to the with-profit policyholders through dividends or bonuses.

*proprietary insurance company*: with shareholders and usually with-profit policyholders. Participating policyholders are not owners, but have a specified right to some of the profits. Thus, the profits must be shared in some predetermined proportion, between the shareholders and the with-profit policyholders.

### Typical problems

---
# Survival Models
## Summary
## The future lifetime random variable
$Def$
*Future Life Time*: time elapsed from now to death

$Def$
*Life Insurance*: A policy that pays benefit upon death of the insured, initiated when bought.

$Def$
*Pure Endowment*: A policy that pays benefit at certain date if the insured is ALIVE on that date.

$\dagger$
现实中Pure Endowment不多

$Def$
*Endowment Insurance* (Endowment): A policy that pays benefit upon death of the insured or at the end of a specified term, whichever occurs first.

$Def$
*Life Annuities*: Anniuty whose payments are contingent on the annuitant being alive on payment date.
***
$Def$
For $x \geq 0$, life aged $x$ is denoted as $(x)$, individual who is insured. And $T_x$ is for that currently aged $x$ life, its *future life time **continuous** **random** variable*, with cumulative distribution function (cdf) $F_x(t)$ and probability density function (pdf) $f_x(t)$.

$\odot$
$T_x \geq 0$, and $T_x$ is a continuous variable.$\square$

$Def$
*Survival Function*: $S_x (t) = 1 - F_x (t)= \mathrm{Pr} [T_x > t]$

$\odot$
$\{T_x\}_{x \geq 0}$ is an infinite collection of $r.v.$.$\square$

$Assumption$
In order to finder the inner relationship between $\{T_x\}_{x \geq 0}$, we want they all are related to $T_0$, which is the future life time for a newborn. Thus:

$$\boxed{ \mathrm{Pr}[ T_x \leq t ] = \mathrm{Pr} [ T_0 \leq x + t \mid T_0 > x ]}$$

$\dagger$
Condition $T_0 > x$ is necessary! Or $T_x$ would not even exist.

$Conclusion$
From the fomula of conditional probability:

$$\mathrm{Pr}[A \mid  B] = \frac{\mathrm{Pr}[A\cup B]} {\mathrm{Pr}[B]},$$

thus from this very basic assumption:

$$\mathrm{Pr}[T_x \leq t] = \frac{ \mathrm{Pr} [x < T_0 \leq x+t]} {\mathrm{Pr} [T_0 > x]} \Rightarrow F_x(t) = \frac {F_0 (x+t) - F_0 (t)} {1-F_0(x)} \Rightarrow 1 - S_x (t) = \frac {S_0(x) - S_0(x+t)} {S_0(x)} \\ \Rightarrow \boxed { S_x(t) = \frac {S_0(x+t)} {S_0(x)}}$$

$Conclusion$
**Factorization property**:
$$S_x(t+d) = \frac{S_0(x+t+d)} {S_0(x)} = \frac{S_0(x+t)} {S_0(x)} \cdot \frac{S_0(x+t+d)} {S_0(x+t)} = S_x(t) \cdot S_{x+t}(d)$$

$i.e.,$

$$\boxed { S_x(t+d) = S_x(t) \cdot S_{x+t}(d)}$$

$\dagger$
上面的性质就$S_x(t)$有，$F_x(t)$啥的都没有这种性质。

$Conclusion$
Any survival func must satisfy the following:
1. $S_x(0) = 1$, the probability that a life currently aged $x$ survives $0$ years is $1$.
2. $\lim_{t \to \infty} S_x(t) = 0$, all lives eventually die.
3. The survival function must be a *non-increasing* function of $t$.

$\dagger$
可以从Conclusion中得到证明。

$Assumption$
Other assumptions needed:
1. $S_x(t)$ is differentiable for all $t >0$.
2. Sometimes, $\displaystyle \lim_{t \to \infty} tS_x(t) = 0$
3. Sometimes, $\displaystyle \lim_{t \to \infty} t^2S_x(t) = 0$

$\odot$
1. Assumption1 and conclusion 3, we can see that $\frac{\mathrm{d} }{\mathrm{d} t} S_x(t) \leq 0$ for all $t >0$.
2. Assumption2 and 3 is used to make sure that mean and variance exist.$\square$

>**e.g.**:
>$$F_0(t) = \left\{\begin{matrix}
1-(1-\frac{t}{120})^{\frac{1}{6}} & 0 \leq t \leq 120\\
1 & t>120
\end{matrix}\right.$$
> **(a)** $(0)$ survives beyond age 20
>> (a) $S_0(20)$

> **(b)** $(20)$ dies before age 35
>> (b) $F_{20}(15)= 1-S_{20}(15) = \displaystyle 1-\frac{S_{0}(35)} {S_{0}(20)}$

> **(c)** $(30)$ survives beyond age 50
>> (c) $S_{30}(20)=\displaystyle \frac{S_{0}(50)}{S_{0}(30)}$

$\dagger$
Write the $S_x(t)$ *FIRST* then do the calculation

## Force of Mortality
$Conclusion$
$f_x(t) = \frac{\mathrm{d} }{\mathrm{d} t} F_x(t)$, specifically for a newborn:
$$\begin{align}
f_0(t) &= \lim_{\mathrm{d}t \to 0^+} \frac{F_0(t+\mathrm{d}t) - F_0(t)}{\mathrm{d}t}\\
&=\lim_{\mathrm{d}t \to 0^+} \frac{\mathrm{Pr}[t\leq T_0 \leq t+\mathrm{d}t]}{\mathrm{d}t}
\end{align}$$

$Def$
**Force of Mortality**:
$$\begin{align*}
\mu_{x} &= \lim_{\mathrm{d}t \to 0^{+}} \frac {\mathrm{Pr} [ T_0 \leq x + \mathrm{d}t \mid T_0 > x ]} {\mathrm{d}t} \\
&= \lim_{\mathrm{d}t \to 0^{+}} \frac {\mathrm{Pr} [ T_x \leq \mathrm{d}t ]} {\mathrm{d}t} \\
&= \lim_{\mathrm{d}t \to 0^{+}} \frac {F_{x} (\mathrm{d}t)} {\mathrm{d}t} \\
&= \lim_{\, \mathrm{d} x \to 0^{+}} \frac {1 - S_{x} ( \mathrm{d} x)} {\, \mathrm{d} x} \\
\end{align*}$$

Since $S_0 (x + \mathrm{d} x) = S_{0} (x) \cdot S_{x} ( \mathrm{d} x)$,

$$\begin{align*}
\mu_{x} &= \lim_{\, \mathrm{d} x \to 0^{+}} \frac {S_{0} (x) - S_0 (x + \mathrm{d} x)} {S_{0} (x) \cdot \, \mathrm{d} x} \\
&= \frac {-1} {S_{0} (x)} \cdot \frac{\mathrm{d} }{\, \mathrm{d} x} S_{0} (x) \\
&= \boxed{ - \frac {\frac{\mathrm{d} }{\, \mathrm{d} x} S_{0} (x)} {S_{0} (x)} = \frac {\frac{\mathrm{d} }{\, \mathrm{d} x} F_{0}(x)} {S_{0} (x)} = \frac {f_{0} (x)} {S_{0} (x)} }\\
&= \boxed{ - \frac{\mathrm{d} }{\, \mathrm{d} x} \log S_{0} (x) }
\end{align*}$$

$\dagger$
那里可以把分式提出极限号出来是因为我们是对$\, \mathrm{d} x$求的极限，不是$x$。
这里的求导也不是正常的求导，而是右导数就好了。

$Conclusion$
Now we fix $x$ at $x^{*}$ and see what's $\mu_{x^{*} + t}$
$$\begin{align*}
\mu_{x^{*} + t} &=  \frac {-1} {S_{0} (x^{*} + t)} \cdot \frac{\mathrm{d} }{\mathrm{d} \left( x^{*} + t \right)} S_{0} (x^{*} + t) \\
&= \frac {-1} {S_{0} (x^{*} + t)} \cdot \frac{\mathrm{d} }{\mathrm{d} t} \left( S_{0} (x^{*}) \cdot S_{x^{*}} (t) \right) \\
&= - \frac{S_{0} (x^{*})} {S_{0} (x^{*} + t)} \cdot \frac{\mathrm{d} }{\mathrm{d} t} S_{x^{*}} (t) \\
&= \frac {-1} {S_{x^{*}} (t)} \cdot \frac{\mathrm{d} }{\mathrm{d} t} S_{x^{*}} (t) \\
&= \boxed{ - \frac {\frac{\mathrm{d} }{\mathrm{d} t} S_{x^{*}} (t)} {S_{x^{*}} (t)} = \frac {\frac{\mathrm{d} }{\mathrm{d} t} F_{x^{*}}(t)} {S_{x^{*}} (t)} = \frac {f_{x^{*}} (t)} {S_{x^{*}} (t)} } \\
&= \boxed{ - \frac{\mathrm{d} }{\mathrm{d} t} \log S_{x^{*}} (t) }
\end{align*}$$

$\dagger$
注意都对什么求的导。$\mu_{x}$那里都是导$x$，而这里的$\mu_{x^{*} + t}$都是导$t$.

$Conclusion$
Now we start from $\mu_{x}$ and see what can we get.

Since $\mu_{x} = - \frac{\mathrm{d} }{\mathrm{d} x} \log S_{0} (x)$,

$$\begin{align*}
\int _{0} ^{y} \mu_{x} \, \mathrm{d} x &= \int _{0} ^{y} - \frac{\mathrm{d} }{\mathrm{d} t} \log S_{0} (x) \,\mathrm{d} x \\
&= -\log S_{0} (x) \mid_{0}^{y} \\
&= -\log S_{0} (y) + \log S_{0} (0)
\end{align*}$$

Remember that $\forall x > 0, S_{x} (0) = 1$ and $\log(1) = 0$, so that:

$$\int _{0} ^{y} \mu_{x} \,\mathrm{d} x = -\log S_{0} (y) \Rightarrow \boxed {S_{0} (y) = e^{-\int_{0}^y \mu_{x} \, \mathrm{d} x}}$$

$\dagger$
For the fomula above, those two zeros may not be changed to others. See another conclusion below.

$Conclusion$
$$\begin{align*}
S_{x^{*}} (t) &= \frac{S_{0}(x^{*} + t)} {S_{0}(x^{*})} \\
&= \frac{e^{-\int_{0}^{x^{*} + t} \mu_{x} \, \mathrm{d} x}} {e^{-\int_{0}^{x^{*}} \mu_{x} \, \mathrm{d} x}} \\
&= e^{-\int_{x^{*}}^{x^{*} + t} \mu_{x} \, \mathrm{d} x}
\end{align*}$$

$i.e.,$

$$\boxed{ S_{x^{*}} (t) = \exp \left\{ -\int_{0}^{t} \mu_{x+x^{*}} \, \mathrm{d} x \right\}, or,S_{x} (t) = \exp \left\{ -\int_{0}^{t} \mu_{x+s} \, \mathrm{d} s \right\} }$$

>**e.g.**
> Suppose that $F_{0}(x) = 1-(1-x/120)^{1/6}$, for $0 \leq x \leq 120$. Derive an expression for $\mu_x$.
>
>$Answer$
>
>First we see that $S_{0}(x) = (1-x/120)^{1/6}$, then
>
>$$\frac{\mathrm{d} }{\, \mathrm{d} x}S_{0}\left( x \right )= \frac{1} {6} (1-x/120)^{-5/6}(-\frac{1}{120})$$
>
>and so
>$$\mu_x=\frac{-1} {S_{0}\left( x \right )} \frac{\mathrm{d} }{\, \mathrm{d} x}S_{0}\left( x \right ) = \frac{1} {720}(1-x/120)^{-1} = \frac{1} {720-6x}$$

###  Gompertz’ law of mortality.
Let $\mu_x = Bc^{x}$, here $x > 0$, $B$ and $c$ are constants such that $0 < B < 1$ and $c > 1$. Then,
$$\begin{align*}
S_{x}\left( t \right) &= \exp \left\{ - \int_{x}^{x+t} \mu_r \; \mathrm{d}r \right\} \\
&= \exp \left\{ - \int_{x}^{x+t} Bc^{r} \; \mathrm{d}r \right\} \\
&= \exp \left\{ - \frac{B}{\log c} c^{r} \left| \right. _{x}^{x+t}  \right\} \\
&= \boxed{\exp \left\{ - \frac{B}{\log c} c^{x}\left( c^{t} - 1 \right ) \right\}}
\end{align*}$$

>**e.g.**: Calculate the survival function and probability density function for $T_x$ using *Gompertz’ law of mortality*, with $B = 0.0003$ and $c = 1.07$, for $x = 20$, $x = 50$ and $x = 80$. Plot the results and comment on the features of the graphs.
>$Answer$
>For $x = 20$, the force of mortality is $\mu_{20 + t} = Bc^{20 + t}$, and the survival function is:
>
>$$S_{20} \left( t \right) = \exp \left\{ - \frac{B}{\log c} c^{20}\left( c^{t} - 1 \right ) \right\}$$
>Then the probability density function is:
>
>$$\mu_{20 + t} = \frac{f_{20} \left( t \right)} {S_{20} \left( t \right)} \Rightarrow f_{20} \left( t \right) = \mu_{20 + t} S_{20} \left( t \right) = Bc^{20 + t} \exp \left\{ - \frac{B}{\log c} c^{20}\left( c^{t} - 1 \right ) \right\}$$
>
>|$S_{x}(t)$|$f_{x}(t)$|
|:---------:|:--------:|
|||

## Actuarial notation
IAN: International Actuarial Notaion

### $_{t}p_{x}$
Survival Function for $T_{x}$, the Probability of $\left( x \right)$ survives $t$ years.

$$_{t}p_{x}=\mathrm{Pr} \left[ T_{x} > t \right] = S_{x}\left( t \right )$$

Further, we use $p_{x}$ with default $t=1$;

### $_{t}q_{x}$
$\mathrm{cdf}$ for $T_{x}$, the Probability of $\left( x \right)$ dies within $t$ years.

$$_{t}q_{x}=\mathrm{Pr} \left[ T_{x} \leq t \right] = F_{x}\left( t \right )$$

Further, we use $q_{x}$ with default $t=1$;

### ${_{u \mid t}}q_{x}$
A deferred mortality probability, that $\left( x \right)$ survives $u$ years and dies within $t$ years after that.

$$_{u \mid t}q_{x}=\mathrm{Pr} \left[ u < T_{x} \leq u + t \right] = S_{x}\left( u \right ) - S_{x}\left( u + t \right )$$

Further, we use ${_{u \mid}}q_{x}$ with default $t=1$, and we never use $_{u \mid t}p_{x}$;

$Conclusion$
1. $\boxed{_{t}p_{x} + _{t}q_{x} = 1}$
2. $\boxed{{_{u \mid t}}q_{x} = {_{u}}p_{x} - {_{u + t}}p_{x}}$
3. Factorization Formula:
$$\boxed{{_{t + u}}p_{x} = {_{t}}p_{x} \cdot {_{u}}p_{ x + t }}$$
4. Force of Mortality:
$$\boxed{\mu_{x} = - \frac{\frac{\mathrm{d}}{\, \mathrm{d} x} S_{0}\left( x \right )} {S_{0}\left( x \right )} = - \frac{1}{{_{x}}p_{0}} \cdot \frac{\mathrm{d}}{\, \mathrm{d} x} \left( {_{x}}p_{0} \right )}$$
$$\boxed{\mu_{x + t} = - \frac{\frac{\mathrm{d}}{\mathrm{d} t} S_{x}\left( t \right )} {S_{x}\left( t \right )} = - \frac{1}{{_{t}}p_{x}} \cdot \frac{\mathrm{d}}{\mathrm{d} t} \left( {_{t}}p_{x} \right )} \Rightarrow \boxed{\frac{\mathrm{d}}{\mathrm{d} t} \left( {_{t}}p_{x} \right ) = - {_{t}}p_{x} \cdot \mu_{x + t}}$$
5. $\mathrm{pdf}$
$$\mu_{x + t} = \frac{ \frac{\mathrm{d}}{\mathrm{d} t} \left( {_{t}}q_{x} \right)} {{_{t}}p_{x}} \Rightarrow \boxed{f_{x} \left( t \right) = {_{t}}p_{x} \cdot \mu_{x + t}}$$
6. Survival Function
$$\boxed{ {_{t}}p_{x} = \exp \left \{ - \int _{0} ^{t} \mu_{x+s} \, \mathrm{d}s \right \}}$$
7. $\mathrm{cdf}$
$$F_{x} \left( t \right) = \int _{0} ^{t} f_{x} \left( s \right) \, \mathrm{d}s \Rightarrow \boxed{ {_{t}}q_{x} = \int _{0} ^{t} {_{s}}p_{x} \mu_{ x + s } \, \mathrm{d}s}$$

An explanation on the formula above:
Consider time $s$, where $0 \leq s < t$. The probability that $\left( x \right)$ is alive at time $s$ is ${_{s}}p_{x}$, and the probability that $\left( x \right)$ dies between ages $x + s$ and $x + s + \mathrm{d}s$, having survived to age $x + s$, is (loosely) $\mu_{x + s} \, \mathrm{d}s$, provided that $\mathrm{d}s$ is very small. Thus ${_{s}}p_{x} \cdot \mu_{x + s} \, \mathrm{d}s$ can be interpreted as the probability that $\left( x \right)$ dies between ages $x + s$
and $x + s + \mathrm{d}s$. Now, we can sum over all the possible death intervals $s$ to $s + \mathrm{d}s$, which requires integrating because these are infinitesimal intervals, to obtain the probability of death before age $x + t$, $i.e.$, ${_{t}}q_{x} = F_{x} \left( t \right)$

An special case is when $x =1$, we have:

$${_{t}}q_{x} \!\mid_{t=1} = {_{1}q_{x}} = \boxed{ q_{x} = \int _{0} ^{1} {_{s}}p_{x} \mu_{ x + s } \, \mathrm{d}s}$$

When $q_{x}$ is small, it follows that $p_{x}$ is close to $1$, and hence ${_{s}}p_{x}$ is close to $1$ for $0 \leq s < 1$. Thus

$$\boxed{q_{x}\approx \int_{0}^{1} \mu _{x+s} \, \mathrm{d}s \approx \mu _{x+\frac{1}{2}}}$$

And another special case is that:

$$\boxed{p_{x} = \frac{S_{0} \left( x + 1 \right)} {S_{0} \left( x \right)}}$$

## Mean and standard deviation of $T_x$
$\overset{\circ}{e}_{x} = \mathbb{E}\left[ \,T_{x} \,\right]$, as the **complete expection of life**. Remember we still have $x \geq 0$.

$$
\begin{align*}
\overset{\circ}{e}_{x} &= \int_{-\infty} ^{\infty} t \cdot f_{x} \left( t \right) \, \mathrm{d}t \\
&= \int_{0} ^{\infty} t \cdot {_{t}p_{x}} \cdot \mu_{x + t} \, \mathrm{d}t \\
&= \int_{0} ^{\infty} t \cdot \left( -\frac{\mathrm{d}} {\mathrm{d}t} {_{t}q_{x}} \right) \, \mathrm{d}t \\
&= -\int_{0} ^{\infty} t \,{\mathrm{d} \left( {_{t}q_{x}} \right)} \\
&= -\left( t \cdot {_{t}p_{x}} \! \mid _{0} ^{\infty} -  \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t \right)
\end{align*}
$$

And since we have assumed that $\lim_{t \to \infty}t \cdot {_{t}p_{x}} = 0$, so finally:

$$\boxed{ \overset{\circ}{e}_{x} = \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t \,}$$

Without the assumption before, $\overset{\circ}{e}_{x}$ won't exist. And with similar method and a stronger assumption, $\lim_{t \to \infty}t^2 \! \cdot \! {_{t}p_{x}} = 0$, we can find that:

$$
\begin{align*}
\mathbb{E}\left[ \,T_{x}^{2} \,\right] &= -\left( t^2 \! \cdot \! {_{t}p_{x}} \! \mid _{0} ^{\infty} -  \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t^2 \right) \\
&= - \left( \lim_{t \to \infty} t^2 \! \cdot \! {_{t}p_{x}}  -  \int_{0} ^{\infty} 2t \, {_{t}p_{x}} \, \mathrm{d}t \right) \\
&= \boxed{ \int_{0} ^{\infty} 2t \, {_{t}p_{x}} \, \mathrm{d}t \,}
\end{align*}
$$

>**e.g.**
>
>$\displaystyle F_{0}\left( x \right) = 1 - \left( 1 - \frac{x} {120} \right)^{1/6}$
>
>First with survival function, which is $\displaystyle S_{0}\left( x \right) = 1 - F_{0}\left( x \right) = \left( 1 - \frac{x} {120} \right)^{1/6}$
>
>Then the $\displaystyle S_{x} \left( t \right) = {_{t}p_{x}} = \frac{S_{0}\left( x + t \right)} {S_{0}\left( x \right)} = \left( 1 - \frac{t} {120 - x} \right)^{1/6}$, for $t \in \left[ \, 0, 120-x \right)$.
>
>$\begin{align*}
\overset{\circ}{e}_{x} &= \int_{0} ^{120 - x} \left( 1 - \frac{t} {120 - x} \right)^{1/6} \, \mathrm{d}t \\
&= \left( 120 - x \right) \cdot \frac{6} {7} \left( 1 - \frac{t} {120 - x} \right)^{7/6}
\bigg|_{0}^{120 - x} = \frac{6} {7} \left( 120 - x \right)
\end{align*}$
>
>$\begin{align*}
\mathbb{E}\left[ \,T_{x}^{2} \,\right] &= 2 \int_{0} ^{\infty} t \, {_{t}p_{x}} \, \mathrm{d}t \\
&= 2 \int_{0} ^{120 - x} t \, \left( 1 - \frac{t} {120 - x} \right)^{1/6} \, \mathrm{d}t \\
\end{align*}$

***
>Then we are stuck here!!! One way it to let $\boxed{ u = 1 - \frac{t} {120 - x} \Rightarrow \mathrm{d}u = - \frac{1} {120 - x} \mathrm{d}t }$, and when $t$ goes from $0$ to $120 - x$, $u$ goes from $1$ to $0$. After this we can write:
>
>$\begin{align*}
\mathbb{E}\left[ \,T_{x}^{2} \,\right] &= 2 \int_{1} ^{0} \left( 1 - u \right) \cdot \left( 120 - x \right) \cdot u^{1/6} \cdot - \left( 120 - x \right) \, \mathrm{d}u \\
&= 2 \left( 120 - x \right)^2 \int_{0} ^{1} \left( 1 - u \right) \cdot u^{1/6} \, \mathrm{d}u = 2 \left( 120 - x \right)^2 \left( \frac{6} {7} - \frac{6} {13} \right)
\end{align*}$

## Curtate future lifetime
$Def$
**Curtate future lifetime**: the integer part of future lifetime, denoted as $K_{x} = \left \lfloor T_{x} \right \rfloor$

Then we have:

$$\begin{align*}
\mathrm{Pr} \left[ K_{x} = k \right] &= \mathrm{Pr} \left[ k \leq T_{x} < k+1 \right] \\
&= \boxed{ {_{k \mid 1}}q_{x} = {_{k \mid}}q_{x} } \\
&= {_k}p_{x} - {_{k + 1}}p_{x} \\
&= {_k}p_{x} - {_k}p_{x} \cdot {_1}p_{x + k} \\
&= {_k}p_{x} \left( 1 - p_{x + k} \right) \\
&= {_k}p_{x} \cdot q_{x + k}
\end{align*}$$

$i.e.$,

$$\boxed{\mathrm{Pr} \left[ K_{x} = k \right] = {_k}p_{x} \cdot q_{x + k} = {_k}p_{x} \cdot {_1}q_{x + k}}$$

And its expectation is $e_{x}$, without a halo on the top like $\overset{\circ}{e}_{x}$.

$$\begin{align*}
e_{x} &= \mathbb{E}\left[ \,K_{x} \,\right] \\
&= \sum _{k = 0} ^{\infty} k \cdot \mathrm{Pr} \left[ K_{x} = k \right] \\
&= \sum _{k = 0} ^{\infty} k \cdot \Big( {_k}p_{x} - {_{k + 1}}p_{x} \Big) \\
&= 0 + 1\left( {_1}p_{x} - {_{2}}p_{x} \right) + 2\left( {_2}p_{x} - {_3}p_{x} \right) + 3\left( {_3}p_{x} - {_4}p_{x} \right) + \cdots
\end{align*}$$

$i.e.$,

$$\boxed{ e_{x}= \mathbb{E}\left[ \,K_{x} \,\right] = \sum _{k = \mathbf{1}} ^{\infty} {_k}p_{x}}$$

Similarly we can acquire:

$$\boxed{ \mathbb{E}\left[ \,K_{x}^{2} \,\right] = \sum _{k = \mathbf{1}} ^{\infty} \left( 2k-1 \right) \cdot {_k}p_{x} = 2\left( \sum _{k = \mathbf{1}} ^{\infty} k \cdot {_k}p_{x} \right) - e_{x}}$$

$Compare$
$$\boxed{\overset{\circ}{e}_{x} = \mathbb{E}\left[ \, T_{x} \,\right]= \int_{\mathbf{0}}^{\infty} {_t}p_{x} \, \mathrm{d}t \,}, \boxed{ \mathbb{E}\left[ \, T_{x}^{2} \,\right] = \int_{\mathbf{0}}^{\infty} 2t \cdot {_t}p_{x} \, \mathrm{d}t \,}$$

Finally we will derive the relationship between $\overset{\circ}{e}_{x}$ and ${e}_{x}$

$$\begin{align*}
\overset{\circ}{e}_{x} &= \int_{0}^{\infty} {_t}p_{x} \, \mathrm{d}t \\
&= \sum _{j=0} ^{\infty} \int_{j}^{j+1} {_t}p_{x} \, \mathrm{d}t \\
&\approx \sum _{j=0} ^{\infty} \left( 1 \times {_{j+1}}p_{x} + \frac{1} {2} \times 1 \times \left( {_j}p_{x} - {_{j+1}}p_{x} \right) \right) \\
&= \sum _{j=0} ^{\infty} \left( \frac{1} {2} \left( {_j}p_{x} + {_{j+1}}p_{x} \right) \right) \\
&= \frac{1} {2} + \sum _{j=1} ^{\infty} {_j}p_{x}
\end{align*}$$

$i.e.$,

$$\boxed{\overset{\circ}{e}_{x} = \frac{1} {2} + e_{x}}$$
***

Another expectation, about $n\textrm{-year}$ annual term curtate expectation of life, denoted as $e_{{x:\overline {n|}}}$, which is the expected life year of $(x)$ given the

$Def$

$L_{x} = \min\left( K_{x},n \right)$

$$\begin{align*}
e_{x:\overline {n|}} &= \mathbb{E} \left[ \, \min\left( K_{x},n \right) \, \right] \\
&= \sum _{l=0} ^{n} l \cdot \mathrm{Pr} \left[ L_{x} = l \right] \\
&= \left( \sum _{l=0} ^{n - 1} l \cdot \Big( {_l}p_{x} - {_{l + 1}}p_{x} \Big) \right) + n \cdot {_n}p_{x} \\
&= \boxed{ \sum _{\mathbf{l=1}} ^{n} {_l}p_{x}}
\end{align*}$$

And similarly, $ \boxed{ \overset{\circ}{e}_{x:\overline {n|}} = \mathbb{E}\left[ \, \min\left( T_{x},n \right) \,\right]= \int_{\mathbf{0}}^{n} {_t}p_{x} \, \mathrm{d}t \,}$

# Life tables and selection

## Summary
General polulation, select a part of population, like at specific age, or with same level
Deterministic point of view
## Life Tables
Given a survivol model, with survival probability ${_{t}}p_{x}$, we can construct a **life table** for the model from some initial age $x_0$ to a maximum age $\omega$.

$Def$

$\{l_{x}\}_{x \, \in \,\left[ x_0, \omega \right)}$, a function as follows:  Let $l_{x_{0}}$ be an *arbitrary positive* number, called the **radix**. Then, for $0 \leq t \leq \omega − x_0$, define:

$$l_{x_0 + t} = l_{x_0} \cdot {_{t}}p_{x}$$

Then easily we can see that, for fixed $x^*$, $x_0 \leq x^* \leq x^* + t \leq \omega$

$$\begin{align*}
l_{x^* + t} &= l_{x_0 + \left( x^* + t - x_0 \right)} \\
&= l_{x_0} \cdot {_{x^* + t - x_0}}p_{x_0} \\
&= l_{x_0} \cdot {_{x^* - x_0}}p_{x_0} \cdot {_{t}}p_{x^*} \\
&= l_{x^*} \cdot {_{t}}p_{x^*}
\end{align*}$$

$i.e.$,

$$\boxed{l_{x+t} = l_{x} \cdot {_{t}}p_{x} } \Rightarrow \boxed{{_{t}}p_{x} = \frac{l_{x+t}} {l_{x}}}$$

And actually we can interpret this relationship into another *binomial random variable*, $\mathfrak{L}_t$. That is suppose we have $l_x$ independent lives aged $x$, and each life has a probability ${_{t}}p_{x}$ of surviving to age $x + t$. Then the number of survivors to age $x + t$ is $\mathfrak{L}_t \sim \mathrm{B}\left( l_x, {_{t}}p_{x} \right )$. So that its expectation is:

$$\boxed{\mathbb{E}\left[ \, \mathfrak{L}_t \, \right] = l_x \cdot {_{t}}p_{x} = l_{x+t} }$$

$Conclusion$

$$\boxed{ {_{t}}p_{x} = \frac{l_{x+t}} {l_{x}}, {_{t}}q_{x} = \frac{l_{x} - l_{x+t}} {l_{x}} }$$

$$\begin{align*}
{_{u \mid t}}q_{x} &= {_{u}}p_{x} \cdot {_{t}}q_{x + u} \\
&= \frac{l_{x+u}} {l_{x}} \cdot \left( 1 - {_{t}}p_{x + u} \right) \\
&= \frac{l_{x+u} - l_{x+u+t}} {l_{x}} \\
&\text{or} \\
&= {_{u}}p_{x} - {_{u + t}}p_{x} \\
&= \frac{l_{x + u}} {l_{x}} - \frac{l_{x + u + t}} {l_{x}} \\
&= \frac{l_{x + u} - l_{x + u + t}} {l_{x}}
\end{align*}  \\
\boxed{ {_{u \mid t}}q_{x} = \frac{l_{x + u} - l_{x + u + t}} {l_{x}} }
$$

Then we let $d_{x} = l_{x} - l_{x+1}$, death of life in the next year, and we can get that,

$$\begin{align*}
d_{x} &= l_{x} - l_{x+1} \\
&= l_{x} \cdot \left( 1- \frac{l_{x+1}} {l_{x}} \right) \\
&= \boxed{ l_{x} \cdot \left( 1- p_{x} \right) = l_{x} \cdot q_{x} = l_{x} \cdot {_{1}}q_{x} }
\end{align*} \\
\boxed{ l_{x} = \frac{d_{x}} {{_{1}}q_{x}}, q_{x} = \frac{d_{x}} {l_{x}} }$$

>**e.g.**: Given life table
>
>
| $x$|  $l_x$  |  $d_x$ |
|:--:|:--------:|:-----:|
| 30 | 10000.00 | 34.78 |
| 31 |  9965.22 | 38.10 |
| 32 | 9927.12  | 41.76 |
| 33 | 9885.35  | 45.81 |
| 34 | 9839.55  | 50.26 |
| 35 | 9789.29  | 55.17 |
| 36 | 9734.12  | 60.56 |
| 37 | 9673.56  | 66.49 |
| 38 | 9607.07  | 72.99 |
| 39 | 9534.08  | 80.11 |
>
>$l_{40} = l_{39} - d_{39} = 9453.97$
>
>${_10}p_{30} = \frac{l_{40}} {l_{30}} = 0.94540$
>
>$q_{35} = \frac{d_{35}} {l_{35}} = 0.00564$
>
>${_5}q_{30} = \frac{l_{30} - l_{35}} {l_{30}} = 0.02107$
>
>${_{5\mid}}q_{30} = {_{5\mid1}}q_{30} = \frac{l_{35} - l_{36}} {l_{30}} = \frac{d_{35}} {l_{30}} = 0.00552$

## Fractional age assumptions
Linear interpolation between ages, other skills ...

### Uniform distribution of deaths
$Assumption$
**UDD**, the uniform distribution of deaths, most common one.
1. For integer $x$, and for $0 \leq s < 1$, assume that ${_{s}}q_{x} = s \cdot q_{x} = s \cdot {_{1}}q_{x}$.
  >**e.g.**
  > ${_{1/4}}q_{25} = \frac{1} {4} \cdot q_{25} = \frac{1} {4} \cdot {_{1}}q_{25}$
2. From $K_x = \left \lfloor  T_x \right \rfloor$, we define a new variable by $T_x = K_x + R_x$, and here $R_x$ is the fractional point of $T_x$. And we assume that:  for integer $x$, $R_x \sim \mathrm{U} \left( 0, 1 \right)$ , and $R_x$ is independent of $K_x$.

$Claim$
**UDD1** $\Leftrightarrow$ **UDD2**

$Proof$
($\Rightarrow$) Suppose that for all integer $x \geq 0, x \in \left[ 0 , 1 \right)$, we have ${_{s}}q_{x} = s \cdot q_{x}$.

Then this means, for $0 \leq s < 1$:

$$\begin{align*}
\mathrm{Pr}\left[ R_x \leq s \right] &= \sum_{k = 0}^{\infty} \mathrm{Pr}\left[ R_x \leq s \mathrm{ AND } K_x = k \right] \\
&= \sum_{k = 0}^{\infty} \mathrm{Pr}\left[ k \leq T_x \leq k+s \right] \\
&= \sum_{k = 0}^{\infty} {_{k}}p_{x} \cdot {_{s}}q_{x+k} \\
&\stackrel{\textbf{UDD1}}=  \sum_{k = 0}^{\infty} {_{k}}p_{x} \cdot s \cdot q_{x+k} \\
&= s \sum_{k = 0}^{\infty} {_{k}}p_{x} \cdot q_{x+k} \\
&= s \sum_{k = 0}^{\infty} \mathrm{Pr}\left[ K_x = k \right] \\
&= s \cdot 1 = s
\end{align*}$$

Thus it is uniformly distributed, and now the rest is to prove the independency. Note that
$$\begin{align*}
\mathrm{Pr}\left[ R_x \leq s \mathrm{ AND } K_x = k \right] &= \mathrm{Pr}\left[ k \leq T_x \leq k+s \right]\\
&= {_{k}}p_{x} \cdot {_s}q_{x+k} \\
&\stackrel{\textbf{UDD1}}= {_{k}}p_{x} \cdot s \cdot q_{x+k} \\
&= \mathrm{Pr}\left[ K_x = k \right] \cdot \mathrm{Pr}\left[ R_x \leq s \right]\\
\end{align*}$$

Half done, let's see the opposite direction.

($\Leftarrow$) Suppose $R_x \sim \mathrm{U} \left( 0, 1 \right)$, $R_x$ and $K_x$ are independent. Let $x$  be an integer and for $0 \leq s < 1$, we have

$$\begin{align*}
s \cdot q_{x+k} &= \mathrm{Pr}\left[ T_x \leq s \right]\\
&= \mathrm{Pr}\left[ K_x = 0 \; \textrm{and}\; R_x \leq s \right] \\
&\stackrel{\textbf{UDD2}}= \mathrm{Pr}\left[ K_x = 0 \right] \cdot \mathrm{Pr}\left[ R_x \leq s \right] \\
&= q_{x} \cdot \int_0^s 1 \, \mathrm{d} x = s \cdot q_{x}
\end{align*}$$

All done. We normally will use **UDD** as $\boxed{{_{s}}q_{x} = s \cdot q_{x} }$
***
$Conclusion$

$$\begin{align*}
{_{s}}q_{x}   &= 1 - {_{s}}p_{x} \\
s \cdot q_{x} &= 1 - \frac{l_{x+s}} {l_x} = \frac{l_{x} - l_{x+s}} {l_x} \\
s \cdot \frac{d_x} {l_x} &= \frac{l_{x} - l_{x+s}} {l_x} \\
\end{align*}$$

$i.e.$,

$$\boxed{l_{x+s} = l_{x} - s \cdot d_{x}}$$

>**e.g.** Given $P_{40} = 0.999473$,
>
>$$\begin{align*}
{_{0.4}}q_{40.2}   &= 1 - {_{0.4}}p_{40.2} \\
&= 1- \frac{l_{40.6}} {l_{40.2}} \\
&= 1- \frac{{_{0.6}}p_{40}} {{_{0.2}}p_{40}} \\
&= 1- \frac{1 - {_{0.6}}q_{40}} {1 - {_{0.2}}q_{40}} \\
&\stackrel{\textbf{UDD}}= 1- \frac{1 - {0.6} q_{40}} {1 - {0.2} q_{40}} \\
&= 1- \frac{1 - 0.6 (0.00527)} {1 - 0.2(0.00527)} \\
& \approx 2.108 \times 10^{-4}
\end{align*}$$
>
>Another example is to calculate ${_{1.7}}q_{33.5}$
>
>$$\begin{align*}
{_{1.7}}q_{33.5} &= 1 - {_{1.7}}p_{33.5} \\
&= 1 - \frac{l_{35.2}} {l_{33.5}} \\
&= 1 - \frac{l_{35} - 0.2 d_{35}} {l_{33} - 0.5 d_{33}}
\end{align*}$$
>
>Using the life table, we can find the final answer, another way is like when we calculate ${_{1.7}}q_{33}$
>
>${_{1.7}}q_{33} = 1 - {_{1.7}}p_{33} = 1 - p_{33} \cdot {_{0.7}}p_{34} = 1 - \displaystyle \frac{l_{34}} {l_{33}} (1 - 0.7 \times q_{34})$
but what if there's no such table, we can then do like above.
>
>

$Conclusion$
We can also differentiate $\boxed{{_{s}}q_{x} = s \cdot q_{x} }$ with $s$ on both side, easily we can get:

$$\frac{ \mathrm{d}} {\mathrm{d}s} {_s}q_x = q_x,\; 0 \leq s \leq 1$$

Left-hand side is the derivative of culmulative density function, so we finally can see that:

$$\boxed{ q_{x} = f_{x} \left( s \right) = {_s}p_x \cdot \mu_{x+s} }, 0 \leq s < 1$$

$\odot$
And this also demonstrate that density function is a constant, $i.e.$, the variable $R_x$ is uniformly distributed.$\square$

>**e.g.**
>
>So we have $\mu_{x + t} = \displaystyle \frac{q_x} {{_{t}}p_{x}}$, then $\displaystyle \lim_{t \to 1^-} \mu_{40 + t} = \frac{q_{40}} {p_{40}}$ and $\displaystyle \lim_{t \to 0^+} \mu_{41 + t} = q_{41}$

### Constant Force of Mortality (CFM)
Assume that the force of mortality $\mu_x$ is constant between integer ages. Thus for integer $x \geq 0$ and $0 \leq s < 1$, we have $\mu_{x+s} = \mu_x ^*$, a **CONSTANT**.Then how to get that?

From the fact that ${_{t}}p_{x} = \displaystyle \exp{ \left\{ -\int_{0} ^{t} \mu_{x+s} \mathrm{d}s \right\}}$, we can see that

$$\begin{align}
p_x &= \exp{ \left\{ -\int_{0} ^{1} \mu_{x+s} \mathrm{d}s \right\}} \\
&\stackrel{\mathbf{CFM}}{=} \exp{ \left\{ -\int_{0} ^{1} \mu_{x}^* \mathrm{d}s \right\}} \\
&= e^{-\mu_{x}^*}
\end{align} \Rightarrow \mu_{x}^* = - \log p_x $$

Then we have

$$\begin{align}
{_{s}}p_{x} &= \exp{ \left\{ -\int_{0} ^{s} \mu_{x}^* \mathrm{d}s \right\}} \\
&= e^{-\mu_{x}^* \cdot s} = (p_x)^s
\end{align}$$

And similarly for $\boxed{t, s > 0, t + s \leq 1}$, we get a general formula

$$\boxed{{_{s}}p_{x+t} = (p_{x})^s}$$

>**e.g.**: Given $p_{40} = 0.999473$, calculate ${_{0.4}}q_{40.2}$ under the CFM.
>
>${_{0.4}}q_{40.2} = 1- {_{0.4}}p_{40.2} = 1 - (p_{40})^{0.2} = 2.108 \times 10^{-4}$
>
>**e.g.**: Given $q_{70} = 0.010413, q_{71} = 0.011670$, calculate ${_{0.7}}q_{70.6}$ under the CFM.
>
> Here since the time range include an integer value so that we have to calculate separately, and DO NOT forget the conditional probability in the later part because you've already survived the former part!
>
>And we have to do that because of the blockhead CFM **only apply to those inside one integer age interval***!*!*!*!
>
>$$\begin{align*}
{_{0.7}}q_{70.6} =& \text{die before the next integer} \\ &+ \text{survive the next} \cdot \text{die between the next and the last one} \\ &+ \text{survive until the last integer} \cdot \text{die after the last one} \\
=& {_{0.4}}q_{70.6} + (1 - {_{0.7}}q_{70.6}) {_{0.3}}q_{71} \\
=& ( 1 - (p_{70})^{0.4}) + (1 - {_{0.7}}q_{70.6})( 1 - (p_{71})^{0.3})
\end{align*}$$

Why the difference using two different assumption is always very small?

$\dagger$
Because when $\mu^*t$ is small and $0 < t < 1$, we have ${_{t}}q_x \stackrel{\mathbf{CFM}}= 1 - e^{-\mu^*t} \approx \mu^*t \stackrel{\mathbf{CFM}}= t(-\log p_{x}) \approx t(1 - p_{x}) = t \cdot q_{x}$, which means **CFM** and **UDD** are close under such conditions.

## National life tables
## Survival models for life insurance policyholders
## Life insurance underwriting
## Select and ultimate survival models
This section defines **select survival model**, when
1. Future survival probabilities for an individual in the group depend on the individual’s current age and on the age at which the individual joined the group.
2. There is a positive number (generally an integer), which we denote by $d$, such that if an individual joined the group more than $d$ years ago, future survival probabilities depend only on current age.The initial selection effect is assumed to have worn off after $d$ years.

An individual who enters the group at age $x$, is said to be selected at age $x$; the period $d$ after which the age at selection has no effect on future survival probabilities is called the **select period** for the model; the *mortality* that applies to lives after the select period is complete is called the **ultimate mortality**.

But actually you only need to multiply a probability belongs to the group of people with same features.

>**e.g.**: Consider men who need to undergo surgery and there is a probability of only $50\%$ that they will survive for **a year** (meaning *select period* is $1$) following surgery.
>
> 1. the probability that a man aged $60$ who is just about to have surgery (meaning selected at $x = 60$) will be alive at age $70$, would be
$$0.5 \times \frac{l_{70}} {l_{\mathbf{61}}}$$
2. the probability that a man aged $60$ who had surgery at age $59$ (meaning selected at $x = 59$) will be alive at age $70$ would be
$$\frac{l_{70}} {l_{\mathbf{60}}}$$

## Notation and formulae for select survival models
$Def$
$S_{[ x ]+ s} ( t ) = \mathrm{Pr}[\text{a life aged } (x + s) \text{ selected at age } x \text{ survives to age } (x + s + t)]$

$Def$
${_{t}}q_{[ x ]+ s} = \mathrm{Pr}[\text{ a life aged } (x + s) \text{ selected at age } x \text{ dies before age } (x + s + t)]$

$Def$
$\mu_{[ x ]+ s}$ is the force of mortality at age $x + s$ for an individual who was select at age $x$

And with these we can acquire the following

$${_{t}}p_{[ x ]+ s} = 1 - {_{t}}q_{[ x ]+ s} \equiv S_{[ x ]+ s} ( t ) \\
+ \\
\mu_{[ x ]+ s} = \lim_{h \to 0^+} \left( \frac{ 1 - S_{[ x ]+ s} ( h )} {h} \right) \\
\Downarrow \\
\boxed{ {_{t}}p_{[ x ]+ s} = \exp \left\{ - \int _{0} ^{t} \mu_{[ x ]+ s + u} \, \mathrm{d}u \right\}}
$$

## Select life tables
Construct select life table for a select survival model for ages at selection from $x_0 \geq 0$. Let $d$ denote the select period, assumed to be an integer number of years.

Let $l_{x_0 + d}$ be an arbitrary positive number. For $y \geq x_0 + d$ since the life was select at least $d$ years ago, the probability of future survival depends only on the current age, ${x_0 + d}$. Then we define:

$$l_y = {_{(y - x_0 -d)}}p_{x_0 + d}l_{x_0 + d}$$

Then for $y > x \geq x_0 + d$, we can define like

$$l_y = {_{(y-x)}}p_{x} l_x$$

The reason is

$$\begin{align*}
l_y &= ({_{(y - x_0 - d)}}p_{x_0 + d}) l_{x_0 + d} \\
&= ({_{(y - x)}}p_{[x_0] + x - x_0})({_{(x - x_0 -d)}}p_{[x_0] + d}) l_{x_0 + d} \\
&= ({_{(y - x)}}p_{x})({_{(x - x_0 -d)}}p_{x_0 + d}) l_{x_0 + d} \\
&= {_{(y - x)}}p_{x}l_x
\end{align*}$$

And at last we define for $x \geq x_0, 0 \leq t \leq d$:

$$l_{[x] + t} = \frac{l_{x + d}} {{_{(d - t)}}p_{[x] + t}}$$

$\dagger$
Similar to **CFM**, you need a break at the end of *selected period*, no matter the time reaches that or not. If exceed, then tear that apart, if not exceed, then use the inverse version with a division from the end of the period.

>**e.g.** for  $y \geq x + d > x + s > x + t \geq x \geq x_0$, show that
>
>$$\begin{align*}
{_{(y − x − t)}}p_{[ x ]+ t} &= {_{(d − t)}}p_{[ x ]+ t} \cdot {_{(y - x - d)}}p_{\mathbf{[x]}+ d} \\
&= {_{(d − t)}}p_{[ x ]+ t} \cdot {_{(y - x - d)}}p_{\mathbf{x} + d} \\
&= \frac{l_{x+d}} {l_{[ x ]+ t}} \cdot \frac{l_y} {l_{x+d}} = \frac{l_y} {l_{[ x ]+ t}}
\end{align*}$$
>
>And we also have a no-exceed one (using the inverse formula)
>
>$$\begin{align*}
{_{(s − t)}}p_{[ x ]+ t} &= \frac{{_{(d − t)}}p_{[ x ]+ t}} {{_{(d - s)}}p_{[ x ]+ s}} \\
&= \frac{l_{x + d}} {l_{[ x ]+ t}} \cdot \frac{l_{[ x ]+ s}} {l_{x + d}} = \frac{l_{[ x ]+ s}} {l_{[ x ]+ t}}
\end{align*}$$
>
>more complex one, ${_{2 | 6}}q_{[ 30 ]+ 2 }$
>
>$$\begin{align*}
{_{2 | 6}}q_{[ 30 ]+ 2 } &= \mathrm{Pr}[\text{a life aged }32 \text{, who was select at age }30 \text{, will survive to age 34}] \times \mathrm{Pr}[\text{a life aged }34 \text{, who was select at age }30 \text{, will die before age 40}] \\
&= {_{2}}q_{[ 30 ]+ 2 } \cdot {_{6}}q_{[ 30 ]+ 4 } \\
&= \frac{l_{[ 30 ]+ 4 }} {l_{[ 30 ]+ 2 }} \left( 1 - \frac{l_{[ 30 ]+ 10}} {l_{[ 30 ]+ 4 }} \right) = \frac{l_{[ 30 ]+ 4 } - l_{40}} {l_{[ 30 ]+ 2 }}
\end{align*}$$
>
>$\dagger$
>Note that $l_{[ 30 ]+ 10} \equiv l_{40}$ since $10$ years is longer than the select period for this survival model.

***

>**e.g.** Example 3.12 Selected period of $2$ years
>
>| Age<br/> $x$ | Duration $0$ <br/> $q_{[x]}$ | Duration $1$ <br/> $q_{[x-1]+1}$ | Duration $2+$ <br/> $q_{x}$ |
|:------------:|:----------------------------:|:--------------------------------:|:---------------------------:|
|     $60$     |          $0.003469$          |            $0.004539$            |          $0.004760$         |
|     $61$     |          $0.003856$          |            $0.005059$            |          $0.005351$         |
|     $62$     |          $0.004291$          |            $0.005644$            |          $0.006021$         |
|     $63$     |          $0.004779$          |            $0.006304$            |          $0.006781$         |
|    $\dots$   |            $\dots$           |              $\dots$             |           $\dots$           |
|     $70$     |          $0.010519$          |            $0.014068$            |          $0.015786$         |
|     $71$     |          $0.011858$          |            $0.015868$            |          $0.017832$         |
|     $72$     |          $0.013401$          |            $0.017931$            |          $0.020145$         |
|     $73$     |          $0.015184$          |            $0.020302$            |          $0.022759$         |
|     $74$     |          $0.017253$          |            $0.023034$            |          $0.025712$         |
|     $75$     |          $0.019664$          |            $0.026196$            |          $0.029048$         |
>
>$(\text{a})$ ${_{4}}p_{[70]}$
>
>$$\begin{align}
{_{4}}p_{[70]} &= p_{[70]} \cdot p_{[70]+1} \cdot p_{[70]+2} \cdot p_{[70]+3} \\
&= p_{[70]} \cdot p_{[70]+1} \cdot p_{72} \cdot p_{73} \\
&= (1-q_{[70]})(1-q_{[70]+1})(1-q_{72})(1-q_{73})
\end{align}$$
>
>$(\text{b})$ ${_{3}}q_{[60]+1}$
>
>$$\begin{align}
{_{3}}q_{[60]+1} &= 1 - {_{3}}p_{[60]+1} \\
&= 1 - {_{1}}p_{[60]+1} \cdot {_{2}}p_{62} \\
&= 1 - (1 - {_{1}}q_{[60]+1}) (1 - {_{1}}q_{62}) (1 - {_{1}}q_{63})
\end{align}$$

***
***

>**e.g.** Exercise 3.2, given the life table and find some values.
>
>| Age, $x$ |   $52$  |   $53$  |   $54$  |   $55$  |   $56$  |   $57$  |   $58$  |   $59$  |   $60$  |
|:--------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|:-------:|
|   $l_x$  | $89948$ | $89089$ | $88176$ | $87208$ | $86181$ | $85093$ | $83940$ | $82719$ | $81429$ |
>
>$(\text{a})$ ${_{0.2}}q_{52.4}$ under **UDD**.
>
>$$\begin{align}
{_{0.2}}q_{52.4} &= 1 - {_{0.2}}p_{52.4} \\
&= 1 - \frac{l_{52.6}} {l_{52.4}} \\
&= 1 - \frac{l_{52} - 0.6 \cdot d_{52}} {l_{52} - 0.4 \cdot d_{52}} \\
&= 1 - \frac{89948 - 0.6 \left( 89948 - 89089 \right)} {89948 - 0.4 \left( 89948 - 89089 \right)} \;= 0.0019173165603473263
\end{align}$$
>
>$(\text{b})$ ${_{0.2}}q_{52.4}$ under **CFM**.
>
>$$\begin{align}
{_{0.2}}q_{52.4} &= 1 - {_{0.2}}p_{52.4} \\
&= 1 - \left( p_{52} \right)^{0.2} \\
&= 1 - \left( \frac{l_{53}} {l_{52}} \right)^{0.2} \\
&= 1 - \left( \frac{89089} {89948} \right)^{0.2} = 0.0019173306705693172
\end{align}$$
>
>$(\text{c})$ ${_{5.7}}p_{52.4}$ under **UDD**.
>
>$$\begin{align}
{_{5.7}}p_{52.4} &= \frac{l_{58.1}} {l_{52.4}} \\
&= \frac{l_{58} - 0.1 \cdot d_{58}} {l_{52} - 0.4 \cdot d_{52}} \\
&= \frac{83940 - 0.1\left( 83940 - 82719 \right)} {89948 - 0.4 \left( 89948 - 89089 \right)} \;= 0.935421698041614
\end{align}$$
>
>$(\text{d})$ ${_{5.7}}p_{52.4}$ under **CFM**.
>
>$\begin{align}
{_{5.7}}p_{52.4} &= 1 - {_{5.7}}q_{52.4} \\
&= 1 - \Big( {_{0.6}}q_{52.4} + \big(1 - {_{0.6}}q_{52.4}\big){_{5}}q_{53} + \big(1 - {_{0.6}}q_{52.4}\big) \big(1 - {_{5}}q_{53}\big) \cdot {_{0.1}}q_{58} \Big) \\
&= 1 - \Bigg( \! \bigg[ 1 - \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6}\bigg] + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{53} - l_{58}} {l_{53}} + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{58}} {l_{53}} \bigg[ 1 - \Big( \frac{l_{59}} {l_{58}} \Big)^{0.1}\bigg] \! \Bigg) \\
&= 0.9354230247854776
\end{align}$
>
>$(\text{e})$ ${_{3.2 \mid 2.5}}\,q_{52.4}$ under **UDD**.
>
>$$\begin{align}
{_{3.2 \mid 2.5}}\,q_{52.4} &= {_{3.2}}p_{52.4} -  {_{5.7}}p_{52.4} \\
&= \frac{l_{55.6}} {l_{52.4}} - \frac{l_{58.1}} {l_{52.4}} \\
&= \frac{\left(l_{55} - 0.6 \cdot d_{55}\right) - \left(l_{58} - 0.1 \cdot d_{58}\right)} {l_{52} - 0.4 \cdot d_{52}} \\
&= 0.03095718513822992
\end{align}$$
>$(\text{f})$ ${_{3.2 \mid 2.5}}\,q_{52.4}$ under **CFM**.
>
>$\begin{align}
{_{3.2 \mid 2.5}}\,q_{52.4} =&\, {_{3.2}}p_{52.4} - {_{5.7}}p_{52.4} \\
=& \, {_{5.7}}q_{52.4} - {_{3.2}}q_{52.4} \\
=&\, \Big( {_{0.6}}q_{52.4} + \big(1 - {_{0.6}}q_{52.4}\big){_{5}}q_{53} + \big(1 - {_{0.6}}q_{52.4}\big) \big(1 - {_{5}}q_{53}\big) \cdot {_{0.1}}q_{58} \Big) \\
&- \Big( {_{0.6}}q_{52.4} + \big(1 - {_{0.6}}q_{52.4}\big){_{2}}q_{53} + \big(1 - {_{0.6}}q_{52.4}\big) \big(1 - {_{2}}q_{53}\big) \cdot {_{0.6}}q_{55} \Big) \\
=&\, \Bigg( \! \bigg[ 1 - \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6}\bigg] + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{53} - l_{58}} {l_{53}} + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{58}} {l_{53}} \bigg[ 1 - \Big( \frac{l_{59}} {l_{58}} \Big)^{0.1}\bigg] \! \Bigg) \\
&- \Bigg( \! \bigg[ 1 - \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6}\bigg] + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{53} - l_{55}} {l_{53}} + \bigg( \frac{l_{53}} {l_{52}} \bigg)^{0.6} \frac{ l_{55}} {l_{53}} \bigg[ 1 - \Big( \frac{l_{56}} {l_{55}} \Big)^{0.6}\bigg] \! \Bigg) \\
=& \, 0.030950242839582684
\end{align}$
>
>And actually you did the problem $(\text{d})$ and $(\text{f})$ a terrible way. Here's a better one
>
>$(\text{d})$
>
>$\begin{align}
{_{5.7}}p_{52.4} &= {_{0.6}}p_{52.4} \cdot {_{5}}p_{53} \cdot {_{0.1}}p_{58}\\
&= \Big( \frac{l_{53}} {l_{52}} \Big)^{0.6} \cdot \frac{ l_{58}} {l_{53}} \cdot \Big( \frac{l_{59}} {l_{58}} \Big)^{0.1} \\
&= 0.9354230247854776
\end{align}$

***
***

<center>**Summary Table**</center>

|                                                                                Probability                                                                                |                                                                                International Actuarial Notation (IAN)                                                                                |                   Meaning                  |                                                                 Note                                                                |
|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------:|
|                                                                                $(x)$                                                                                |                                                                                $(x)$                                                                                |               a Life aged $x$              |                                                              $x \geq 0$                                                             |
|                                                                                $T_x(t)$                                                                                |                                                                                $T_x(t)$                                                                                |               Future Lifetime              |                                                          continuous $r.v.$                                                          |
|                                                                                $F_x(t)$                                                                                |                                                                                ${_{t}\,}q_{x}$                                                                                |      Distribution Function of $T_x(t)$     |                                            the probability of $(x)$ dies within $t$ years                                           |
|                                                                                $S_x(t) = 1 - F_x(t)$                                                                                |                                                                                ${_{t}\,}p_{x} = 1 - {_{t}\,}q_{x}$                                                                                |        Survival Function of $T_x(t)$       |                                             the probability of $(x)$ survives $t$ years                                             |
|                                                                                $\mathrm{Pr} \left[ u < T_{x} \leq u + t \right] = S_{x}(u) - S_{x}(u + t)=F_{x}(u + t) - F_{x}(u)$                                                                                |                                                                                ${_{u \mid t}\;}q_{x}  = {_{u}\,}p_{x} - {_{u + t}\;\,}p_{x}$                                                                                | Deferred Mortality Probability of $T_x(t)$ | the probability of $(x)$ survives $\mathbf{u}$ years and dies within $\mathbf{t}$ years after that; no such ${_{u \mid t}\;\,}p_{x}$. |
|                                                                                $S_x(t+d) = S_x(t) \cdot S_{x+t}\;(d)$                                                                                |                                                                                ${_{t + u}\;\,}p_{x} = {_{t}\,}p_{x} \cdot {_{u}\;}p_{ x + t }$                                                                                |            Factorization Formula           |                                                                                |
***
<center>**After** $\mu_{x}$</center>

|                                                                                Probability                                                                                |                                                                                International Actuarial Notation (IAN)                                                                                |
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|                  $\displaystyle \mu_{x} = - \frac {\frac{\mathrm{d} }{\mathrm{d} x} S_{0} (x)} {S_{0} (x)} = \frac {\frac{\mathrm{d} }{\mathrm{d} x} F_{0}(x)} {S_{0} (x)} = \frac {f_{0} (x)} {S_{0} (x)} = - \frac{\mathrm{d} }{\mathrm{d} x} \log S_{0} (x) $                  |     $\displaystyle \mu_{x} = - \frac{\frac{\mathrm{d}}{\mathrm{d} x} \,S_{0}\left( x \right )} {S_{0}\left( x \right )} = - \frac{1}{{_{x} \, }p_{0}} \frac{\mathrm{d}}{\mathrm{d} x} \, \left( {_{x}\,}p_{0} \right )$    |
| $\displaystyle \mu_{x^{*} + t} = - \frac {\frac{\mathrm{d} }{\mathrm{d} t} S_{x^{*}} (t)} {S_{x^{*}} (t)} = \frac {\frac{\mathrm{d} }{\mathrm{d} t} F_{x^{*}}(t)} {S_{x^{*}} (t)} = \frac {f_{x^{*}} (t)} {S_{x^{*}} (t)}= - \frac{\mathrm{d} }{\mathrm{d} t} \log S_{x^{*}} (t)$ | $\displaystyle \mu_{x + t} \, = - \frac{\frac{\mathrm{d}}{\mathrm{d} t} \, S_{x}\left( t \right )} {S_{x}\left( t \right )} = - \frac{1}{{_{t}\,}p_{x}} \frac{\mathrm{d}}{\mathrm{d} t} \, \left( {_{t}\,}p_{x} \right ) $ |
|                                                                                $f_{x}(t)$                                                                                |                                                               $\frac{\mathrm{d}}{\mathrm{d} t} \left( {_{t}}q_{x} \right ) = {_{t}\,}p_{x} \cdot \mu_{x + t}$                                                              |
|                                                                                $F_{x}(t)$                                                                                |                                                                    ${_{t} \, }q_{x} = \int _{0} ^{t}\, {_{s}\,}p_{x} \, \mu_{ x + s } \;\; \mathrm{d}s$                                                                    |
|                                                                                $S_{x} (t) = \exp \left\{ -\int_{0}^{t} \, \mu_{x+s} \;\;\mathrm{d} s \right\}$                                                                                |                                                                                ${_{t} \, }p_{x}$                                                                                |
|                                                                                |                                                                                |

***
<center>**Mean and standard deviation for curtate and complete future life time, ** $T_x$  </center>

- **complete expection of life** for $x \geq 0$

$$
\begin{align*}
\overset{\circ}{e}_{x} &= \int_{-\infty} ^{\infty} t \cdot f_{x} \left( t \right) \mathrm{d}t \\
&= \int_{0} ^{\infty} t \cdot {_{t}p_{x}} \cdot \mu_{x + t} \mathrm{d}t \\
&= \int_{0} ^{\infty} t \cdot \left( -\frac{\mathrm{d}} {\mathrm{d}t} {_{t}q_{x}} \right) \mathrm{d}t \\
&= -\int_{0} ^{\infty} t \,{\mathrm{d} \left( {_{t}q_{x}} \right)} \\
&= -\left( t \cdot {_{t}p_{x}} \mid _{0} ^{\infty} -  \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t \right) \\
&= \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t = \mathbb{E}\left[ \,T_{x} \,\right]
\end{align*}
$$

- **Second order complete expectation of life**

$$
\begin{align*}
\mathbb{E}\left[ \,T_{x}^{2} \,\right] &= -\left( t^2 \! \cdot \! {_{t}p_{x}} \mid _{0} ^{\infty} -  \int_{0} ^{\infty} {_{t}p_{x}} \, \mathrm{d}t^2 \right) \\
&= - \left( \lim_{t \to \infty} t^2 \! \cdot \! {_{t}p_{x}}  -  \int_{0} ^{\infty} 2t \, {_{t}p_{x}} \, \mathrm{d}t \right) \\
&= \int_{0} ^{\infty} 2t \, {_{t}p_{x}} \, \mathrm{d}t
\end{align*}
$$

- **Curtate future lifetime**: $K_{x} = \left \lfloor T_{x} \right \rfloor$

$$\begin{align*}
\mathrm{Pr} \left[ K_{x} = k \right] &= \mathrm{Pr} \left[ k \leq T_{x} < k+1 \right] \\
&= {_{k \mid 1}}q_{x} \\
&= {_k}p_{x} - {_{k + 1}}p_{x}  \\
&= {_k}p_{x} - {_k}p_{x} \cdot {_1}p_{x + k} \\
&= {_k}p_{x} \left( 1 - p_{x + k} \right) \\
&= {_k}p_{x} \cdot q_{x + k}
\end{align*}$$

- **Curtate expection of life**

$$\begin{align*}
e_{x} &= \mathbb{E}\left[ \,K_{x} \,\right] \\
&= \sum _{k = 0} ^{\infty} k \cdot \mathrm{Pr} \left[ K_{x} = k \right] \\
&= \sum _{k = 0} ^{\infty} k \cdot \Big( {_k}p_{x} - {_{k + 1}}p_{x} \Big) \\
&= 0 + 1\left( {_1}p_{x} - {_{2}}p_{x} \right) + 2\left( {_2}p_{x} - {_3}p_{x} \right) + 3\left( {_3}p_{x} - {_4}p_{x} \right) + \cdots \\
&= \sum _{k = \mathbf{1}} ^{\infty} {_k}p_{x}
\end{align*}$$

- **Second order curtate expectation of life**

$$\mathbb{E}\left[ \,K_{x}^{2} \,\right] = \sum _{k = \mathbf{1}} ^{\infty} \left( 2k-1 \right) \cdot {_k}p_{x} = 2\left( \sum _{k = \mathbf{1}} ^{\infty} k \cdot {_k}p_{x} \right) - e_{x}$$

- **RELATIONSHIP BETWEEN**

$$\begin{align*}
\overset{\circ}{e}_{x} &= \int_{0}^{\infty} {_t}p_{x} \mathrm{d}t \\
&= \sum _{j=0} ^{\infty} \int_{j}^{j+1} {_t}p_{x} \mathrm{d}t \\
&\approx \sum _{j=0} ^{\infty} \left( 1 \times {_{j+1}}p_{x} + \frac{1} {2} \times 1 \times \left( {_j}p_{x} - {_{j+1}}p_{x} \right) \right) \\
&= \sum _{j=0} ^{\infty} \left( \frac{1} {2} \left( {_j}p_{x} + {_{j+1}}p_{x} \right) \right) \\
&= \frac{1} {2} + \sum _{j=1} ^{\infty} {_j}p_{x} = \frac{1} {2} + e_{x}
\end{align*}$$

- **n-year annual term curtate expectation of life**: $L_{x} = \min\left( K_{x},n \right)$

$$\begin{align*}
e_{x:\overline {n|}} &= \mathbb{E} \left[ \, \min\left( K_{x},n \right) \, \right] \\
&= \sum _{l=0} ^{n} l \cdot \mathrm{Pr} \left[ L_{x} = l \right] \\
&= \left( \sum _{l=0} ^{n - 1} l \cdot \Big( {_l}p_{x} - {_{l + 1}}p_{x} \Big) \right) + n \cdot {_n}p_{x} \\
&= \sum _{\mathbf{l=1}} ^{n} {_l}p_{x}
\end{align*}$$

- **n-year annual term complete expectation of life**

$$\overset{\circ}{e}_{x:\overline {n|}} = \mathbb{E}\left[ \, \min\left( T_{x},n \right) \,\right]= \int_{\mathbf{0}}^{n} {_t}p_{x} \mathrm{d}t$$

***
<center>**After **$l_x$</center>

$\{l_{x}\}_{x \, \in \,\left[ x_{0}, \omega \right]}$, a function as follows:  Let $l_{x_{0}}$ be an *arbitrary positive* number, called the **radix**. Then, for $0 \leq t \leq \omega − x_0$, define:

$$l_{x_0 + t} = l_{x_0} \cdot {_{t}}p_{x}$$

$${_{t}}p_{x} = \frac{l_{x+t}} {l_{x}}, {_{t}}q_{x} = \frac{l_{x} - l_{x+t}} {l_{x}}, {_{u \mid t}}q_{x} = \frac{l_{x + u} - l_{x + u + t}} {l_{x}}$$

***
<center>**UDD & CFM** after $d_{x} = l_{x} - l_{x+1}$</center>

- **UDD**
$${_{s}}q_{x} = s \cdot q_{x} = s \cdot {_{1}}q_{x} \Rightarrow l_{x+s} = l_{x} - s \cdot d_{x}$$
  - After differentiate:

    $$q_{x} = f_{x} \left( s \right) = {_s}p_x \cdot \mu_{x+s}, 0 \leq s < 1$$

- **CFM**

$${_{s}}p_{x+t} = (p_{x})^s, t, s > 0, t + s \leq 1$$

>**e.g.** Exercise 3.4 The given data are $q_{[x]}$, $q_{[x-1]+1}$, $q_{[x-2]+2}$, $q_{[x-3]+3}$, $q_{[x-4]+4}$, for duration more than $5$, it's just $q_{[x]}$.
>
>$(\text{a})$ ${_{2}}p_{[72]}$
>
>$$\begin{align}
{_{2}}p_{[72]} &= p_{[72]} \cdot p_{[72]+1} \\
&= \left(1 - q_{[72]}\right)\left(1 - q_{[72]+1}\right)
\end{align}$$
>
>$(\text{b})$ ${_{3}}q_{[73]+2}$
>
>$$\begin{align}
{_{3}}q_{[73]+2} &= 1 - \left(p_{[73]+2} \cdot p_{[73]+3} \cdot p_{[73]+4}\right)\\
&= 1 - \big( \left( 1 - q_{[73]+2} \right) \left( 1 - q_{[73]+3} \right) \left( 1 - q_{[73]+4} \right)\big)
\end{align}$$
>
>$(\text{c})$ ${_{1\mid}}q_{[65]+4}$
>
>$$\begin{align}
{_{1\mid}}q_{[65]+4} &= p_{[65]+4} - {_{2}}p_{[65]+4} \\
&= \left( 1 - q_{[65]+4} \right) - \left( 1 - q_{[65]+4} \right) \left( 1 - q_{[65]+5} \right) \\
&= \left( 1 - q_{[65]+4} \right) \times q_{65+5}
\end{align}$$
>
>$(\text{d})$ ${_{7}}p_{[70]}$
>
>$$\begin{align}
{_{7}}p_{[70]} &= p_{[70]}p_{[70]+1}p_{[70]+2}p_{[70]+3}p_{[70]+4}p_{[70]+5}p_{[70]+6} \\
&= \left( 1 - q_{[70]} \right) \left( 1 - q_{[70]+1} \right) \cdots \left( 1 - q_{[70]+4} \right) \left( 1 - q_{70+5} \right) \left( 1 - q_{70+6} \right)
\end{align}$$

>**e.g.** Exercise 3.5 The given data are $q_{[x]}$, $q_{[x-1]+1}$, $q_{[x-2]+2}$, $q_{[x-3]+3}$, $q_{[x-4]+4}$, for duration more than $5$, it's just $q_{[x]}$.
>
>$(\text{c})$ ${_{3.8}}q_{[70]+0.2}$, under *UDD*
>
>$$\begin{align*}
{_{3.8}}q_{[70]+0.2} &= 1 - {_{0.8}}p_{[70]+0.2}p_{[70]+1}p_{[70]+2}p_{[70]+3} \\
&= 1 - \left( \frac{p_{[70]}} {{_{0.2}}p_{[70]}} \right)p_{[70]+1}p_{[70]+2}p_{[70]+3} \\
&\stackrel{\mathbf{UDD}}{=} 1 - \left( \frac{1 - q_{[70]}} {0.2 \times \left( 1 - q_{[70]} \right)} \right) \left( 1 - q_{[70]+1} \right) \left( 1 - q_{[70]+2} \right)\left( 1 - q_{[70]+3} \right)
\end{align*}$$


### This notebook computes the joint likelihood in 5 dimensions for the parameters of interest (see below) from pre-computed likelihoods for individual lenses

```python
from lenslikelihood.measurements import flux_measurements, flux_measurement_uncertainties, all_lens_names, all_param_ranges
import matplotlib.pyplot as plt

# Note that the syntax for the uncertainties is
# {'lens_name': (1-sigma-uncertainty, reference_index, uncertainty_in_ratio)}
# where reference_index is the reference image with which to compute the flux ratio, and uncertainty_in_ratio specifies
# whether the measurement uncertainty refers to the flux or the flux ratio

for name in all_lens_names:
    print(name)
    print('fluxes/flux ratios measured: ', flux_measurements[name])
    print('uncertainties: ', flux_measurement_uncertainties[name])
    print('\n')
```

    B1422
    fluxes/flux ratios measured:  [0.88  1.    0.474 0.025]
    uncertainties:  ([0.011363636363636364, 0.01, 0.012765957446808512, None], 0, False)

    HE0435
    fluxes/flux ratios measured:  [0.96  0.976 1.    0.65 ]
    uncertainties:  ([0.05, 0.049, 0.048, 0.056], 0, False)

    WGD2038
    fluxes/flux ratios measured:  [0.86 1.   0.79 0.4 ]
    uncertainties:  ([0.01, 0.01724137931034483, 0.021739130434782608, 0.021739130434782608], 0, False)

    WGDJ0405
    fluxes/flux ratios measured:  [0.8  0.52 1.   0.94]
    uncertainties:  ([0.04, 0.061538461538461535, 0.024, 0.03418803418803419], 0, False)

    WFI2033
    fluxes/flux ratios measured:  [1.   0.65 0.5  0.53]
    uncertainties:  ([0.03, 0.046875, 0.04, 0.03773584905660377], 0, False)

    PSJ1606
    fluxes/flux ratios measured:  [1.   1.   0.59 0.79]
    uncertainties:  ([0.03, 0.03, 0.03333333333333333, 0.02564102564102564], 0, False)

    WFI2026
    fluxes/flux ratios measured:  [1.   0.75 0.31 0.28]
    uncertainties:  ([0.02, 0.02666666666666667, 0.06451612903225806, 0.03571428571428571], 0, False)

    RXJ0911
    fluxes/flux ratios measured:  [0.56 1.   0.53 0.24]
    uncertainties:  ([0.07142857142857142, 0.05, 0.07547169811320754, 0.16666666666666669], 0, False)

    RXJ1131
    fluxes/flux ratios measured:  [1.   0.61 0.73 0.12]
    uncertainties:  ([[0.012345679012345678, 0.024691358024691357], [0.10084033613445378, 0.025210084033613446], None], 1, True)

    MG0414
    fluxes/flux ratios measured:  [1.   0.83 0.36 0.16]
    uncertainties:  ([0.06024096385542169, 0.11111111111111112, 0.11764705882352941], 0, True)

    PG1115
    fluxes/flux ratios measured:  [1.   0.93 0.16 0.21]
    uncertainties:  ([0.06451612903225806, 0.43750000000000006, 0.1904761904761905], 0, True)

### Models implemented for the halo mass function and concentration-mass relation

The full set of hyper-parameters we're interested in constraining are defined by the parameterizations of the halo mass function and concentration-mass relation. They are $\Sigma_{\rm{sub}}$, $\delta_{\rm{LOS}}$, $\Delta \alpha$, $q$, $c_8$, and $\beta$. The first four define to the subhalo and field halo mass functions, and the last two define the concentration-mass relation.

The field halo mass function is parameterized as
\begin{equation}
\frac{dN_{\rm{LOS}}}{dm dV} = \delta_{\rm{LOS}} \left(1+\xi_{\rm{2halo}}\right) \left(\frac{m}{10^8}\right)^{\Delta \alpha} \ \frac{dN_{\rm{ShethTormen}}}{dm dV}
\end{equation}
where $\delta_{\rm{LOS}}$ scales the overall normalization, and $\Delta \alpha$ parameterizes deviations from the logarithmic slope predicted by CDM around $10^8 M_{\odot}$.

The subhalo mass function is parameterized as
\begin{equation}
\frac{dN_{\rm{sub}}}{dm dA} \sim \Sigma_{\rm{sub}} \ \left(\frac{m}{10^8}\right)^{\alpha + q \Delta \alpha}
\end{equation}
where $\Sigma_{\rm{sub}}$ is the normalization, $\alpha$ is the logarithmic slope predicted by CDM, $\Delta \alpha$ parameterizes deviations from the value predicted by CDM, and $q$ controls the coupling between the line of sight halo mass function slope and the subhalo mass function slope. When $q=1$ the slopes change in the same way, and when $q=0$ the slopes of the subhalo and field halo mass functions are completely decoupled.

The concentration-mass relation is parameterized as

\begin{equation}
c\left(M, z\right) = c_8 \left(1+z\right)^{\zeta} \left(\frac{\nu\left(M, z\right)}{\nu\left(10^8, z\right)}\right)^{-\beta}
\end{equation}
i.e. it is a power-law in the peak height $\nu$ with normalization $c_8$ at $10^8$ and a logarithmic slope $\beta$. The parameter $\zeta$ modifies the redshift evolution and is marginalized over in the sampling.

The parameter names used in the python code have the following correspondence:

1) sigma_sub = $\Sigma_{\rm{sub}}$

2) delta_power_law_index = $\Delta \alpha$

3) c0 = $c_8$

4) beta = $\beta$

5) delta_power_law_index_coupling = $q$

6) LOS_normalization = $\delta_{\rm{LOS}}$

Now we compute the likelihood using the package trikde https://github.com/dangilman/trikde

```python
from trikde.pdfs import DensitySamples, IndepdendentLikelihoods
import os
import pickle

nbins = 20
likelihoods, likelihoods_coupled, likelihoods_decoupled, likelihoods_lowa4 = [], [], [], []

filename_extension = '_joint'
filename_extension_coupled = '_joint_coupled'
filename_extension_decoupled = '_joint_decoupled'
base_path = './../lenslikelihood/precomputed_likelihoods/'
print(all_lens_names)

lens_list = ['B1422',
            'HE0435',
            'WGD2038',
            'WGDJ0405',
            'WFI2033',
            'PSJ1606',
            'WFI2026',
            'RXJ0911',
            'RXJ1131',
            'MG0414',
            'PG1115']

for lens in lens_list:

    fname = base_path + lens + filename_extension
    print('loading joint likelihoods for lens '+lens+' ...')
    f = open(fname, 'rb')
    single_lens_likelihood = pickle.load(f)
    f.close()
    likelihoods.append(single_lens_likelihood)

    fname = base_path + lens + filename_extension_coupled
    f = open(fname, 'rb')
    single_lens_likelihood = pickle.load(f)
    f.close()
    likelihoods_coupled.append(single_lens_likelihood)

    fname = base_path + lens + filename_extension_decoupled
    f = open(fname, 'rb')
    single_lens_likelihood = pickle.load(f)
    f.close()
    likelihoods_decoupled.append(single_lens_likelihood)

#     fname = base_path + lens + filename_extension_lowa4
#     f = open(fname, 'rb')
#     single_lens_likelihood = pickle.load(f)
#     f.close()
#     likelihoods_lowa4.append(single_lens_likelihood)

likelihood = IndepdendentLikelihoods(likelihoods)
likelihood_coupled = IndepdendentLikelihoods(likelihoods_coupled)
likelihood_decoupled = IndepdendentLikelihoods(likelihoods_decoupled)
#likelihood_lowa4 = IndepdendentLikelihoods(likelihoods_lowa4)
```

    ['B1422', 'HE0435', 'WGD2038', 'WGDJ0405', 'WFI2033', 'PSJ1606', 'WFI2026', 'RXJ0911', 'RXJ1131', 'MG0414', 'PG1115']
    loading joint likelihoods for lens B1422 ...
    loading joint likelihoods for lens HE0435 ...
    loading joint likelihoods for lens WGD2038 ...
    loading joint likelihoods for lens WGDJ0405 ...
    loading joint likelihoods for lens WFI2033 ...
    loading joint likelihoods for lens PSJ1606 ...
    loading joint likelihoods for lens WFI2026 ...
    loading joint likelihoods for lens RXJ0911 ...
    loading joint likelihoods for lens RXJ1131 ...
    loading joint likelihoods for lens MG0414 ...
    loading joint likelihoods for lens PG1115 ...

### The joint likelihood/posterior with indepedent, uniform priors on all model parameters

This likelihood includes a marginalization over a term that couples the subhalo mass function slope to the field halo mass function slope

```python
from trikde.triangleplot import TrianglePlot
triangle_plot = TrianglePlot([likelihood])
triangle_plot.set_cmap('magma')
axes = triangle_plot.make_triplot(filled_contours=False, show_intervals=False, show_contours=False
                                 )
beta = r'$\beta$'
beta_ticks = [0., 1., 2., 3., 4.]
c0 = r'$c_8$'
c0_ticks = [1, 50, 100, 150, 200]
delta_power_law_index = r'$\Delta \alpha$'
dpli_ticks = [-0.6, -0.3, 0., 0.3, 0.6, 0.9]
sigma_sub = r'$\Sigma_{\rm{sub}} \ \left[\rm{kpc^{-2}}\right]$'
sigma_sub_ticks = [0., 0.025, 0.05, 0.075, 0.1]
delta_LOS = r'$\delta_{\rm{LOS}}$'
dlos_ticks = [0., 0.5, 1., 1.5, 2.]
ticksize = 14
labelsize = 18
rotation = 40

axes[5].set_ylabel(beta, fontsize=labelsize)
axes[5].set_yticks(beta_ticks)
axes[5].set_yticklabels(beta_ticks, fontsize=ticksize)

axes[10].set_ylabel(c0, fontsize=labelsize)
axes[10].set_yticks(c0_ticks)
axes[10].set_yticklabels(c0_ticks, fontsize=ticksize)

axes[15].set_ylabel(delta_power_law_index, fontsize=labelsize)
axes[15].set_yticks(dpli_ticks)
axes[15].set_yticklabels(dpli_ticks, fontsize=ticksize)

axes[20].set_ylabel(sigma_sub, fontsize=labelsize)
axes[20].set_yticks(sigma_sub_ticks)
axes[20].set_yticklabels(sigma_sub_ticks, fontsize=ticksize)

axes[20].set_xlabel(delta_LOS, fontsize=labelsize)
axes[20].set_xticks(dlos_ticks)
axes[20].set_xticklabels(dlos_ticks, fontsize=ticksize, rotation=rotation)

axes[21].set_xlabel(beta, fontsize=labelsize)
axes[21].set_xticks(beta_ticks)
axes[21].set_xticklabels(beta_ticks, fontsize=ticksize, rotation=rotation)

axes[22].set_xlabel(c0, fontsize=labelsize)
axes[22].set_xticks(c0_ticks)
axes[22].set_xticklabels(c0_ticks, fontsize=ticksize, rotation=rotation)

axes[23].set_xlabel(delta_power_law_index, fontsize=labelsize)
axes[23].set_xticks(dpli_ticks)
axes[23].set_xticklabels(dpli_ticks, fontsize=ticksize, rotation=rotation)

axes[24].set_xlabel(sigma_sub, fontsize=labelsize)
axes[24].set_xticks(sigma_sub_ticks)
axes[24].set_xticklabels(sigma_sub_ticks, fontsize=ticksize, rotation=rotation)
# can change axis labels
```

### The joint likelihood/posterior assuming the slope of the subhalo mass function tracks the slope of the field halo mass function.

This likelihood has a Gaussian prior on q (see equation for subhalo mass function at the top of this notebook) with a mean of 1 and a variance of 0.25.

```python
triangle_plot = TrianglePlot([likelihood_coupled])
triangle_plot.cmap = 'magma'
axes = triangle_plot.make_triplot(filled_contours=False, show_intervals=False, show_contours=False)

axes[5].set_ylabel(beta, fontsize=labelsize)
axes[5].set_yticks(beta_ticks)
axes[5].set_yticklabels(beta_ticks, fontsize=ticksize)

axes[10].set_ylabel(c0, fontsize=labelsize)
axes[10].set_yticks(c0_ticks)
axes[10].set_yticklabels(c0_ticks, fontsize=ticksize)

axes[15].set_ylabel(delta_power_law_index, fontsize=labelsize)
axes[15].set_yticks(dpli_ticks)
axes[15].set_yticklabels(dpli_ticks, fontsize=ticksize)

axes[20].set_ylabel(sigma_sub, fontsize=labelsize)
axes[20].set_yticks(sigma_sub_ticks)
axes[20].set_yticklabels(sigma_sub_ticks, fontsize=ticksize)

axes[20].set_xlabel(delta_LOS, fontsize=labelsize)
axes[20].set_xticks(dlos_ticks)
axes[20].set_xticklabels(dlos_ticks, fontsize=ticksize, rotation=rotation)

axes[21].set_xlabel(beta, fontsize=labelsize)
axes[21].set_xticks(beta_ticks)
axes[21].set_xticklabels(beta_ticks, fontsize=ticksize, rotation=rotation)

axes[22].set_xlabel(c0, fontsize=labelsize)
axes[22].set_xticks(c0_ticks)
axes[22].set_xticklabels(c0_ticks, fontsize=ticksize, rotation=rotation)

axes[23].set_xlabel(delta_power_law_index, fontsize=labelsize)
axes[23].set_xticks(dpli_ticks)
axes[23].set_xticklabels(dpli_ticks, fontsize=ticksize, rotation=rotation)

axes[24].set_xlabel(sigma_sub, fontsize=labelsize)
axes[24].set_xticks(sigma_sub_ticks)
axes[24].set_xticklabels(sigma_sub_ticks, fontsize=ticksize, rotation=rotation)

plt.savefig('lensing_likelihood.pdf')
# can change axis labels
```

### The joint likelihood/posterior assuming the slope of the subhalo mass function is completely decoupled from the slope of the field halo mass function.

This likelihood has a Gaussian prior on q (see equation for subhalo mass function at the top of this notebook) with a mean of 0 and a variance of 0.25.

```python
triangle_plot = TrianglePlot([likelihood_decoupled])
triangle_plot.cmap = 'magma'
axes = triangle_plot.make_triplot(filled_contours=False, show_intervals=False, show_contours=False)

axes[5].set_ylabel(beta)
axes[5].set_yticks(beta_ticks)
axes[5].set_yticklabels(beta_ticks)

axes[10].set_ylabel(c0)
axes[10].set_yticks(c0_ticks)
axes[10].set_yticklabels(c0_ticks)

axes[15].set_ylabel(delta_power_law_index)
axes[15].set_yticks(dpli_ticks)
axes[15].set_yticklabels(dpli_ticks)

axes[20].set_ylabel(sigma_sub)
axes[20].set_yticks(sigma_sub_ticks)
axes[20].set_yticklabels(sigma_sub_ticks)

axes[20].set_xlabel(delta_LOS)
axes[20].set_xticks(dlos_ticks)
axes[20].set_xticklabels(dlos_ticks)

axes[21].set_xlabel(beta)
axes[21].set_xticks(beta_ticks)
axes[21].set_xticklabels(beta_ticks)

axes[22].set_xlabel(c0)
axes[22].set_xticks(c0_ticks)
axes[22].set_xticklabels(c0_ticks)

axes[23].set_xlabel(delta_power_law_index)
axes[23].set_xticks(dpli_ticks)
axes[23].set_xticklabels(dpli_ticks)

axes[24].set_xlabel(sigma_sub)
axes[24].set_xticks(sigma_sub_ticks)
axes[24].set_xticklabels(sigma_sub_ticks)
# can change axis labels
```

```python

```