---
description: 伽马分布
---

# 5-5. Gamma Distribution (\*)

{% embed url="https://www.probabilitycourse.com/chapter4/4_2_4_Gamma_distribution.php" %}

{% embed url="https://www.statisticshowto.datasciencecentral.com/gamma-distribution/" %}

The gamma distribution is another widely used distribution. Its importance is largely due to its relation to exponential and normal distributions. Here, we will provide an introduction to the gamma distribution.

The gamma distribution is a family of [right-skewed](https://www.statisticshowto.datasciencecentral.com/probability-and-statistics/skewed-distribution/#SkewRight), [continuous probability distributions](https://www.statisticshowto.datasciencecentral.com/continuous-probability-distribution/). These distributions are useful in real-life where something has a natural minimum of 0. For example, it is commonly used in _finance_, for **elapsed times**, or during [Poisson processes](https://www.statisticshowto.datasciencecentral.com/exponential-distribution/#poisson).



## 1. Gamma Function

Before introducing the gamma random variable, we need to introduce the gamma function.

> **Gamma Function :** $$\Gamma (\alpha ) \equiv  \int_{0}^{\infty }x^{\alpha -1}e^{-x}dx$$&#x20;
>
> \==>  $$\Gamma (\alpha ) = \left [ -y^{\alpha -1} e^{-y} \right ]_{0}^{\infty } + (\alpha -1)\int_{0}^{\infty }y^{\alpha -2}e^{-y}dy=(\alpha -1)\Gamma (\alpha -1)^{} .$$&#x20;
>
> * $$\Gamma (1) = \int_{0}^{\infty }x^{1 -1}e^{-x}dx= 1.$$ &#x20;
> * If $$\alpha$$ is an integer $$n,$$ $$\Gamma (n ) = (n -1)\Gamma (n -1) = \cdots = (n -1)(n-2)\cdots \times 2\times 1 = (n-1)!$$&#x20;



The following figure shows the gamma function for positive real values.\


![](https://www.probabilitycourse.com/images/chapter4/gamma-function-color.png)



### 1.1 Properties of the gamma function

For any positive real number $$α$$ :

1. &#x20;$$\Gamma(\alpha )=  \int_{0}^{\infty } x^{_{\alpha -1}} e^{-x}dx$$&#x20;
2. &#x20;$$\int_{0}^{\infty } x^{_{\alpha -1}} e^{-\lambda x}dx = \frac{\Gamma(\alpha )} {\lambda^\alpha}$$,    for $$λ>0;$$&#x20;
3. &#x20;$$Γ(α+1)=αΓ(α);$$&#x20;
4. &#x20;$$Γ(n)=(n−1)!$$ ,  for  $$n=1,2,3,⋯;$$&#x20;
5. &#x20;$$Γ(\frac{1}{2})= \sqrt{π}$$ .



**EXAMPLE 26.**  Answer the following questions:

1. Find $$Γ(\frac{7}{2}).$$&#x20;
2. Find the value of the following integral:\
   &#x20;$$I = \int_{0}^{\infty } x^{6} e^{-5}dx$$&#x20;

**\[ Solution ]**

1. &#x20;$$Γ(\frac{7}{2})$$ $$= \frac{5}{2} \times Γ(\frac{5}{2})$$ (using Property 3) \
   &#x20;             $$= \frac{5}{2} \times \frac{3}{2} \times Γ(\frac{3}{2})$$ (using Property 3)\
   &#x20;             $$= \frac{5}{2} \times \frac{3}{2} \times \frac{1}{2} \times Γ(\frac{1}{2})$$ (using Property 3)\
   &#x20;             $$= \frac{5}{2} \times \frac{3}{2} \times \frac{1}{2} \times \sqrt {\pi}$$ (using Property 5)\
   &#x20;             $$= \frac{15}{8} \times \sqrt {\pi}$$\

2. (Using Property 2) with $$α=7$$ and $$λ=5$$ , we obtain\
   &#x20;$$I = \int_{0}^{\infty } x^{6} e^{-5}dx =  \frac{\Gamma(7 )} {5^7} =  \frac{6!} {5^7} \approx 0.0092$$&#x20;



## 2. Gamma Distribution

In $$\Gamma(\alpha )=  \int_{0}^{\infty } x^{_{\alpha -1}} e^{-x}dx$$ ,

for random variable $$X=x,$$&#x20;

$$\Gamma(\alpha )=  \int_{0}^{\infty } x^{_{\alpha -1}} e^{-x}dx$$ => $$1=  \int_{0}^{\infty } \frac{1}{\Gamma(\alpha )} x^{_{\alpha -1}} e^{-x}dx$$

$$\therefore f(x) = \frac{1}{\Gamma(\alpha )} x^{_{\alpha -1}} e^{-x}$$ is the pdf of $$X ∼ Gamma(\alpha, 1)$$ .&#x20;



> **Gamma Distribution**
>
> &#x20;        $$f(x) = \frac{1}{\theta ^\alpha \Gamma (\alpha )}x^{\alpha -1}e^{-x / \theta},$$   $$x > 0;$$   $$\alpha, \theta >0$$&#x20;
>
> where $$\alpha$$ is the _**shape parameter**_ which forms the shape of the distribution, and $$\theta$$  is the [_rate parameter_](https://www.statisticshowto.datasciencecentral.com/rate-parameter/) (the reciprocal of the [_**scale parameter**_](https://www.statisticshowto.datasciencecentral.com/scale-parameter/) $$\lambda$$ ).&#x20;



If  $$\alpha = 1$$,  $$f(x) = \frac{1}{\theta \Gamma (1)}x^{1 -1}e^{-x / \theta} = (\frac{1}{\theta})e^{-x (\frac{1}{\theta})}$$which is the **exponential distribution** with $$\lambda = \frac {1}{\theta}$$.



> A continuous random variable X is said to have a **gamma distribution** with parameters $$α>0$$ and $$λ>0$$ , shown as $$X∼Gamma(α,λ)$$ , if its PDF is given by&#x20;
>
> &#x20;    $$f_X(x) = \left\{ 						\begin{array}{l l} 						\frac{\lambda^{\alpha} x^{\alpha-1} e^{-\lambda x}}{\Gamma(\alpha)} \hspace {5pt} x > 0\\ 						0 \hspace{56pt} \textrm{otherwise} 						\end{array}\right.$$&#x20;



### **2.1 Relationship between Gamma Distribution and Exponential Distribution**

> If we let $$α=1$$ , we obtain
>
> &#x20;      $$f_X(x) = \left\{ 					\begin{array}{l l} 					\lambda e^{-\lambda x} \hspace{20pt} x > 0\\ 					0 \hspace{41pt} \textrm{otherwise} 					\end{array}\right.$$ &#x20;
>
> Thus, we conclude $$Gamma(1,λ)=Exponential(λ)$$ .&#x20;

More generally, if you sum $$n$$ identical independent Exponential($$λ$$) random variables, then you will get a $$Gamma(n,λ)$$ random variable. (We will prove this later on using the moment generating function.)&#x20;

> If$$X_1, X_2, \cdots , X_n$$   $$\widetilde{iid}$$    $$Exp(\lambda \equiv 1/\theta )$$ , $$\sum_{i=1}^{n}X_i \sim \Gamma (n, \theta ).$$&#x20;



The gamma distribution is also related to the normal distribution as will be discussed later. Figure 4.10 shows the PDF of the gamma distribution for several values of $$α$$ .

![PDF of Gamma Distribution for Some Values of α and  λ. ](https://www.probabilitycourse.com/images/chapter4/gamma-color.png)



**EXAMPLE 27.** Using the properties of the gamma function, show that the gamma PDF integrates to 1, i.e., show that for $$α$$ , $$λ>0$$ , we have&#x20;

&#x20;                                         $$\int_0^\infty \frac{\lambda^{\alpha}x^{\alpha - 1} e^{-\lambda x}}{\Gamma(\alpha)} dx = 1.$$&#x20;

**\[ Solution ]**$$\begin{align*} 										\int_0^\infty \frac{\lambda^{\alpha} x^{\alpha - 1} e^{-\lambda x}}{\Gamma(\alpha)} dx &= 										\frac{\lambda^{\alpha}}{\Gamma(\alpha)} \int_0^\infty x^{\alpha - 1} e^{-\lambda x} dx\\ 										\\ \hspace{20pt} &= \frac{\lambda^{\alpha}}{\Gamma(\alpha)} \cdot \frac{\Gamma(\alpha)}{\lambda^{\alpha}} 										\hspace{20pt} \textrm{(using Property 2 of the gamma function)}\\ 										\\ \hspace{0px} &= 1. 										\end{align*}$$

**감마분포를 간략히 표현하자면** $$α$$ **번째 사건이 일어날 때 까지 걸리는 시간에 대한 연속확률분포이다. 즉, 총** $$α$$**번의 사건이 발생할 때까지 걸린 시간에 대한 확률분포를 보여준다.**&#x20;

여기서 $$\theta$$는 포아송 분포의 모수와 비슷한 역할을 합니다. (감마 분포에서는 $$α$$, $$\theta$$ 둘 다 모수(parameter)라고 부릅니다. 단지 이 둘의 역할이 다를 뿐이죠. $$α$$는 '형태 모수(shape parameter)', $$\theta$$는 '비율 모수(ratio parameter)'라고 한다.)



### 2.2 Expected Value and Variance

> **Expected Value** and **Variance** of Gamma Distribution &#x20;
>
> $$X \sim Gamma(\alpha,  \frac{1}{ \theta } )$$
>
> $$E(X) = \alpha \theta,$$    $$Var(X) = \alpha \theta^2$$ .
>
> Or
>
> $$X \sim Gamma(\alpha,\lambda)$$ **;**
>
> $$E(X) = \frac{\alpha}{ \lambda},$$    $$Var(X) =\frac{\alpha}{ \lambda ^2}$$ .



**EXAMPLE 28.** $$\theta =1$$ 일 때, $$\alpha = 0.5, 1, 2, 3$$ 인 감마분포의 확률밀도함수와 누적분포함수를 그래프로 작성하시오.

**\[ Solution ]**

{% tabs %}
{% tab title="R Source" %}
```
library(Rstat)

# set the parameter, run the function
alp <- c(0.5, 1:3); rate <- 1
cont.mpdf("gamma", 0,8, para=alp, para2=rate, ymax=1.2)
```
{% endtab %}

{% tab title="Prob. Density Function" %}
![](https://2234305379-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lqmt1Wp54aKlZ5eVcaS%2F-LtCWKK7ghP06l2SWFBz%2F-LtCWpSRMBOBf4KoXhoe%2Fimage.png?alt=media\&token=ab6022f3-42e6-4b57-b6d4-debd8f1074f5)
{% endtab %}
{% endtabs %}



**EXAMPLE 29.** 어떤 전동안마기의 수명이 평균 10년, 분산 50인 감마분포를 따를 때, 다음을 구하시오.

1. 이 전동안마가 3년간 고장 없이 작동할 확률
2. 이 전동안마가 8년간 고장 없이 작동할 확률
3. 5년간 고장이 없었을 때, 앞으로 3년 더 고장 없이 작동할 확률

**\[ Solution ]**

$$E(X) = \alpha \theta = 10,$$   $$Var(X) = \alpha \theta^2 = 50,$$   ==>  $$\alpha =2,  \theta = 5.$$&#x20;

1. $$P(X>3) = \frac{1}{5^2 \Gamma(2)}\int_{3}^{\infty }x^{2-1}e^{-x/5}dx = \frac{1}{25}\int_{3}^{\infty }xe^{-x/5}dx$$ \
   &#x20;                     $$= \frac{1}{25} \{ \left [ -5xe^{-x/5} \right ]_{3}^{8 } + \int_{3}^{\infty }5e^{-x/5}dx \}$$ \
   &#x20;                     $$= \frac{1}{25} \{ 15e^{-3/5} + \left [ -25e^{-x/5} \right ]_{3}^{ \infty} \} = (\frac{3}{5} + 1) e^{-\frac{3}{5}} \approx 0.8781$$    &#x20;
2. $$P(X>8) = (\frac{8}{5} + 1) e^{-\frac{8}{5}} \approx 0.5249$$&#x20;
3. $$P(X>5+3 | X>5) = \frac{P(X>8)}{P(X>5)}.$$ \
   &#x20;    $$P(X>5) =  (\frac{5}{5} + 1) e^{-\frac{5}{5}} \approx  0.7358$$ \
   &#x20;    $$P(X>5+3 | X>5) = \frac{0.5249}{0.7358} \approx 0.7134.$$&#x20;

{% tabs %}
{% tab title="R Source" %}
```
library(Rstat)

EX <- 10; VX <- 50
alp <- EX^2/VX ; th <- EX / alp

# 1. P(X>3)
pgamma(3, apl, 1/th, lower=FALSE)

# 2. P(X>8)
pgamma(8, apl, 1/th, lower=FALSE)

# 3. P(X>5+3 | X>5) = P(X>8) / P(X>5)
pgamma(8, apl, 1/th, lower=FALSE) / pgamma(5, apl, 1/th, lower=FALSE)
```
{% endtab %}

{% tab title="1. P(X>3)" %}
```
> # 1. P(X>3)
> pgamma(3, alp, 1/th, lower=FALSE)
## [1] 0.8780986
```
{% endtab %}

{% tab title="2. P(X>8)" %}
```
> # 2. P(X>8)
> pgamma(8, alp, 1/th, lower=FALSE)
## [1] 0.5249309
```
{% endtab %}

{% tab title="3. P(X>5+3 | X>5)" %}
```
> # 3. P(X>5+3 | X>5) = P(X>8) / P(X>5)
> pgamma(8, alp, 1/th, lower=FALSE) / pgamma(5, alp, 1/th, lower=FALSE)
## [1] 0.7134551
```
{% endtab %}
{% endtabs %}
