testMHSampler.m 1.1 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
clear inopts
close all

% Function
pdfName = 'fHaario1'

hfHaario1 = @(x) fHaario1(x);
hfHaario3 = @(x) fHaario3(x);
hfHaario4 = @(x) fHaario4(x);

hOptGauss = @(x,y) optGauss(x,y);
hPropOptGauss = @(z) (z + 2.4/sqrt(length(z)).*randn(length(z),1)');


% Dimension
N = 8

numIter = 100;
MaxSample = 2e4;
MHData_pi1 = zeros(MaxSample,N,numIter); 

% number of iterations
for j=1:numIter
    j
    % Set-up of MH options
    xstart = -1 + 2*rand(N,1)';
    MHData_pi1(:,:,j) = mhsample(xstart,MaxSample,'pdf',hfHaario1,'proppdf',hOptGauss,'proprnd',hPropOptGauss);
end

MaxSample = 4e4;
MHData_pi3 = zeros(MaxSample,N,numIter); 

% number of iterations
for j=1:numIter
    j
    % Set-up of MH options
    xstart = -1 + 2*rand(N,1)';
    MHData_pi3(:,:,j) = mhsample(xstart,MaxSample,'pdf',hfHaario3,'proppdf',hOptGauss,'proprnd',hPropOptGauss);
end

MaxSample = 8e4;
%MHData_pi4 = zeros(MaxSample,N,numIter); 

% number of iterations
for j=35:numIter
    j
    % Set-up of MH options
    xstart = -1 + 2*rand(N,1)';
    MHData_pi4(:,:,j) = mhsample(xstart,MaxSample,'pdf',hfHaario4,'proppdf',hOptGauss,'proprnd',hPropOptGauss);
end