PLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASHREPLACE_WITH_DASH_DASH end MC loop

end % k loop


% normalize marginal posterior
Px = Px/sum(Px);

% viz posterior histogram
figure
subplot(211)
h=bar(xr,Px); set(h,'facecolor',[1 0 0])
axis([min(xr) max(xr) 0 max(Px)*1.05])
title('expected (marginal) posterior for (elements of) x','fontsize',14)
% d