Posts tagged with gamma

One of the most common exersices given to Statistical Computing,Simulation or relevant classes is the generation of random numbers from a gamma distribution. At first this might seem straightforward in terms of the lifesaving relation that exponential and gamma random variables share. So, it’s easy to get a gamma random variate using the fact that

$$ {{X}_{i}}\tilde{\ }Exp(\lambda )\Rightarrow \sum\limits_{i}{{{X}_{i}}}\tilde{\ }Ga(k,\lambda )$$.

The code to do this is the following

rexp1 <- function(lambda, n) {
  u <- runif(n)
  x <- -log(u)/lambda
  }

rgamma1 <- function(k, lambda) {
  sum(rexp1(lambda, k))
}

This works unfortunately only for the case $$ k\in \mathbb{N}$$.
Read the rest of this entry »

Actuaries are not famous for their sense of humour. Sometimes, they exhibit a remarkable sense of it though!

A second year undergrad student is familiar with the following formula,

$$ EX=\int_{0}^{\infty }{\left( 1-F(x) \right)dx},$$

where X is a random variable satisfying $$ X\ge 0$$ with probability 1. Most call $$ 1-F(x)\,$$ the right tail and others the survival function of X,denoted by $$ S(x)\ $$. This is a really convenient way to calculate expected values instead of using integration by parts.

Actuaries find this quite handy especially when dealing with deductibles that shift the variable or stop limits that truncate the variable from above. The first is usually treated whether the latter makes no real difference as the survival function will be 0 over the stop limit.

Where’s the joke that actuaries tipped in? Well, they called this the Darth Vader Rule given that Darth Vader was a true survivor…

Below you can see the expected value of a Gamma(2,5) random variable.

To get the plot it’s easy with Mathematica for instance.

Plot[CDF[GammaDistribution[2, 5], x], {x, 0, 25}, PlotRange -> {{0, 29}, {0, 1}}, Filling -> Top]

Next calculate the expected value.

Integrate[1 - CDF[GammaDistribution[2, 5], z], {z, 0, 25}] // N
9.76417

Real Time Web Analytics