# 機率
[YT教學影片](https://www.youtube.com/playlist?list=PLtvno3VRDR_jMAJcNY1n4pnP5kXtPOmVk)
## 1. Probability
- Probability Axioms 公理
- A probability measure P(.) is a function, that maps events into number
- 1.For any event $A\in S$ , $P(A)\ge 0$,
- 2.$P(S)=1$
- 3.Mutually exclusive events, $P(A_1\cup...\cup A_k)=P(A_1)+...+P(A_k)$
- 延伸定理
- 1.$P(A')=1-P(A)$
- 2.$P(\phi)=0$
- 3.如果 $A\subseteq B$,則 $P(A)\le P(B)$
- 4.任意 event A,都有 $0\le P(A)\le 1$
- 5.$P(A\cup B)=P(A)+P(B)-P(A\cap B)$
- 古典機率
- $P(A)=\frac{n(A)}{n(\Omega)}$
- Sampleing
- 
- 條件機率 $P(~\cdot~|B)$
- 定義:$P(A|B)=\frac{P(A\cap B)}{P(B)}~~~當~P(B)>0$
- 滿足三個 Probability Axioms 公理
- 定理:$P(A\cap B)=P(A|B)P(B)=P(B|A)P(A)~~~當~P(A)>0,~P(B)>0$
- 獨立事件
- $P(A\cap B)=P(A)P(B)$
- 等價於 $P(A|B)=P(A)$
- 等價於 $P(B|A)=P(B)$
- 定理:如果 $A$, $B$ 獨立,則
- $A,B'$ 和 $A',B$ 和 $A',B'$ 皆獨立
- 貝式定理
- Partition:彼此互斥,聯集為S的集合
- Law of Total Probability
- $P(A)=P(A|B_1)+P(A|B_2)+...+P(A|B_k)$
- Bayes’ Theorem
- $P(B_1|A)=\frac{P(A|B_1)P(B_1)}{P(A)}=\frac{P(A|B_1)P(B_1)}{P(A|B_1)P(B_1)+P(A|B_2)P(B_2)}$
## 2. Discrete Distributions
- Random Variable:在結果未確定前,有機率便成特定的值
- Countable Infinite:可以一一對應到正整數
- Probability Mass Function (p.m.f.) 機率質量函數
- $P_X(k)=prob(X=k)$
- Cumulative Distribution Function 累積分布函數
- $F_X(x)=P(X\le x)$
- 特殊分布
- Uniform distribution:$f(x)=\frac{1}{b-a}$
- 平均值:$\frac{a+b}{2}$
- 變異數:$\frac{(b-a)^2}{12}$
- Hypergeometric distribution: $f(k,n,m,N)=\frac{\begin{pmatrix}m\\k\end{pmatrix}\begin{pmatrix}N-m\\n-k\end{pmatrix}}{\begin{pmatrix}N\\n\end{pmatrix}}$:
- 樣本:N個中有m個標記。抽樣:抽n個問在有k個標記機率
- 平均值:$\frac{nm}{N}$
- 變異數:$\frac{n(m/N)(1-m/N)(N-n)}{N-1}$
- 期望值 Expectation
- $E[X]=\sum p(x)x$
- 如果 $Y=u(X)$ , 則 $E[Y]=\sum p(y)y=\sum p(x)u(x)$
- 定理:
- 1.$E[c]=c$
- 2.$E[cX]=cE[X]$
- 3.$E[c_1u_1(X)+c_2u_2(X)]=c_1E[u_1(X)]+c_2E[u_2(X)]$
- $E[X]$ 是可以 minimize $E[(X-b)^2]$ 的 b 值
- 變異數 Variance $\sigma^2$
- $E[(X-\mu)^2]=E[X^2]-\mu^2$
- $Y=aX+b$
- $E[Y]=a\mu_X+b$
- $Var[Y]=a^2\sigma^2$
- 標準差 Standard Deviation $\sigma$
- $\sigma=\sqrt{Var(X)}$
- Moment of a Distribution
- $E[(x-b)^k]$: $k^{th}$ moment of the distribution about b
- 特殊分布
- Bernoulli Distribution: $f(x)=p^x(1-p)^{1-x}$
- 平均值:$p$
- 變異數:$p(1-p)$
- Binomial Distribution: $f(x)=\begin{pmatrix}n\\x\end{pmatrix}p^x(1-p)^{n-x}$
- 平均值:$np$
- 變異數:$np(1-p)$
- Negative Binomial Distribution: $f(x)=\begin{pmatrix}x-1\\r-1\end{pmatrix}p^rq^{x-r}$
- 平均值:
- 變異數:
- Geometric Distribution: $f(x)=(1-p)^{x-1}p$
- 平均值:
- 變異數:
- Moment Generating Function
- $M(t)=E[e^{tx}]$
- $M'(0)=E[X]$
- $M''(0)=E[X^2]$
- $M'''(0)=E[X^3]$
- 性質
- $\mu=M'(0)$
- $\sigma^2=M''(0)-M'(0)^2$
- The Poisson Distribution
- 1.change 是 independent 的
- 2.在 h 中發生 1 change 機率是 $\lambda$ h
- 3.在 h 中發生 2 change 以上機率是 0
- $p(x)=\frac{n!}{x!(n-x)!}\begin{pmatrix}\frac{\lambda}{n}\end{pmatrix}^x\begin{pmatrix}1-\frac{\lambda}{n}\end{pmatrix}^{n-x}=\frac{\lambda^xe^{-x}}{x!}$
- 平均值:$\lambda$
- 變異數:$\lambda$
## 3. Continuous Distributions
- Cumulative Distribution Function 累積分布函數
- $F_X(x)=P(X\le x)=\int f_X(u)du$
- Probability Density Function 機率密度函數
- $f_X(x)=\lim\limits_{\Delta x\rightarrow0}\frac{F_X(x+\Delta x)-F_X(x)}{\Delta x}=F'_X(x)$
- 特殊分布
- The Exponential Distribution
- Gamma Distribution
- Chi-Square Distribution
- Standard Normal Distribution: $X$~$N(0,~1)$
- PDF : $f(x)=\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}}$
- CDF : $\phi(x)=\int_{-\infty}^x\frac{1}{\sqrt{2\pi}}e^{-\frac{u^2}{2}}du$
- $\phi(-z)=1-\phi(z)$
- Normal Distribution: $X$~$N(\mu,~\sigma)$
- PDF : $f(x)=\frac{1}{\sqrt{2\pi\sigma}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$
- CDF : $F_X(x) = \phi(\frac{X-\mu}{\sigma})$
- $\frac{X-\mu}{\sigma}$~$N(0,~1)$
## 4. Bivariate Distributions
- Joint Probability Mass Function
- Joint Distribution Function
- Correlation Coefficient
- Conditional Distributions
- Bivariate Normal Distributions
## 5. Distributions of Functions of Random Variables
- Functions of One Random Variable
- Transformations of Two Random Variables
- Central Limit Theorem
- 如果 i.i.d.
- $X_1+X_2+...+X_n$~$N(\mu_{X_1+X_2+...+X_n},~\sigma_{X_1+X_2+...+X_n})$
- $\mu_{X_1+X_2+...+X_n}=\mu_{X_1}+...+\mu_{X_n}=n\mu_{X_1}$
- $\sigma_{X_1+X_2+...+X_n}=\sigma_{X_1}+...+\sigma_{X_1}=n\sigma_{X_1}$