# 多维高斯分布

$N(x|u,\sigma^2)=\frac{1}{\sqrt{2\pi \sigma^2}}exp[-\frac{1}{2\sigma^2}(x-u)^2]$

$N(\overline x | \overline u, \Sigma)=\frac{1}{(2\pi)^{D/2}}\frac{1}{|\Sigma|^{1/2}}exp[-\frac{1}{2}(\overline x-\overline u)^T\Sigma^{-1}(\overline x-\overline u)]$

### 二维的情况

$\begin{eqnarray} f(\overline x) &=& f(x_1,x_2) \\ &=& f(x_1)f(x_2) \\ &=& \frac{1}{\sqrt{2\pi \sigma_1^2}}exp(-\frac{1}{2}(\frac{x_1-u_1}{\sigma_1})^2) \times \frac{1}{\sqrt{2\pi \sigma_2^2}}exp(-\frac{1}{2}(\frac{x_2-u_2}{\sigma_2})^2) \\ &=&\frac{1}{(2\pi)^{2/2}(\sigma_1^2 \sigma_2^2)^{1/2}}exp(-\frac{1}{2}[(\frac{x_1-u_1}{\sigma_1})^2+(\frac{x_2-u_2}{\sigma_2})^2]) \end{eqnarray}$

$\begin{eqnarray} \Sigma&=&\begin{bmatrix} \sigma_{11} & \sigma_{12} \\ \sigma_{12} & \sigma_{22} \end{bmatrix} \\ &=&\begin{bmatrix} \sigma_1^2 & \sigma_{12} \\ \sigma_{21} & \sigma_{2}^2 \end{bmatrix} \\ \end{eqnarray}$

(不熟悉协方差矩阵的请查找其他资料或翻看我之前的文章)

$\Sigma$ 的行列式 $|\Sigma|=\sigma_1^2 \sigma_2^2$，代入公式 (4) 就可以得到：

$f(\overline x)=\frac{1}{(2\pi)^{2/2}|\Sigma|^{1/2}}exp(-\frac{1}{2}[(\frac{x_1-u_1}{\sigma_1})^2+(\frac{x_2-u_2}{\sigma_2})^2])$

$\begin{eqnarray} exp[-\frac{1}{2}(\overline x-\overline u)^T\Sigma^{-1}(\overline x-\overline u)] &=& exp[-\frac{1}{2} \begin{bmatrix} x_1-u_1 \ \ \ x_2-u_2 \end{bmatrix} \frac{1}{\sigma_1^2 \sigma_2^2} \begin{bmatrix} \sigma_2^2 & 0 \\ 0 & \sigma_1^2 \end{bmatrix} \begin{bmatrix} x_1-u_1 \\ x_2-u_2 \end{bmatrix}] \\ &=&exp[-\frac{1}{2} \begin{bmatrix} x_1-u_1 \ \ \ x_2-u_2 \end{bmatrix} \frac{1}{\sigma_1^2 \sigma_2^2} \begin{bmatrix} \sigma_2^2(x_1-u_1) \\ \sigma_1^2(x_2-u_2) \end{bmatrix}] \\ &=&exp[-\frac{1}{2\sigma_1^2 \sigma_2^2}[\sigma_2^2(x_1-u_1)^2+\sigma_1^2(x_2-u_2)^2]] \\ &=&exp[-\frac{1}{2}[\frac{(x_1-u_1)^2}{\sigma_1^2}+\frac{(x_2-u_2)^2}{\sigma_2^2}]] \end{eqnarray}$

### 参数估计

$\begin{eqnarray} f(x_1, x_2, \dots, x_m)&=&\prod_{i=1}^{m}\frac{1}{\sqrt{2\pi}\sigma}exp(-\frac{(x_i-\tilde \mu)^2}{2\sigma^2}) \\ &=&(2\pi \sigma^2)^{-\frac{m}{2}}exp(-\frac{\sum_{i=1}^n{(x_i-\tilde \mu)^2}}{2\sigma^2}) \end{eqnarray}$

$\ln{f(x_1, x_2, \dots, x_m)}=-\frac{m}{2}\ln{(2\pi \sigma^2)}-\frac{1}{2\sigma^2}\sum_{i=1}^n{(x_i-\tilde \mu)^2}$

$\frac{\partial \ln f}{\partial \overline \mu}=\frac{1}{\sigma^2}\sum_{i=1}^{n}{(x_i-\tilde \mu)}=0$

$\frac{\partial \ln{f}}{\partial \sigma}=-\frac{m}{\sigma}+\frac{1}{\sigma^3}\sum_{i=1}^n{(x_i-\tilde \mu)}=0$

### 总结

$N(x|u,\sigma^2)=\frac{1}{\sqrt{2\pi \sigma^2}}exp[-\frac{1}{2\sigma^2}(x-u)^2]$

$N(\overline x | \overline u, \Sigma)=\frac{1}{(2\pi)^{D/2}}\frac{1}{|\Sigma|^{1/2}}exp[-\frac{1}{2}(\overline x-\overline u)^T\Sigma^{-1}(\overline x-\overline u)]$

### 参考

PS: 之后的文章更多的会发布在公众号上，欢迎有兴趣的读者关注我的个人公众号：AI小男孩，扫描下方的二维码即可关注

posted @ 2018-01-09 13:38  jermmyhsu  阅读(28422)  评论(3编辑  收藏