# 吉布斯採樣

## 算法

1. 確定初始值${\displaystyle \mathbf {X} ^{(1)}}$
2. 假設已得到樣本${\displaystyle \mathbf {X} ^{(i)}}$，記下一個樣本為${\displaystyle \mathbf {X} ^{(i+1)}=\left(x_{1}^{(i+1)},x_{2}^{(i+1)},\dots ,x_{n}^{(i+1)}\right)}$。於是可將其看作一個向量，對其中某一分量${\displaystyle x_{j}^{(i+1)}}$，可通過在其他分量已知的條件下該分量的概率分佈來抽取該分量。對於此條件概率，我們使用樣本${\displaystyle \mathbf {X} ^{(i+1)}}$中已得到的分量${\displaystyle x_{1}^{(i+1)}}$${\displaystyle x_{j-1}^{(i+1)}}$以及上一樣本${\displaystyle \mathbf {X} ^{(i)}}$中的分量${\displaystyle x_{j+1}^{(i)}}$${\displaystyle x_{n}^{(i)}}$，即${\displaystyle p\left(x_{j}^{(i+1)}|x_{1}^{(i+1)},\dots ,x_{j-1}^{(i+1)},x_{j+1}^{(i)},\dots ,x_{n}^{(i)}\right)}$
3. 重複上述過程${\displaystyle k}$次。

## 參考文獻

1. ^ Geman, S.; Geman, D. Stochastic Relaxation, Gibbs Distributions, and the Bayesian Restoration of Images. IEEE Transactions on Pattern Analysis and Machine Intelligence. 1984, 6 (6): 721–741. doi:10.1109/TPAMI.1984.4767596.
• Bishop, Christopher M., Pattern Recognition and Machine Learning, Springer, 2006, ISBN 0-387-31073-8
• Bolstad, William M. (2010), Understanding Computational Bayesian Statistics, John Wiley ISBN 978-0-470-04609-8
• Casella, G.; George, E. I. Explaining the Gibbs Sampler. The American Statistician. 1992, 46 (3): 167. JSTOR 2685208. doi:10.2307/2685208.
• Gelfand, Alan E.; Smith, Adrian F. M., Sampling-Based Approaches to Calculating Marginal Densities, Journal of the American Statistical Association, 1990, 85 (410): 398–409, JSTOR 2289776, MR 1141740, doi:10.2307/2289776
• Gelman, A., Carlin J. B., Stern H. S., Dunson D., Vehtari A., Rubin D. B. (2013), Bayesian Data Analysis, third edition. London: Chapman & Hall.
• Levin, David A.; Peres, Yuval; Wilmer, Elizabeth L. (2008), "Markov Chains and Mixing Times", American Mathematical Society.
• Robert, C. P.; Casella, G. (2004), Monte Carlo Statistical Methods (second edition), Springer-Verlag.