# Moments

### Integrating survival function to calculate the mean

Posted on Updated on

For a continuous random variable $X$ that are non-negative in values, the mean $E(X)$ is obtained by integrating $x f(x)$ from $0$ to $\infty$ where $f(x)$ is the probability density function of $X$. In some cases, this integral is hard (or impossible) to do. In these cases, it may be possible to find the mean and higher moments by integrating the survival functions.

Here’s the usual way to calculate moments.
$\displaystyle (1) \ \ \ \ E(X)=\int_0^\infty x f(x) \ dx$
$\text{ }$
$\displaystyle (2) \ \ \ \ E(X^k)=\int_0^\infty x^k f(x) \ dx$

Moments can be calculated by integrating the survival function.
$\displaystyle (3) \ \ \ \ E(X)=\int_0^\infty S(x) \ dx$
$\text{ }$
$\displaystyle (4) \ \ \ \ E(X^k)=\int_0^\infty k x^{k-1} S(x) \ dx$

In fact, the mean and moments of many of the distributions in the Exam C table are calculated using the survival function method, e.g. the Pareto distribution and the exponential distribution.

The integrals in (3) and (4) are derived from (1) and (2) by performing integration by parts. The derivation is not very hard. You will find out that some assumptions are needed to make the integration by parts work. Specifically, the assumption is that the following limit is 0.

$\displaystyle \lim_{x \rightarrow \infty} x^k \ S(x)= 0$

The integrals in (3) and (4) works only if this limit converges to zero. Essentially this limit is zero if the expectation $E(X^k)$ exists.

The same idea can be applied to a discrete distribution.

$\displaystyle (5) \ \ \ \ E(X)=\sum_{x=0}^\infty x P(X=x)$
$\text{ }$
$\displaystyle (6) \ \ \ \ E(X^k)=\sum_{x=0}^\infty x^k P(X=x)$

$\displaystyle (7) \ \ \ \ E(X)=\sum_{x=0}^\infty P(X>x)$
$\text{ }$
$\displaystyle (8) \ \ \ \ E(X^k)=\sum_{x=0}^\infty [(x+1)^k-x^k] P(X>x)$

$\text{ }$

$\text{ }$

Examples

Example 1
Suppose that the useful life (in months) of a device is modeled by the CDF $F(x)=1-(1- x/120)^{1/2}$ for $0 \le x \le 120$. Calculated the expected useful of a brand new device. Calculate the variance of the lifetime of such a device.

Note that the survival function is $S(x)=(1- x/120)^{1/2}$. The following shows the calculation.

$\displaystyle E(X)=\int_0^{120} (1- x/120)^{1/2} \ dx=80$

\displaystyle \begin{aligned} E(X^2)&=\int_0^{120} 2x \ (1- x/120)^{1/2} \ dx \\&=\int_1^{0} 2 \cdot 120(1-U) \ U^{1/2} (-120) \ dU \\&=\int_0^{1} 28800 \ (U^{1/2}-U^{3/2}) \ dU \\&=28800 \ \biggl[\frac{2}{3} U^{3/2}-\frac{2}{5} U^{5/2} \biggr]_0^1 \\&=7680 \end{aligned}

$Var(X)=E(X^2)-E(X)^2=7680-80^2=1280$

Note that the integral for $E(X^2)$ uses the method of substitution.

Example 2
Suppose that the lifetime of a machine follows a distribution with the following CDF.

$\displaystyle F(x)=1+e^{-x/6}-2 e^{-x/12} \ \ \ \ \ x>0$

Calculate the mean and variance of the lifetime.

The survival function is $\displaystyle S(x)=2 e^{-x/12}-e^{-x/6}$. The first is to calculate the first 2 moments.

\displaystyle \begin{aligned} E(X)&=\int_0^\infty (2 e^{-x/12}-e^{-x/6}) \ dx \\&=\int_0^\infty (2 \cdot 12 \frac{1}{12} e^{-x/12}-6 \ \frac{1}{6} e^{-x/6}) \ dx \\&=24 \int_0^\infty \frac{1}{12} e^{-x/12} \ dx- 6 \int_0^\infty \frac{1}{6} e^{-x/6} \ dx=24-6=18 \end{aligned}

\displaystyle \begin{aligned} E(X^2)&=\int_0^\infty 2x (2 e^{-x/12}-e^{-x/6}) \ dx \\&=\int_0^\infty (4x e^{-x/12}-2x e^{-x/6}) \ dx \\&=\int_0^\infty (4 \cdot 12 \ x \frac{1}{12} e^{-x/12}-2 \cdot 6 \ x \ \frac{1}{6} e^{-x/6}) \ dx \\&=48 \int_0^\infty x \frac{1}{12} e^{-x/12} \ dx -12 \int_0^\infty x \ \frac{1}{6} e^{-x/6} \ dx=48(12)-12(6)=504 \end{aligned}

$Var(X)=E(X^2)-E(X)^2=504-18^2=180$

Note that the integral for $E(X)$ is manipulated to be in terms of integrals of exponential density functions while the integral for $E(X^2)$ is manipulated to be in terms of integrals of $x$ times exponential density functions (each becoming the mean of that exponential distribution).

Example 3
The two-parameter Pareto distribution (Type II Lomax) is discussed in here in a companion blog. Its survival function is

$\displaystyle S(x)=\biggl(\frac{\theta}{x+\theta} \biggr)^\alpha \ \ \ \ \ x>0$

Derive the mean of the Pareto distribution using the survival function approach. What assumption is made on the shape parameter $\alpha$?

\displaystyle \begin{aligned} E(X)&=\int_0^\infty \biggl(\frac{\theta}{x+\theta} \biggr)^\alpha \ dx \\&=\int_0^\infty \theta^\alpha (x+\theta)^{- \alpha} \ dx \\&=\frac{\theta^\alpha}{-\alpha+1} \ (x+\theta)^{-\alpha+1} \biggr|_0^\infty \\&=\frac{\theta^\alpha}{-\alpha+1} \ \frac{1}{(x+\theta)^{\alpha-1}} \biggr|_0^\infty =\frac{\theta}{\alpha-1} \end{aligned}

In order for the integral to converge, we need to assume $\alpha>1$.

The next two examples are left as exercises.

Practice Problems

Practice Problem 1
The survival function for the distribution of a lifetime of a type of electronic devices is $\displaystyle S(x)=\frac{1}{40} \ e^{-x/10}+\frac{1}{20} \ e^{-x/15} \ \ \ \ \ x>0$.

Calculate the mean and variance of the lifetime of such devices.

Practice Problem 2
The probability that the size of a randomly selected auto collision loss is greater than $x$ is $\displaystyle S(x)=\biggl(1-\frac{x}{10} \biggr)^6 \ \ \ \ 0.

Calculate the mean and variance of the loss size.

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

Answers

Practice Problem 1

$\displaystyle E(X)=1$

$\displaystyle Var(X)=\frac{53}{2}=26.5$

Practice Problem 2

$\displaystyle E(X)=\frac{10}{7}$

$\displaystyle Var(X)=\frac{75}{49}$

$\text{ }$

$\text{ }$

$\text{ }$

$\copyright$ 2017 – Dan Ma

Advertisements

### Basic properties of lognormal distribution

Posted on Updated on

A detailed discussion of the mathematical properties of lognormal distribution is found in this previous post in a companion blog. This post shows how to work basic calculation problems for lognormal distribution. A summary of lognormal distribution is given and is followed by several examples. Practice problems are in the next post.

______________________________________________________________________________________________________________________________

Basic Properties

The random variable $Y$ is said to follow a lognormal distribution with parameters $\mu$ and $\sigma$ if $\log(Y)$ follows a normal distribution with mean $\mu$ and variance $\sigma^2$. Here, $\log$ is the natural logarithm in base $e$ = 2.718281828…. It is difficult (if not impossible) to calculate probabilities by integrating the lognormal density function. Since the lognormal distribution is intimately related to the normal distribution, the basic lognormal calculation is performed by calculating the corresponding normal distribution. The following summary shows how.

In the following points, $Y$ has a lognormal distribution with parameters $\mu$ and $\sigma$ and $X=\log(Y)$ is the corresponding normal distribution with mean $\mu$ and variance $\sigma^2$. The notation $\exp(t)$ means raising $e$ to the number $t$.

 1. Lognormal observations and normal observations Taking natural log of a lognormal observation gives a normal observation. Raising $e$ to a normal observation gives a lognormal observation.
 2. Lognormal CDF and normal CDF $\Phi(z)$ is the CDF of the standard normal distribution. $\displaystyle F_Y(y)=\Phi \biggl(\frac{\log(y)-\mu}{\sigma} \biggr)$ In words, lognormal CDF evaluated at $y$ equals to standard normal CDF evaluated at $\frac{\log(y)-\mu}{\sigma}$. Derivation: \displaystyle \begin{aligned} F_Y(y)=P(Y \le y)&=P[\log(Y) \le \log(y)] \\&=P \biggl[\frac{\log(Y)-\mu}{\sigma} \le \frac{\log(y)-\mu}{\sigma} \biggr] \\&=\Phi \biggl(\frac{\log(y)-\mu}{\sigma} \biggr) \end{aligned}
 3. Lognormal density function and normal density function normal density: $\displaystyle f_X(x)=\frac{1}{\sqrt{2 \pi} \ \sigma} \exp(-\frac{(x-\mu)^2}{2 \sigma^2})$ lognormal density: $\displaystyle F_Y(y)=\frac{1}{\sqrt{2 \pi} \ \sigma \ y} \exp(-\frac{(\log(y)-\mu)^2}{2 \sigma^2})$ In words, lognormal density evaluated at $y$ equals to normal density evaluated at $\log(y)$ times $\frac{1}{y}$.
 4. Lognormal moments and normal moment generating function normal mgf: $M(t)=e^{\mu \ t+\frac{1}{2} \sigma^2 \ t^2}=\exp(\mu \ t+\frac{1}{2} \sigma^2 \ t^2)$ lognormal moment: $E(x^k)=M(k)=\exp(\mu \ k+\frac{1}{2} \sigma^2 \ k^2)$ In words, lognormal $k$th raw moment equals to normal mgf evaluated at $k$.
 5. Examples of lognormal moments $E(Y)=E[e^{\log(Y)}]=M(1)=e^{\mu+\frac{1}{2} \sigma^2}$ $E(Y^2)=E[e^{2 \log(Y)}]=M(2)=e^{2 \mu+2 \ \sigma^2}$ $Var(Y)=e^{2 \ \mu+2 \ \sigma^2}-e^{2 \mu+ \sigma^2}=e^{2 \ \mu+\sigma^2} (e^{\sigma^2}-1)$ skewness: $\gamma_1=(e^{\sigma^2}+2) \sqrt{e^{\sigma^2}-1}$ kurtosis: $e^{4 \sigma^2}+2 e^{3 \sigma^2}+3 e^{2 \sigma^2}-3$
 6. Lognormal percentiles and normal percentiles $(100p)$th percentile of the normal distribution is $\displaystyle z_p$. $(100p)$th percentile of the normal distribution with mean $\mu$ and variance $\sigma^2$ is $\displaystyle \mu+z_p \times \sigma$. $(100p)$th percentile of the lognormal distribution with parameters $\mu$ and $\sigma$ is $\displaystyle e^{\mu+z_p \times \sigma}$. In words, to find the $(100p)$th percentile of the lognormal distribution, find the $(100p)$th percentile of the corresponding normal distribution and then raise $e$ to it.
 7. Constant multiple of lognormal distribution Let $c>0$. If $Y$ has a lognormal distribution with parameters $\mu$ and $\sigma$, then $c Y$ has a lognormal distribution with parameters $\mu+\log(c)$ and $\sigma$. The effect of the multiplicative constant is on the parameter $\mu$ in the form of an additive adjustment of $\log(c)$.
 8. Mode of lognormal distribution $\displaystyle e^{\mu - \sigma^2}$

______________________________________________________________________________________________________________________________

Examples

Two examples are given to illustrate the calculation discussed here. The next post has practice problems.

All normal probabilities are obtained by using the normal distribution table found here.

Example 1
Suppose that the random variable $Y$ has a lognormal distribution with parameters $\mu$ = 1 and $\sigma$ = 2. Calculate the following.

• $P(Y \le 75.19)$ and $P(Y > 0.9)$
• The 67th, 95th and 99th percentiles of $Y$.
• Let $Y_1=1.1Y$. Find $P(Y_1 \le 75.19)$ and $P(Y_1 > 0.9)$

$\text{ }$

$\displaystyle P(Y \le 75.19)=\Phi \biggl(\frac{\log(75.19)-1}{2} \biggr)=\Phi(1.66)=0.9515$

\displaystyle \begin{aligned}P(Y > 0.9)&=1-\Phi \biggl(\frac{\log(0.9)-1}{2} \biggr) \\&=1-\Phi(-0.55) \\&=1-(1-0.7088) \\&=0.7088 \end{aligned}

_______________________________________________

To find the percentiles, first find the standard normal percentiles, either by using calculator or by looking up a table. Using a standard normal table, we get 0.44 (67th percentile), 1.645 (95th percentile) and 2.33 (99th percentile). The following gives the lognormal percentiles.

$\displaystyle e^{1+0.44(2)}=e^{1.88} = 6.5535$ (67th percentile)

$\displaystyle e^{1+1.645 (2)}=e^{4.29} = 72.9665$ (95th percentile)

$\displaystyle e^{1+2.33(2)}=e^{5.66} = 287.1486$ (99th percentile)

_______________________________________________

The random variable $Y_1=1.1Y$ has a lognormal distribution with parameters $\mu=1+\log(1.1)$ and $\sigma$ = 2.

$\displaystyle P(Y_1 \le 75.19)=\Phi \biggl(\frac{\log(75.19)-1-\log(1.1)}{2} \biggr)=\Phi(1.61)=0.9463$

\displaystyle \begin{aligned}P(Y_1 > 0.9)&=1-\Phi \biggl(\frac{\log(0.9)-1-\log(1.1)}{2} \biggr) \\&=1-\Phi(-0.57) \\&=1-(1-0.7157) \\&=0.7157 \end{aligned}

Note. One interpretation of $Y_1=1.1Y$ is that of inflation, in this case a 10% inflation. For example, let $Y$ be the size of a randomly selected auto insurance collision claim in the current year. If the claims are expected to increase 10% in the following year, $Y_1=1.1Y$ is the the size of a randomly selected claim in the following year.

Example 2
Suppose that the random variable $Y$ has a lognormal distribution with mean 12.18 and variance 255.02. Calculation the following.

• $P(Y > 10)$
• The skewness and kurtosis of $Y$.

$\text{ }$

First, determine the parameters $\mu$ and $\sigma$ by setting up the following equations.

$\displaystyle E(Y)=e^{\mu+\frac{1}{2} \sigma^2}=12.18$

$\displaystyle Var(Y)=[e^{\sigma^2}-1] \ [ e^{ \mu+\frac{1}{2} \sigma^2} ]^2=255.02$

Plug the first equation into the second equation and obtain the equation $\displaystyle [e^{\sigma^2}-1] \ [12.18 ]^2=255.02$. Solving for $\sigma$ produces $\sigma$ = 1. Plug $\sigma$ = 1 into the first equation produces $\mu$ = 2. The following gives the desired probability.

$\displaystyle P(Y > 10)=1-\Phi \biggl(\frac{\log(10)-2}{1} \biggr)=1-\Phi(0.30)=1-0.6179=0.3821$

To find the skewness and kurtosis, one way is to find the first 4 lognormal moments and then calculate the third standardized moment (skewness) and the fourth standardized moment (kurtosis). To see how this is done, see this previous post. Another is to use the formulas given above.

$\gamma_1=(e^{\sigma^2}+2) \sqrt{e^{\sigma^2}-1}=(e^1+2) \sqrt{e^1-1}=6.1849$

$\text{Kurtosis}=e^{4 \sigma^2}+2 e^{3 \sigma^2}+3 e^{2 \sigma^2}-3=e^{4}+2 e^{3}+3 e^{2}-3=113.9364$

Example 3
Suppose that the lifetime (in years) of a certain type of machines follows the lognormal distribution described in Example 2. Suppose that you purchased such a machine that is 10-year old. What is the probability that it will last another 10 years?

This is a conditional probability since the machine already survived for 10 years already.

\displaystyle \begin{aligned}P(Y > 20 \lvert Y > 10)&=\frac{1-\Phi (\frac{\log(20)-2}{1} )}{1-\Phi (\frac{\log(10)-2}{1} )} \\&=\frac{1-\Phi(1.0)}{1-\Phi(0.30)} \\&=\frac{1-0.8413}{1-0.6179} \\&=\frac{0.1587}{0.3821}=0.4153 \end{aligned}

______________________________________________________________________________________________________________________________
$\copyright$ 2017 – Dan Ma

### Practice Problem Set 1 – working with moments

Posted on Updated on

This post has two practice problems to complement the previous post Working with moments.

 Practice Problem 1a Losses are modeled by a distribution that is the independent sum of two exponential distributions, one with mean 6 and the other with mean 12. Calculate the skewness of the loss distribution. Calculate the kurtosis of the loss distribution.
 Practice Problem 1b Losses are modeled by a distribution that is a mixture of two exponential distributions, one with mean 6 and the other with mean 12. The weight of each distribution is 50%. Calculate the skewness of the loss distribution. Calculate the kurtosis of the loss distribution.

Comment
As the previous post Working with moments shows, this is primarily an exercise in finding moments. There is no need to first find the probability density function of the loss distribution. For more information on exponential distribution, see here.

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

Solutions

Problem 1a

$E(X)=18$

$E(X^2)=504$

$E(X^3)=19440$

$E(X^4)=964224$

$\displaystyle \gamma_1=\frac{3888}{180^{1.5}}=1.61$

$\displaystyle \text{Kurt}[X]=\frac{229392}{180^{2}}=7.08$

Problem 1b

$E(X)=9$

$E(X^2)=180$

$E(X^3)=5832$

$E(X^4)=264384$

$\displaystyle \gamma_1=\frac{2430}{99^{1.5}}=2.4669$

$\displaystyle \text{Kurt}[X]=\frac{122229}{99^{2}}=12.47$

_______________________________________________________________________
$\copyright$ 2017 – Dan Ma

### Working with moments

Posted on

This post gives some background information on calculation involving moments.

Let $X$ be a random variable. Let $\mu=E(X)$ be its mean and $\sigma^2=Var(X)$ be its variance. Thus $\sigma$ is the standard deviation of $X$.

The expectation $\displaystyle E[X^k]$ is the $k$th raw moment. It is also called the $k$th moment about zero. The expectation $\displaystyle E[(X-\mu)^k]$ is the $k$th central moment. It is also called the $k$th moment about the mean. Given $X$, its standardized random variable is $\displaystyle \frac{X-\mu}{\sigma}$. Then the $k$th standardized moment is $\displaystyle E \biggl[\biggl(\frac{X-\mu}{\sigma} \biggr)^k \biggr]$.

The mean of $X$ is the first raw moment $\mu=E(X)$. The variance of $X$ is the second central moment $\displaystyle Var(X)=E[(X-\mu)^2]$. It is equivalent to $Var(X)=E(X^2)-\mu^2$. In words, the variance is the second raw moment subtracting the square of the mean.

The skewness of $X$ is the third standardized moment of $X$. The kurtosis is the fourth standardized moment of $X$. The excess kurtosis is the kurtosis subtracting 3. They are:

$\displaystyle \gamma_1 =E \biggl[\biggl(\frac{X-\mu}{\sigma} \biggr)^3 \biggr]$

$\displaystyle \text{kurt}[X] =E \biggl[\biggl(\frac{X-\mu}{\sigma} \biggr)^4 \biggr]$

$\displaystyle \text{Ex Kurt}[X] = \text{kurt}[X]-3$

The calculation is usually done by expanding the expression inside the expectation. As a result, the calculation would then be a function of the individual raw moments up to the third or fourth order.

\displaystyle \begin{aligned} \gamma_1&=E \biggl[\biggl(\frac{X-\mu}{\sigma} \biggr)^3 \biggr] \\&=\frac{E(X^3)-3 \mu E(X^2)+3 \mu^2 E(X)-\mu^3}{(\sigma^2)^{1.5}} \\&=\frac{E(X^3)-3 \mu \sigma^2 - \mu^3}{(\sigma^2)^{1.5}} \end{aligned}

\displaystyle \begin{aligned} \text{kurt}[X]&=E \biggl[\biggl(\frac{X-\mu}{\sigma} \biggr)^4 \biggr] \\&=\frac{E(X^4)-4 \mu E(X^3)+6 \mu^2 E(X^2)-4 \mu^3 E(X)+\mu^4}{\sigma^4} \\&=\frac{E(X^4)-4 \mu E(X^3)+6 \mu^2 E(X^2)-3 \mu^4}{\sigma^4} \end{aligned}

Note that the last line in skewness is a version that depends on the mean, the variance and the third raw moment. The calculation is illustrated with some examples. Practice problems are given in subsequent posts.

Example 1
Losses are modeled by a distribution that has the following density function. Calculate the mean, variance, skewness and kurtosis of the loss distribution.

$\displaystyle f(x)=\left\{ \begin{array}{ll} \displaystyle 0.15 &\ 0

The following shows the calculation of the first four raw moments.

$\displaystyle E(X)=\int_0^5 0.15 x \ dx+\int_5^{10} 0.05 x \ dx=3.75$

$\displaystyle E(X^2)=\int_0^5 0.15 x^2 \ dx+\int_5^{10} 0.05 x^2 \ dx=\frac{62.5}{3}$

$\displaystyle E(X^3)=\int_0^5 0.15 x^3 \ dx+\int_5^{10} 0.05 x^3 \ dx=140.625$

$\displaystyle E(X^4)=\int_0^5 0.15 x^4 \ dx+\int_5^{10} 0.05 x^4 \ dx=1062.5$

The following shows the results.

$\displaystyle Var(X)=\frac{62.5}{3}-3.75^2=\frac{20.3125}{3}=6.77083$

$\displaystyle \gamma_1=\frac{140.625-3 \times 3.75 \times \displaystyle \frac{20.3125}{3} - 3.75^3}{\biggl(\displaystyle \frac{20.3125}{3} \biggr)^{1.5}}=0.66515$

$\displaystyle \text{kurt}[X]=\frac{1062.5-4 \times 3.75 \times 140.625+ 6 \times 3.75^2 \times \displaystyle \frac{62.5}{3}-3 \times 3.75^4}{\displaystyle \biggl(\frac{20.3125}{3} \biggr)^2}=2.56686$

_______________________________________________________________________
$\copyright$ 2017 – Dan Ma