# 補充:Exponential Distribution
## random varaible W
### 定義
在談 (approximate) Poisson distribution 時,我們是在計算在一個 given interval 中,++event 發生的次數++。這個情況下,對應的 random variable 是 ++discrete++ 的(因為次數的計算並非 continuous,而是 $\mathbb{Z^+} \cup \{0\}$)。
> 關於 Poisson distribution 的相關內容,可參考前面的筆記「補充:Poisson Distribution」
但是在一個 Poisson process 中,不只次數的計算是一個 random variable,在 (event 的)++occurences 之間的 waiting times++ 也是一種 random variable,而且因為 wating time 的值可以是任何正數,所以是 ++continuous++ 的。
假設我們令:
:::info
- ==$W$==:在一個 Poisson process 的 observation 中,++從開始到第一個 occurence 之間的 waiting time++。
> $\rightarrow W$:continuous random variable
- ==$\lambda$==: unit interaval 中 event 平均的發生次數。
> 在談 exponential distribution 時,我們通常把 $\lambda$ 稱作 <font color = "blue">rate parameter</font>
:::
接著,我們就要去找出 $W$ 的 cdf (cumulative distribution function $F(·)$)
> Recall: cdf $F(a) = P\{X \le a\}$
>
> $\rightarrow$ 可參考筆記「A.2.1 Probability Distribution and Density Functions」
### cdf, pdf
首先,因為 waiting time 必為 nonnegative,所以當 $w < 0$ 時,$F(w) = 0$。
> 也就是 waiting time $<0$ 的機率為零。
如果 $w \ge 0$ 的話:

> 在第二行的地方,我們將對 waiting time $>w$ 機率的計算轉換為前面提到的,對 Poisson process 中 event 發生次數的計算。
>
> 因此可用發生次數的 pmf 來接著算出第三行在 interval $=w$ 時,沒有 event 發生的機率:
>
> 
有了 cdf 以後,我們對 cdf $F(·)$ 微分來得到 pdf $f(·)$:

## exponential distribution
有了上面求得的 $W$ 的 pdf 以後,因為我們通常會令:
\begin{equation}
\lambda = \frac{1}{\theta}
\end{equation}
替換原 pdf 得到:

於是我們給出 exponential distribution 的正式定義:
:::info
我們說一個 random variable $X$ 是 <font color = "blue">exponential distribution</font>,若它的 pdf 定義為:
\begin{equation}
f(x) = \frac{1}{\theta}e^{-\frac{x}{\theta}} \qquad 0 \le x < \infty
\end{equation}
其中 parameter $\theta > 0$
:::
因此,我們也可以說代表「waiting time until first occurence」的 random variable $W$ 具有 exponential distribution with $\theta = \frac{1}{\lambda}$。
### 特性: mean, variance
先說結論:
:::success
exponential distribution 的 mean 和 variance 為:
\begin{equation}
\mu = \theta \qquad \sigma^2 = \theta^2
\end{equation}
:::
推導過程如在推導 Poisson distribution 一樣,要利用到 mgf,過程如下:
> 關於 mgf 的內容,可參考筆記 $A.3$ 部分的「補充:moment generating function (mgf)」

求出 mgf $M(t)$ 以後,再微分一次、兩次取 $t=0$ 時的值來求 mean、variance:

### 例子
從上面的內容,我們可以得到結論:
:::warning
如果 $\lambda$ 是 mean number of occurences in unit interval
則 $\theta = \frac{1}{\lambda}$ 為 mean waiting time for the first occurence
:::
像是如果我們的 $\lambda = 7$,unit interval 為一分鐘(即一分鐘內 event 會發生七次),則平均來說我們要等 $\frac{1}{7}$ 分鐘才會等到 first occurence。
> 我們得到的這個結果也是很符合直覺的。
再舉一個例子:

# 參考資料
- Hogg,Tanis,Zimmerman, Probability and Statistical Inference, 9th ed(2015), p.95-96
> 對應 $3.2$ 小節 the Exponential, Gamma, and Chi-Square Distributions 的最前部分。