function posterior_plot(smpl, state_prob)

k=size(smpl,2);
row=ceil(k/4);   % the plot will have four paramters in each row
for i=1:10
    delete (figure (i))
end


% plot the draws, to see whether they are stationary
scrsz = get(0,'ScreenSize');
figure('Position',[4 scrsz(4)/2 scrsz(3) scrsz(4)/2])
for i=1:k
    subplot(row, 4, i)
    plot(smpl(:,i)); xlabel(['paramters ', num2str(i)])
end

% histgram of the posterior density
scrsz = get(0,'ScreenSize');
figure('Position',[4 scrsz(4)/2 scrsz(3) scrsz(4)/2])
for i=1:k
    subplot(row, 4, i)
    histfit(smpl(:,i));  xlabel(['paramters ', num2str(i)]); ylabel('Frequency');
end

% Autocorrelation of posterior density
scrsz = get(0,'ScreenSize');
figure('Position',[4 scrsz(4)/2 scrsz(3) scrsz(4)/2])
for i=1:k
    subplot(row, 4,i)
    autocorr(smpl(:,i),50); xlabel('lags'); ylabel('ACF');
    ACF(:,i)=autocorr(smpl(:,i));
end

% Plot the state probability
scrsz = get(0,'ScreenSize');
figure('Position',[4 scrsz(4)/2 scrsz(3) scrsz(4)/2])
plot(state_prob); xlabel(' Pr(St=1|Y)');

end

