Command Palette
Search for a command to run...
马尔可夫链蒙塔卡罗方法 MCMC
日期
Metropolis-Hastings 采样
1:初始化马氏链初始状态 $latex {X\mathop{{}}\nolimits_{{0}}\text{ }=\text{ }x\mathop{{}}\nolimits_{{0}}}$
2:对 $latex {t\text{ }=\text{ }0,\text{ }1,\text{ }2,\text{ }…}$ 循环以下过程进行采样
- 第 $latex {t}$ 个时刻马氏链状态为 $latex {X\mathop{{}}\nolimits_{{t}}\text{ }=\text{ }x\mathop{{}}\nolimits_{{t}}}$ ,采样 $latex {y\text{ } \sim \text{ }q{ \left( {x \left| x\mathop{{}}\nolimits_{{t}}\right. } \right) }}$
- 从均匀分布采样 $latex {u\text{ } \sim \text{ }Uniform{ \left[ {0,1} \right] }}$
- 如果 $latex {u\text{ } < \text{ } \alpha { \left( {x\mathop{{}}\nolimits_{{t}},y} \right) }\text{ }=\text{ }min{ \left\{ {\frac{{p{ \left( {y} \right) }q{ \left( {x\mathop{{}}\nolimits_{{t}} \left| y\right. } \right) }}}{{p{ \left( {x\mathop{{}}\nolimits_{{t}}} \right) }p{ \left( {y \left| x\mathop{{}}\nolimits_{{t}}\right. } \right) }}},1} \right\} }}$ 则接受转移 $latex {x\mathop{{}}\nolimits_{{t}}\text{ } \to \text{ }y}$ ,即 $latex {X\mathop{{}}\nolimits_{{t+1}}\text{ }=\text{ }y}$
- 否则不接受转移,即 $latex {X\mathop{{}}\nolimits_{{t+1}}\text{ }=\text{ }x\mathop{{}}\nolimits_{{t}}}$
Gibbs 采样
1:随机初始化 $latex {X\mathop{{}}\nolimits_{{0}}\text{ }=\text{ }x\mathop{{}}\nolimits_{{0}},\text{ }Y\mathop{{}}\nolimits_{{0}}\text{ }=\text{ }y\mathop{{}}\nolimits_{{0}}}$
2:对 $latex {t\text{ }=\text{ }0,\text{ }1,\text{ }2,\text{ }…}$ 循环采样
- $latex {y\mathop{{}}\nolimits_{{t+1}}\text{ } \sim \text{ }p{ \left( {y \left| x\mathop{{}}\nolimits_{{t}}\right. } \right) }}$
- $latex {x\mathop{{}}\nolimits_{{t+1}}\text{ } \sim \text{ }p{ \left( {x \left| y\mathop{{}}\nolimits_{{t+1}}\right. } \right) }}$