Markov Chains Monte Carlo(MCMC)proposal distribution(建议分布)选取的一个原则

    xiaoxiao2021-03-25  153

          在上篇博客中  MATLAB 抽取随机数 MCMC原理中已经介绍了在Metropolis和Metropolis-Hastings算法中选择proposal分布的三种建议,本文基于实践再给出一种选取proposal分布的一种建议。原理是抽取的样本相关系数大的话,有效样本的个数是减少的,因此近似的效果会变差。因此,我们在选取proposal分布时,也应注意抽样的相关性,选取相关性小的proposal。下面是一个具体的例子:

    clc;clear; standerror=1; Nsamples=10000; %抽取的样本个数 pdf=@(x) normpdf(x,1,0.3) % target distribution % Generate random samples using Random Walk proppdf=@(x,y) normpdf(x);%proppdf defines the proposal distribution density; proprnd=@(x)(randn(size(x))*standerror+x);%+0.00001 proprnd defines the random number generator for the proposal distribution [smpl,a]=mhsample(1,Nsamples,'pdf',pdf,'proppdf',proppdf,'proprnd',proprnd,'symmetric',1); [h,p]=adftest(smpl)%检验序列是否平稳 autocorr(smpl) %自相关图 [h1,p1]=kstest(smpl,[smpl,normcdf(smpl,1,0.3)]) h=1   %说明序列是平稳的 p=1.0000e-003 h1=1   %说明拒绝正态分布假设 p1=0.0428

    注意:对平稳性不可简单的通过肉眼观察,最好还是通过检验。可以看出序列在10阶以后就不相关了,提的样本有效性还是蛮高的,在用样本时可以间隔10个来取。

    若将standerror设为0.1,则h1=1;p1=0.0195;自相关图如下图:

    x=smpl(1:10:end); %针对standerror=1的情况 [h2,p2]=kstest(x,[x,normcdf(x,1,0.3)])

    h2=0

    p2=0.6560

    说明不拒绝服从正态分布的假设。

    参考:http://www.ilovematlab.cn/thread-41758-1-1.html

    http://www.cnblogs.com/djcsch2001/archive/2012/02/05/2339199.html   MATLAB假设检验

    转载请注明原文地址: https://ju.6miu.com/read-18805.html

    最新回复(0)