# Gamma Distribution Calculator with examples

## Gamma distribution calculator with examples

Use this calculator to find the probability density and cumulative probabilities for Gamma distribution with parameter $\alpha$ and $\beta$.

Gamma Distribution Calculator
Shape Parameter $\alpha$:
Scale Parameter $\beta$
Value of x
Results
Probability density : f(x)
Probability X less than x: P(X < x)
Probability X greater than x: P(X > x)

### How to use Gamma Distribution Calculator?

Step 1 - Enter the shape parameter $\alpha$

Step 2 - Enter the scale parameter $\beta$

Step 3 - Enter the value of $x$

Step 4 - Click on "Calculate" button to get gamma distribution probabilities

Step 5 - Gives the output probability density at $x$ for gamma distribution

Step 6 - Gives the output probability $X < x$ for gamma distribution

Step 7 - Gives the output probability $X > x$ for gamma distribution.

## Definition of Gamma Distribution

A continuous random variable $X$ is said to have an gamma distribution with parameters $\alpha$ and $\beta$ if its p.d.f. is given by

 \begin{align*} f(x)&= \begin{cases} \frac{1}{\beta^\alpha\Gamma(\alpha)}x^{\alpha -1}e^{-x/\beta}, & x>0;\alpha, \beta >0; \\ 0, & Otherwise. \end{cases} \end{align*}

In notation, it can be written as $X\sim G(\alpha, \beta)$.

## Another form of gamma distribution is

 \begin{align*} f(x)&= \begin{cases} \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha -1}e^{-\beta x}, & x>0;\alpha, \beta >0 \\ 0, & Otherwise. \end{cases} \end{align*}

## Mean and Variance of Gamma Distribution

The mean and variance of gamma distribution $G(\alpha,\beta)$ are
$\mu_1^\prime =\alpha\beta$ and $\mu_2 =\alpha\beta^2$ respectively.

The probabilities can be computed using MS EXcel or R function pgamma().
The percentiles or quantiles can be computed using MS EXcel or R function qgamma().
The probabilities can also be computed using incomplete gamma functions.

## Gamma Distribution Example 1

Suppose that $Y$ has the gamma distribution with parameter $\alpha$ (shape) =10 and $\beta$ (scale)=2. Use R to compute the

a. probability that $Y$ is between 2 and 8,
b. $90^{th}$ percentile of gamma distribution.

#### Solution

Given that $X\sim G(10,2)$ distribution. That is $\alpha= 10$ and $\beta=2$.

The probability density function of $X$ is

 \begin{aligned} f(x;\alpha,\beta)&= \frac{1}{\beta^\alpha \Gamma(\alpha)} x^{\alpha -1}e^{-\frac{x}{\beta}}, x>0;\alpha, \beta >0 \\ &= \frac{1}{2^{10} \Gamma(10)} x^{10 -1}e^{-\frac{x}{2}}, x>0 \end{aligned}

a. The probability that $2 < X < 8$ is

 \begin{aligned} P(2 < X < 8) &= P(X < 8) - P(X < 2)\\ &=\int_0^{8}f(x)\; dx - \int_0^{2}f(x)\; dx\\ &= 0.0081 -0\\ &=0.0081 \end{aligned}

b. Let the $90^{th}$ percentile be $Q$.

 \begin{aligned} & P(X < Q) = 0.9\\ \Rightarrow &\int_0^{Q}f(x)\; dx=0.9\\ \Rightarrow &Q= 28.412 \end{aligned}

Thus $90^{th}$ percentile of the given gamma distribution is 28.412.

## Gamma Distribution Example 2

If a random variable $X$ has a gamma distribution with $\alpha=4.0$ and $\beta=3.0$, find $P(5.3 < X < 10.2)$.

#### Solution

Given that $X\sim G(4,3)$ distribution. That is $\alpha= 4$ and $\beta=3$.

The probability density function of $X$ is

 \begin{aligned} f(x;\alpha,\beta)&= \frac{1}{\beta^\alpha \Gamma(\alpha)} x^{\alpha -1}e^{-\frac{x}{\beta}}, x>0;\alpha, \beta >0 \\ &= \frac{1}{3^{4} \Gamma(4)} x^{4 -1}e^{-\frac{x}{3}}, x>0 \end{aligned}

The probability that $5.3 < X < 10.2$ is

 \begin{aligned} P(5.3 < X < 10.2) &= P(X < 10.2) - P(X < 5.3)\\ &=\int_0^{10.2}f(x)\; dx - \int_0^{5.3}f(x)\; dx\\ &= 0.4416 -0.1034\\ &=0.3382 \end{aligned}

## Gamma Distribution Example 3

Let $X$ have a standard gamma distribution with $\alpha=3$. Find

a. $P(2\leq X \leq 6)$
b. $P(X>8)$
c. $P(X\leq 6)$

#### Solution

Given that $X\sim G(3,1)$ distribution, which is a standard gamma distribution. That is $\alpha= 3$ and $\beta=1$.

The probability density function of $X$ is

 \begin{aligned} f(x;\alpha,\beta)&= \frac{1}{\beta^\alpha \Gamma(\alpha)} x^{\alpha -1}e^{-\frac{x}{\beta}}, x>0;\alpha, \beta >0 \\ &= \frac{1}{1^{3} \Gamma(3)} x^{3 -1}e^{-\frac{x}{1}}, x>0 \end{aligned}

a. The probability that $2 < X < 6$ is

 \begin{aligned} P(2 < X < 6) &= P(X < 6) - P(X < 2)\\ &=\int_0^{6}f(x)\; dx-\int_0^{2}f(x)\; dx\\ &= 0.938 -0.3233\\ &=0.6147 \end{aligned}

b. The probability that $X > 8$ is

 \begin{aligned} P(X > 8) &= 1- P(X \leq 8)\\ &=1- \int_0^{8}f(x)\; dx\\ &= 1-0.9862\\ &=0.0138 \end{aligned}

c. The probability that $X \leq 6$ is

 \begin{aligned} P(X \leq 6)&= \int_{0}^{6} f(x)\; dx\\ &=0.938 \end{aligned}

## Gamma Distribution Example 4

Time spend on the internet follows a gamma distribution is a gamma distribution with mean 24 $min$ and variance 78 $min^2$.

Find the

a. parameters of gamma distribution,
c. probability that time spend on the internet is between 22 to 38 minutes,
b. probability that time spend on the internet is less than 28 minutes.

#### Solution

Let $X$ be the time spend on the internet. Given that $X\sim G(\alpha, \beta)$. The mean of $G(\alpha,\beta)$ distribution is $\alpha\beta$ and the variance is $\alpha\beta^2$.

Given that $mean =\alpha\beta=24$ and $V(X)=\alpha\beta^2=78$.

a. Thus $\beta=\frac{78}{24}=3.25$ and $\alpha = 24/3.25= 7.38$ (rounded to two decimal)

The probability density function of $X$ is

 \begin{aligned} f(x;\alpha,\beta)&= \frac{1}{\beta^\alpha \Gamma(\alpha)} x^{\alpha -1}e^{-\frac{x}{\beta}}, x>0;\alpha, \beta >0 \\ &= \frac{1}{3.25^{7.38} \Gamma(7.38)} x^{7.38 -1}e^{-\frac{x}{3.25}}, x>0 \end{aligned}

b. The probability that $22 < X < 38$ is

 \begin{aligned} P(22 < X < 38) &= P(X < 38) - P(X < 22)\\ &=\int_0^{38}f(x)\; dx-\int_0^{22}f(x)\; dx\\ &= 0.9295 -0.4572\\ &=0.4722 \end{aligned}

b. The probability that $X < 28$ is

 \begin{aligned} P(X < 28) &=\int_0^{28}f(x)\; dx\\ &= 0.7099 \end{aligned}

## Conclusion

In this tutorial, you learned about how to calculate probabilities of Gamma distribution. You also learned about how to solve numerical problems based on Gamma distribution.

To read more about the step by step tutorial on Gamma distribution refer the link Gamma Distribution. This tutorial will help you to understand Gamma distribution and you will learn how to derive mean, variance, moment generating function of Gamma distribution and other properties of Gamma distribution.