之前介绍的MCMC算法都具有一般性和通用性(这里指Metropolis-Hasting 算法),但也存在一些特殊的依赖于仿真分布特征的MCMC方法。在介绍这一类算法(指Gibbs sampling)之前,本节将介绍一种特殊的MCMC算法。 我们重新考虑了仿真的理论基础,建立了Slice Sampler。

    考虑到[MCSM]伪随机数和伪随机数生成器中提到的产生服从f(x)密度分布随机数等价于在子图f上产生均匀分布,即

[MCSM] Slice Sampler

    类似笔记“[MCSM] Metropolis-Hastings 算法”(文章还没写好),考虑采用马尔可夫链的稳态分布来等价[MCSM] Slice Sampler上的均匀分布,以此作为f分布的近似。很自然的想法是采用[MCSM] Slice Sampler随机行走(random walk)。这样得到的稳态分布是在集合上的均匀分布。

2. 2D slice sample

    有很多方法实现在集合上的"random walk",最简单的就是一次改变一个方向上的取值,每个方向的改变交替进行,由此得到的算法是 2D slice sampler


    在第t次迭代中,执行

    1. [MCSM] Slice Sampler

    2. [MCSM] Slice Sampler , 其中

[MCSM] Slice Sampler


    举例

[MCSM] Slice Sampler

    其中,[MCSM] Slice Sampler是归一化因子,代码如下,第一幅图是前10个点的变化轨迹,第二幅图表明初始点的选取影响不大

% p324
T = 0:10000;
T = T/10000;
% N(3,1)
y = exp(-(T+3).^2/2);
plot(T,y);
hold on;
x = 0.25;
u = rand *(exp(-(x+3).^2/2));
x_s = [x];
u_s = [u];
for k = 1:10;
    limit = -3 + sqrt(-2*log(u));
    limit = min([limit 1]);
    x = rand * limit;
    x_s = [x_s x];
    u_s = [u_s u];
    u = rand *(exp(-(x+3).^2/2));
    x_s = [x_s x];
    u_s = [u_s u];
end
plot(x_s,u_s,'-*');
hold off;

%%
x = 0.01;
u = 0.01;
x_s = [x];
u_s = [u];
for k = 1:50;
    limit = -3 + sqrt(-2*log(u));
    limit = min([limit 1]);
    x = rand * limit;
    x_s = [x_s x];
    u_s = [u_s u];
    u = rand *(exp(-(x+3).^2/2));
    x_s = [x_s x];
    u_s = [u_s u];
end
figure;
subplot(1,3,1);
plot(x_s,u_s,'*');hold on;plot(T,y);
x = 0.99;
u = 0.0001;
x_s = [x];
u_s = [u];
for k = 1:50;
    limit = -3 + sqrt(-2*log(u));
    limit = min([limit 1]);
    x = rand * limit;
    x_s = [x_s x];
    u_s = [u_s u];
    u = rand *(exp(-(x+3).^2/2));
    x_s = [x_s x];
    u_s = [u_s u];
end
subplot(1,3,2);
plot(x_s,u_s,'*');hold on;plot(T,y);
x = 0.25;
u = 0.0025;
x_s = [x];
u_s = [u];
for k = 1:50;
    limit = -3 + sqrt(-2*log(u));
    limit = min([limit 1]);
    x = rand * limit;
    x_s = [x_s x];
    u_s = [u_s u];
    u = rand *(exp(-(x+3).^2/2));
    x_s = [x_s x];
    u_s = [u_s u];
end
subplot(1,3,3);
plot(x_s,u_s,'*');hold on;plot(T,y);
View Code

相关文章:

  • 2021-04-23
  • 2021-05-07
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2021-06-08
猜你喜欢
  • 2021-08-22
  • 2021-12-18
  • 2021-04-12
  • 2021-07-12
  • 2021-11-14
  • 2021-06-07
  • 2022-01-30
相关资源
相似解决方案