# 梅特罗波利斯－黑斯廷斯算法

## 算法

1. 初始化
1. 选定初始状态${\displaystyle x_{0}}$
2. ${\displaystyle t=0}$
2. 迭代过程
1. 生成： 从某一容易抽样的分布${\displaystyle Q(x'|x_{t})}$中随机生成候选状态${\displaystyle x'}$[註 1]
2. 计算： 计算是否采纳候选状态的概率${\textstyle A(x'|x)=\min \left(1,{\frac {P(x')}{P(x)}}{\frac {Q(x|x')}{Q(x'|x)}}\right)}$
3. 接受或拒绝
1. ${\displaystyle [0,1]}$的均匀分布中生成随机数${\displaystyle u}$
2. ${\displaystyle u\leq A(x'|x)}$，则接受该状态，并令${\displaystyle x_{t+1}=x'}$
3. ${\displaystyle u>A(x'|x)}$，则拒绝该状态，并令${\displaystyle x_{t+1}=x_{t}}$（复制原状态）；
4. 增量：${\textstyle t=t+1}$

## 注释

1. ^ 该分布称为提议分布（proposal distribution），当其对称时（即满足${\displaystyle Q(x'|x)=Q(x|x')}$），是梅特罗波利斯－黑斯廷斯算法的一类特例，称为梅特罗波利斯算法（Metropolis algorithm）。

## 参考文献

1. ^ Metropolis, N.; Rosenbluth, A.W.; Rosenbluth, M.N.; Teller, A.H.; Teller, E. Equations of State Calculations by Fast Computing Machines. Journal of Chemical Physics. 1953, 21 (6): 1087–1092. Bibcode:1953JChPh..21.1087M. doi:10.1063/1.1699114.
2. ^ Hastings, W.K. Monte Carlo Sampling Methods Using Markov Chains and Their Applications. Biometrika. 1970, 57 (1): 97–109. JSTOR 2334940. Zbl 0219.65008. doi:10.1093/biomet/57.1.97.
• Bernd A. Berg. Markov Chain Monte Carlo Simulations and Their Statistical Analysis. Singapore, World Scientific, 2004.
• Siddhartha Chib and Edward Greenberg: "Understanding the Metropolis–Hastings Algorithm". American Statistician, 49(4), 327–335, 1995
• David D. L. Minh and Do Le Minh. "Understanding the Hastings Algorithm." Communications in Statistics - Simulation and Computation, 44:2 332-349, 2015
• Bolstad, William M. (2010) Understanding Computational Bayesian Statistics, John Wiley & Sons ISBN 0-470-04609-0