# 古典概型

$\Omega = \{w_1,w_2,...,w_N\}$

$P(A) = \frac{N(A)}{N}$

## 排列数与组合数

$(n)_k = n(n-1)(n-2)...(n-k+1) = \frac{n!}{(n-k)!}$

$(k)_k = k(k-1)...1 = k!$
$n$个元素中抽出$k$个元素的所有可能的抽法数量是组合数$C_n^k$
$C_n^k = \frac{(n)_k}{k!} = \frac{n!}{(n-k)!k!}$

$C_n^{n-1} = C_n^1 = n \\ C_n^{k} = C_n^{n-k}$

$kC_n^k = nC_{n-1}^{k-1} \\ C_n^k = C_{n-1}^{k-1} + C_{n-1}^{k} (杨辉三角，Pascal\ Triangle)$

$n! \approx \sqrt{2\pi} n^{n+1/2}e^{-n}$

## 二项式定理，负二项式定理与多项式定理

$(x+y)^n = \sum_{k=0}^{n} C_n^k x^{n-k}y^k = \sum_{k=0}^{\infty} C_n^k x^{n-k}y^k$

$(x+y)^{-r} = \frac{1}{x^r}(1+\frac{y}{x})^{-r} = \frac{1}{x^r} \sum_{k=0}^{\infty} C_{-r}^k (\frac{y}{x})^k = \sum_{k=0}^{\infty} C_{-r}^k x^{-r-k}y^k$

$C_{-r}^{k} = (-1)^kC_{r+k-1}^{k}$

$(x_1+x_2+...+x_r)^n$

$n_1+n_2+...+n_r = n$

$C_n^{n_1} C_n^{n-n_1} C_n^{n-n_1-n_2} ... C_n^{n_r} = \frac{n!}{n_1!n_2!...n_r!}$

$(x_1+x_2+...+x_r)^n = \sum_{n_1+n_2 + ... +n_r=n} \frac{n!}{n_1!n_2!...n_r!} x_1^{n_1}x_2^{n_2}...x_r^{n_r}$

## 第二类Stirling数

$S_2(n,1) = S_2(n,n)=1 \\ S_2(n,0) = S_2(0,n) = 0$
$n$个物品放进$n-1$个非空的盒子里，相当于从$n$个物品中抽出两个放入同一个盒子，再将剩下的每个球单独放入一个盒子里，因此
$S_2(n,n-1) = C_n^2$

$S_2(n+1,k) = kS_2(n,k) + S_2(n,k-1)$

$x^n = \sum_{k=1}^n S_2(n,k) (x)_k$

# 独立性与条件概率

$P(A\cap B) = P(A)P(B)$

$P(A|B) = \frac{N(A\cap B)}{N(B)} = \frac{P(A\cap B)}{P(B)}$

## 全概率公式

$\Omega = \bigsqcup_{i=1}^{m} D_i$

$A = \bigsqcup_{i=1}^{m} A \cap D_i$

$N(A) = \sum_{i=1}^{m} N(A \cap D_i)$

$P(A) = \sum_{i=1}^{m} P(A \cap D_i)$

## 贝叶斯公式

$P(D_k |A) = \frac{P(A \cap D_k)}{P(A)}$

$P(D_k |A) = \frac{P(A \cap D_k)}{\sum_{i=1}^{m} P(A \cap D_i)}$

$P(A|D_k) = \frac{P(A \cap D_k)}{P(D_k)}$

$P(D_k |A) = \frac{P(A | D_k)P(D_k)}{\sum_{i=1}^{m} P(A | D_i)P(D_i)}$

# Bernoulli试验与二项分布

Bernoulli试验（Bernoulli trials）指的是试验结果只有成功或者失败的试验，假设随机变量$X_i,i=1,2,...,n$代表第$i$次独立重复Bernoulli试验的结果，$X_i=1$代表试验成功，$X_i=0$代表试验失败，$p=P(X_i=1)$是成功概率。有两个比较常用的结果
$EX_i = p \\ Var(X_i) = p(1-p)^2 + (1-p)(0-p)^2 = p(1-p)$

$P(Y=k) = C_n^k p^k(1-p)^{n-k}$

$\sum_{k=0}^{n} P(Y=k) = \sum_{k=0}^{n} C_n^k p^k(1-p)^{n-k} = (1-p+p)^n = 1$

$EY = \sum_{k=0}^{n} kP(Y=k) = \sum_{k=0}^{n} kC_n^k p^k(1-p)^{n-k}$

$EY = \sum_{k=0}^{n} nC_{n-1}^{k-1} p^k(1-p)^{n-k} = np \sum_{k=1}^{n} C_{n-1}^{k-1} p^{k-1}(1-p)^{(n-1)-(k-1)} \\ = np \sum_{k=0}^{n-1} C_{n-1}^k p^k(1-p)^{(n-1)-k} = np$
$EY^2 = \sum_{k=0}^{n} k^2P(Y=k) = \sum_{k=0}^{n} k^2C_n^k p^k(1-p)^{n-k} \\ =np \sum_{k=0}^{n-1} (k+1)C_{n-1}^k p^k(1-p)^{(n-1)-k} \\=np \sum_{k=0}^{n-1} kC_{n-1}^k p^k(1-p)^{(n-1)-k} + np \\ = np \sum_{k=0}^{n-1} (n-1)C_{n-2}^{k-1} p^k(1-p)^{(n-1)-k} + np \\ = n(n-1)p^2 + np$
$Var(Y) = EY^2 - (EY)^2 = np(1-p)$

$M_Y(t) = E(e^{tY}) = \sum_{k=0}^{n} e^{tk} C_n^k p^k(1-p)^{n-k} \\ = \sum_{k=0}^{n} C_n^k (pe^t)^k(1-p)^{n-k} = (1-p+pe^t)^n$

# Poisson分布

$P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}$

$\sum_{k=0}^{\infty} P(X=k) = \sum_{k=0}^{\infty}\frac{\lambda^k e^{-\lambda}}{k!}=e^{-\lambda}e^{\lambda} = 1$

$P(Y=k) = C_n^k p^k(1-p)^{n-k} = \frac{n!}{(n-k)!k!} p^k(1-p)^{n-k} \\ \to \frac{\sqrt{2\pi} n^{n+1/2}e^{-n}}{\sqrt{2\pi} (n-k)^{n-k+1/2}e^{-n+k}k!} p^k(1-p)^{n-k} \\ \to \frac{(np)^ke^{-\lambda}}{k!} (\frac{n}{n-k})^{n-k+1/2}e^{-k} \\ \to \frac{\lambda^ke^{-\lambda}}{k!} (1+\frac{k}{n-k})^{n-k+1/2}e^{-k} \\ \to \frac{\lambda^ke^{-\lambda}}{k!}$

$(1+a_k)^{c_k} \to e^{\lambda}$
Poisson分布一般用于记录单位时间内随机事件发生的次数，$\lambda$的含义是事件发生的平均速率或者称为强度。

# 几何分布与负二项分布

$P(X=k) = p(1-p)^k$

$\sum_{k=0}^{\infty} P(X=k) = p\sum_{k=0}^{\infty} (1-p)^k = p\frac{1-(1-p)^{\infty}}{1-(1-p)} = 1$

$P(X=k) = C_{-r}^k p^r (1-p)^k = C_{r+k-1}^k p^r (1-p)^k$

$p^{-r} = [1-(1-p)]^{-r} = \sum_{k=0}^{\infty}C_{-r}^k (p-1)^k = \sum_{k=0}^{\infty}C_{r+k-1}^k (1-p)^k$

$\sum_{k=0}^{\infty} P(X=k) = \sum_{k=0}^{\infty} C_{r+k-1}^k p^r (1-p)^k = p^rp^{-r} = 1$

$EX = \sum_{k=0}^{\infty} kP(X=k) = \sum_{k=0}^{\infty} k C_{r+k-1}^k p^r (1-p)^k$

$EX = \sum_{k=0}^{\infty} (r+k-1)C_{r+k-2}^{k-1} p^r (1-p)^k \\=r\sum_{k=0}^{\infty} C_{r+k-2}^{k-1} p^r (1-p)^k + \sum_{k=0}^{\infty} (k-1)C_{r+k-2}^{k-1} p^r (1-p)^k \\ = r(1-p) \sum_{k=0}^{\infty} C_{r+k-1}^{k} p^r (1-p)^k + \sum_{k=0}^{\infty} (r+k-2)C_{r+k-3}^{k-2} p^r (1-p)^k \\ = r(1-p) + r\sum_{k=0}^{\infty} C_{r+k-3}^{k-2} p^r (1-p)^k + \sum_{k=0}^{\infty} (k-2)C_{r+k-3}^{k-2} p^r (1-p)^k \\ = ... \\=r(1-p) + r(1-p)^2 + r(1-p)^3 + ... = \frac{r(1-p)}{p}$

$M_X(t) = E(e^{tY}) = \sum_{k=0}^{n} e^{tk} C_{r+k-1}^k p^r (1-p)^k = (1-p+pe^t)^{-r}$

# 超几何分布

$P(X=k) = \frac{C_{M-N}^{n-k} C_N^k}{C_M^n}$

$C_M^n = \sum_{k=0}^{n} C_{M-N}^{n-k} C_N^k$

$(1+t)^M = \sum_{i=0}^M C_M^i t^i$
$M$写成$M=N+(M-N)$
$(1+t)^M = (1+t)^{N}(1+t)^{M-N} \\ \sum_{i=0}^M C_M^i t^i = (\sum_{i=0}^N C_N^i t^i)(\sum_{i=0}^{M-N} C_{M-N}^i t^i)$

$\sum_{k=0}^{n} C_{M-N}^{n-k} C_N^k$

$\sum_{k=0}^{n} P(X=k) = \sum_{k=0}^{n} \frac{C_{M-N}^{n-k} C_N^k}{C_M^n}= \frac{C_M^n}{C_M^n} = 1$

$EX = \sum_{k=0}^{n} k\frac{C_{M-N}^{n-k} C_N^k}{C_M^n}$

$EX = N \sum_{k=0}^{n} \frac{C_{M-N}^{n-k} C_{N-1}^{k-1}}{C_M^n} = N \sum_{k=0}^{n-1} \frac{C_{M-N}^{(n-1)-k} C_{N-1}^{k}}{C_M^n} \\= \frac{nN}{M}\sum_{k=0}^{n-1} \frac{C_{M-N}^{(n-1)-k} C_{N-1}^{k}}{C_{M-1}^{n-1}} = \frac{nN}{M}$

$EX^2 = \sum_{k=0}^{n} k^2 \frac{C_{M-N}^{n-k} C_N^k}{C_M^n} = N\sum_{k=0}^{n} k \frac{C_{M-N}^{n-k} C_{N-1}^{k-1}}{C_M^n} \\ = N\sum_{k=0}^{n} \frac{C_{M-N}^{n-k} C_{N-1}^{k-1}}{C_M^n} + N\sum_{k=0}^{n} (k-1) \frac{C_{M-N}^{n-k} C_{N-1}^{k-1}}{C_M^n} \\ = \frac{nN}{M} + N(N-1)\sum_{k=0}^{n} \frac{C_{M-N}^{n-k} C_{N-2}^{k-2}}{C_M^n} \\ = \frac{nN}{M} + N(N-1)\sum_{k=0}^{n-2} \frac{C_{M-N}^{(n-2)-k} C_{N-2}^{k}}{C_M^n} \\ = \frac{nN}{M} + \frac{Nn(N-1)(n-1)}{M(M-1)}\sum_{k=0}^{n-2} \frac{C_{M-N}^{(n-2)-k} C_{N-2}^{k}}{C_{M-2}^{n-2}} \\ = \frac{nN}{M} + \frac{Nn(N-1)(n-1)}{M(M-1)}$

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客