% Matlab script to run the code "MHsimple.m" and plot the results.

[X,acc] = MHsimple();
xx=0:0.1:10;
lambda=1;
hold on

histogram(X,'Normalization','pdf')
plot(xx,exp(-xx),'linewidth',2,'color','red')
% set(gca,'yscale','log')
grid on
xlim([0 10])
xlabel('x')
ylabel('p(x)')

arate=floor(100*acc(1)/acc(2));
display(strcat('acceptance rate=',num2str(arate)),'%')