analyzeMHSampler2.m 1.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
% Analyze the MH sampling data

numIter = 100;
N=8;
burnIn = 1e4;

% Analysis for MH's pi3

maxLag = 1e3;
trajAutoCorrMHVec_pi1 = zeros(maxLag+1,N,numIter);
trajAutoCorrMHVec_pi3 = zeros(maxLag+1,N,numIter);
trajAutoCorrMHVec_pi4 = zeros(maxLag+1,N,numIter);

for i=1:numIter
    
    burnIn = 1e4;
    temp1 = squeeze(MHData_pi1(burnIn:end,:,i));
    
    burnIn = 2e4;
    temp3 = squeeze(MHData_pi3(burnIn:end,:,i));
    
    burnIn = 4e4;
    temp4 = squeeze(MHData_pi4(burnIn:end,:,i));
    
    for d=1:N
        % pi1
        [ACF1,Lags,Bounds] = autocorr(temp1(:,d),[maxLag],[],[]);
        trajAutoCorrMHVec_pi1(:,d,i) = ACF1;
        % pi3
        [ACF3,Lags,Bounds] = autocorr(temp3(:,d),[maxLag],[],[]);
        trajAutoCorrMHVec_pi3(:,d,i) = ACF3;
        % pi4
        [ACF4,Lags,Bounds] = autocorr(temp4(:,d),[maxLag],[],[]);
        trajAutoCorrMHVec_pi4(:,d,i) = ACF4;
    end
end

figure(1)
plot(Lags,squeeze(mean(trajAutoCorrMHVec_pi1,3)),'--','LineWidth',1.2)
grid on
hold on
ylim([-0.1 1.1])

%xlabel('Lag k')
%ylabel('Auto-correlation')

figure(2)
plot(Lags,squeeze(mean(trajAutoCorrMHVec_pi3,3)),'--','LineWidth',1.2)
grid on
hold on
ylim([-0.1 1.1])

%xlabel('Lag k')
%ylabel('Auto-correlation')

figure(3)
plot(Lags,squeeze(mean(trajAutoCorrMHVec_pi4,3)))
grid on
hold on
ylim([-0.1 1.1])
% xlabel('Lag k')
% ylabel('Auto-correlation')