深度之眼-统计学习方法-作业【1】
作业【1】
- 推导下述正态分布均值的极大似然估计和贝叶斯估计。
- (1)
由于\(x_i\)的概率密度函数为:\(f(x)=(2\pi\sigma^2)^{-1/2}Exp\{-\frac{1}{2\sigma^2}(x-\mu)^2\}\),于是其似然函数为:
\[\begin{align}
L=&\prod_{i=1}^n\left[(2\pi\sigma^2)^{-1/2}Exp\{-\frac{1}{2\sigma^2}(x_i-\mu)^2\}\right]\\
\ln{L}=&\ln{\left[\prod_{i=1}^n(2\pi\sigma^2)^{-1/2}Exp\{-\frac{1}{2\sigma^2}(x_i-\mu)^2\}\right]}\\
=&\sum_{i=1}^nln\left[(2\pi\sigma^2)^{-1/2}\right]+\sum_{i=1}^nln\left[Exp\{-\frac{1}{2\sigma^2}(x_i-\mu)^2\}\right]\\
=&-\frac n2\ln{(2\pi)}-\frac n2\ln{(\sigma^2)}-\frac{1}{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2
\end{align}
\]
为使\(L\)达到最大,只需是\(\ln{L}\)达到最大,故求偏导数方程(似然方程):
\[\begin{align}
\frac{\partial\ln{L}}{\partial\mu}=&\frac1{\sigma^2}\sum_{i=1}^n(x_i-\mu)=0\\
解得,\mu=&\frac1n\sum_{i=1}^nx_i
\end{align}
\]
- (2)
由题意:\(x_i\sim N(\mu,\sigma^2)\),而且已定下先验密度:\(\mu\sim N(0,\tau^2)\)。
于是我们列出先验密度与总体的密度函数
\[h(\mu)=(\sqrt{2\pi}\tau)^{-1}Exp[-\frac{\mu^2}{2\tau^2}]\\
f(x,\mu)=(\sqrt{2\pi}\sigma)^{-1}Exp[-\frac{(x-\mu)^2}{2\sigma^2}]
\]
则\((\mu,x_1,\dots,x_n)\)的联合密度为:
\[\begin{align}
h(\mu)\prod_{i=1}^nf(x_i,\mu)=&\frac{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2]}{\sqrt{2\pi}\tau(\sqrt{2\pi}\sigma)^n}
\end{align}
\]
则\((x_1,\dots,x_n)\)的边缘密度为:
\[\begin{align}
p(x_1,\dots,x_n)=&\int h(\mu)\prod_{i=1}^nf(x_i,\mu)d\mu\\
=&\frac1{\sqrt{2\pi}\tau(\sqrt{2\pi}\sigma)^n}\int{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2]}d\mu
\end{align}
\]
其中
\[\begin{align}
&\int{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2]}d\mu\\
=&\int{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n{x_i}^2-\frac1{2\sigma^2}n\mu^2+\frac1{\sigma^2}n\mu\bar{x}]}d\mu
\end{align}
\]
于是可以得到在给定\((x_1,\dots,x_n)\)的条件下,\(\mu\)的条件密度为:
\[\begin{align}
h(\mu|x_1,\dots,x_n)=&\frac{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2]}{\int{Exp[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2]}d\mu}
\end{align}
\]
观察可知分母与\(\mu\)并没有关系,于是令\(t=n\bar{X}/(n+1/\tau^2),\eta^2=\frac1{(n+1/\tau^2)}\):
\[-\frac1{2\tau^2}\mu^2-\frac1{2\sigma^2}\sum_{i=1}^n(x_i-\mu)^2=-\frac{1}{2\eta^2}(\mu-t)^2+J
\]
则:
\[h(\mu|x_1,\dots,x_n)=I_1Exp[-\frac1{2\eta^2}(\mu-t)^2]
\]
因此\(\mu\)的后验概率分布记为\(N(t,\eta^2)\),即:
\[\tilde{\mu}=t=\frac{n}{n+1/\tau^2}\bar{X}
\]