hiden-cubistのブログ

機械学習などの技術や投資に関する情報を記事にしています。

ベイズ推定とグラフィカルモデル Section8 Worksheet

ベイズ推定とグラフィカルモデルの略解をまとめています。あくまで個人のメモですので、必ずしも正しい保証はありません。もしミスがある場合は教えていただければ幸いです。今回はSection8です。

1. 多次元線形回帰(重回帰分析)の導出


\newcommand{\argmax}{\mathop{\rm arg~max}\limits}
\displaystyle P(w|X, \theta)\\
\displaystyle =Norm_w[X^T\phi, \sigma^2I]\\
\hat\theta\\
\displaystyle =\argmax_{\theta}\log[Norm_w[X^T\phi, \sigma^2I]]\\
\displaystyle =\argmax_{\theta}[-\frac{I}{2}\log[2\pi]-\frac{I}{2}\log[\sigma^2]-\frac{(w-X^T\phi)^T(w-X^T\phi)}{2\sigma^2}]

\frac{\partial L}{\partial \phi}=0を解いて、


\hat\phi=(XX^T)^{-1}Xw

2. ベイズ回帰の事後分布


P(\phi)
=Norm_{\phi}[0, \sigma_p^2I]\\
P(\phi|X, w)
\displaystyle =\frac{P(w|X, \phi)P(\phi)}{P(w|X)}\\
\displaystyle \propto Norm_w[X^T\phi, \sigma^2I]Norm_\phi[0, \sigma_p^2I]\\
\displaystyle \propto Norm_\phi[(XX^T)^{-1}Xw, (\sigma^{-2}XX^T)^{-1}]Norm_\phi[0, \sigma_p^2I]\\
\displaystyle \propto Norm_\phi[(\sigma^{-2}XX^T+\sigma_p^{-2}I)^{-1}(\sigma^{-2}Xw), (\sigma^{-2}XX^T+\sigma_p^{-2}I)^{-1}]\\
\displaystyle \therefore \quad P(\phi|X, w)
=Norm_\phi[\frac{1}{\sigma^2}A^{-1}Xw, A^{-1}]\\
\displaystyle A=\frac{1}{\sigma^2}XX^T+\frac{1}{\sigma_p^2}I

3. Sherman–Morrison–Woodburyの公式


B^TC^{-1}(BAB^T+C)\\
=B^TC^{-1}BAB^T+B^T\\
=(A^{-1}+B^TC^{-1}B)AB^T\\
\therefore\quad (A^{-1}+B^TC^{-1}B)^{-1}B^TC^{-1}\\
=AB^T(BAB^T+C)^{-1}


I
=I+B^TC^{-1}BA-B^TC^{-1}BA\\
=(A^{-1}+B^TC^{-1}B){A-(A^{-1}+B^TC^{-1}B)^{-1}B^TC^{-1}BA}\\
\therefore\quad (A^{-1}+B^TC^{-1}B)^{-1}\\
=A-(A^{-1}+B^TC^{-1}B)^{-1}B^TC^{-1}BA\\
=A-AB^T(BAB^T+C)^{-1}BA