# 各 Distribution 的筆記 #### 先備知識: * $\mu = np$ * $\sigma^2 = np(1-p)$ * $Var(x) = E(x^2) - (E(x))^2$ ## Binomial Distribution : 1. 分成 a 個 1 (成功), b 個 0 (失敗) $\Longrightarrow$ * pmf : $(\cfrac{a}{a+b})^x (\cfrac{b}{a+b})^{1-x}, x = 0,1$ * mean $(\mu)$ : p $\Rightarrow$ 1 發生的機率 * $\sigma^2 : p(1-p)$ 2. 有 m 個達成, t 為總數, p 為達成的機率 : $C^t_m p^m (1-p)^{t-m}$ 3. t 為總數, p 為成功機率 : $P(x\le k) : \Sigma^k_{x=0}C^t_x(p)^x(1-p)^{t-x}$ $if\ P(x\ge L) = 1 - P(x \le L-1)$ ## Negative Binomial Distribution : 1. 令 n = 次數, p = 機率 $\Longrightarrow$ * $mean (\mu)$ : $n/p$ * $\sigma^2 : \cfrac{n \cdot (1-p)}{p^2}$ 2. $E(x^r) = k^r, \ r = 1, 2, 3 \Longrightarrow$ * $M(t) = e^k$ * pmf : $f(k) = 1$ 3. $f(x) : C^{x-1}_{n-1} p^n (1-p)^{x-n}$ 4. to get every probability : 令每個獨立機率為 p (此範例假設 p = 1/6) $\Longrightarrow$ $\cfrac{6}{1}+\cfrac{6}{2}+\cfrac{6}{3}+\cfrac{6}{4}+\cfrac{6}{5}+\cfrac{6}{6}$ 而當今天 p = 1/4 時 $\Longrightarrow$ $\cfrac{4}{1}+\cfrac{4}{2}+\cfrac{4}{3}+\cfrac{4}{4}$ ## Poisson Distribution : 1. $f(x) = \cfrac{\lambda^x \cdot e^{-\lambda}}{x!}$ $\mu = \sigma^2 = \lambda$ $\Longrightarrow if \ 我們要求出 :$ - $\ P(k_1 \le x \le k_2) : 這會等同於 \ P(x = k_1) \ + \ ... \ + \ P(x = k_2) \ 或是可以用查表的[用P(k_2)-P(k_1)]$ - $P(x \ge k) = 1 - (P(x=1)+...+P(x=k)) \ 或是可以用查表的[用1-P(x \le k)]$ 2. tips : 重點要找出 $\mu$ 可以等於 $n \times p$ 或是 $\cfrac{n_1}{n_2}$ 然後 $Var(x) = E(x^2)-(E(x))^2$ 3. 有點難的進階 : 求出 expected value 可以先分成 \begin{cases} x = 0 \Rightarrow 0 \times P(x=0) \\ ... \\ ... \\ ... \\ x = n \Rightarrow n \times[P(x=n)-P(x=n-1)] \end{cases} 最後把全部的值相加,或是可以用 $0 \times f(0) + 1 \times f(1) + ... + n \times \{ 1-f((n-1) + (n-2) + ... + 1) \}$ ## **以上皆為 Discrete Distribution** --- ## **以下皆為 Continuous Distribution** 這裡是一些小重點 1. period : $n \Rightarrow X = U(\underbrace{0,n}_{\color{orange}{a,b}})$ $\Rightarrow pdf : f(x) = \cfrac{1}{n}$ $P(X \ge k) = \int^n_k f(x)dx$ $P(k_1 \le x \le k_2) = \int^{k_2}_{k_1} f(x)dx$ $E(x) = \cfrac{a+b}{2},\ Var(x) = \cfrac{(b-a)^2}{12}$ 2. $pdf \xrightarrow{積分} cdf$ eg. $f(x) = 4x^c,\ 0 \le x \le 1$ $cdf = 1 \Rightarrow \int^1_0 4x^c dx = (\cfrac{4}{c+1}x^{c+1})^1_0 = \cfrac{4}{c+1} = 1$ $\therefore c= 3 \Rightarrow cdf = F(x) = x^4,\ 0 \le x \le 1$ $E(x) = \int^1_0 x \times 4x^3 dx = \cfrac{4}{5}$ $\sigma^2(x) = E(x^2)-(E(x))^2 = \int^1_0x^2 \times 4x^3 dx - (\cfrac{4}{5})^2 = \cfrac{2}{75}$ ${\color{red}{\star \ E(x) = \int x f(x)dx}}$ ${\color{red}{\star \ E(x^2) = \int x^2 f(x)dx}}$ 3. $P(0 \le x \le k) = F(k)$ $P(k_1 \le x \le k_2) = F(k_2)-F(k_1)$ $P(x = k) = P(k \le x \le k) = 0$ $P(x \ge k) = 1 - F(k)$ $\star P(x \ge k_1 | x \ge k_2) = \cfrac{P(x \ge k_1)}{P(x \ge k_2)}$ ## Uniform Distribution 1. $pmf : f(x) = \cfrac{1}{b-a},\ a \le x \le b$ 2. $mgf : M(0) = 1$ ## Exponential Distribution : 1. $f(x) = \cfrac{1}{\theta} \cdot e^{{-x}/{\theta}}$ $\mu = \theta, \ \sigma^2 = \theta^2$ 2. $M(t) = \cfrac{1}{1-\theta t},\ t < \cfrac{1}{\theta}$ 3. $F(x) = 1 - e^{-x/ \theta}$ $\therefore P(x<n) = 1 - e^{(-n{\color{blue}{+k}})/\theta} \Longrightarrow \mu = \theta {\color{blue}{+k}},\ \sigma^2 = \theta^2,\ ({\color{red}{r = \alpha \theta}})$ $M(t) = (1-kt)^{-n} \Rightarrow \theta = k,\ \alpha = n$ $\Longrightarrow \mu = \alpha \theta,\ \sigma^2 = \alpha \theta^2$ ## Gamma Distribution : 1. $f(x) = \cfrac{x^{\alpha-1} \cdot e^{-x/\theta}}{(\alpha -1)! \cdot \theta^{\alpha}},\ 0<x<\infty$ $\mu = \alpha \theta, \ \sigma^2 = \alpha \theta^2$ 2. 變形題 : $令u = x-k....,\ du = dx....$ ## Chi-Square Distribution : 1. 等同於 **gamma 分配**,只是把 $\theta$ 代入 $2$,把 $\alpha$ 代入 $r/2$,因為 $r=\alpha \theta$ 2. at most n of t $C^t_0(p)^0(1-p)^t+C^t_1(p)^1(1-p)^{t-1}+...+C^t_n(p)^n(1-p)^{t-n}$ ## Normal Distribution : 1. $f(x) = \cfrac{1}{\sigma \cdot \sqrt{2\pi}} \cdot e^{-(x-\mu)^2/2 \sigma^2}$ $\mu = \mu, \ \sigma = \sigma$ 2. 上述公式是用在 $x$ 在 $N(0, \sigma^2)$ 的情況下 而當今天 $Z$ 在 $N(0, 1)$ 的情況時我們就可以透過查表快速求解,$Z$ 是經過標準化之後的結果 ($Z = \cfrac{x-\mu}{\sigma}$) 查表的方式是藉由 $P(0 \le Z \le k )$ 查表中的 $k$ 值 3. $P(n_1 \le x \le n_2)$ $\Rightarrow P(\underbrace{\cfrac{n_1-\mu}{\sigma}}_{令\ k_1} \le \cfrac{x-\mu}{\sigma} \le \underbrace{\cfrac{n_2-\mu}{\sigma}}_{令\ k_2})$ 查表時只需查出 $k_1$ 以及 $k_2$ 的值來計算 4. 超級難的補充 : 用 normal 分配找出其他的分配(下方是舉例) $N(0,\sigma^2)$ $f(x) = \cfrac{1}{\sigma \sqrt{2\pi}} \cdot e^{-x^2/2 \sigma^2}$ $F_w(w) = P(W \le w) = P(X^2 \le w)$ $= P(-\sqrt{w} \le x \le \sqrt{w})$ $= 2 \times \int^{\sqrt{w}}_{0} \cfrac{1}{\sigma \sqrt{2\pi}} \cdot e^{-x^2/2 \sigma^2} dx$ 再來運用變數代換 $令x^2 = y,\ 2xdx = dy$ $\therefore \ x=\sqrt{y},\ dx = \cfrac{1}{2x}dy$ $\Longrightarrow = \int^{w}_{0}\cfrac{1}{\sigma \sqrt{2\pi}}\cdot e^{-y/2 \sigma^2} \cdot \cfrac{1}{\sqrt{y}} dy$ $= \int^{w}_{0}\cfrac{y^{(1/2)-1}}{\sqrt{\pi}\sqrt{2\sigma^2}}\cdot e^{-y/2 \sigma^2} dy$ $= \int^{w}_{0}\cfrac{y^{(1/2)-1} \cdot e^{-y/2 \sigma^2}}{\Gamma(\cfrac{1}{2})(2\sigma^2)^{1/2}}dy$ $\Longrightarrow Gamma:\alpha = \cfrac{1}{2},\ \theta = 8$ $(Gamma : \cfrac{x^{\alpha-1} \cdot e^{-\theta x}}{\Gamma(\alpha)\cdot \theta^\alpha})$ ## 補充 : pdf 積分之後會獲得 cdf $cdf = F(x) = \int f(x)dx$ $\Longrightarrow E(x) = \int x \cdot f(x) dx$ $\ \ \ \ \ \ \ E(x^2) = \int x^2 \cdot f(x) dx$ $\Longrightarrow \sigma^2 = E(x^2) - (E(x))^2$ 另外,如果要求 n 次內,總共有 t 次,則會用到這個公式 : $\Rightarrow C^t_0(p)^0(1-p)^t+...+C^t_n(p)^n(1-p)^{t-n}$