% show contour plot of log likelihood across weight space [gxs, gys] = meshgrid(-5:.1:10,-6:.1:4); z1 = log(1+exp(gxs+1.2*gys)); z2 = log(1+exp(-gxs+gys)); z3 = log(1+exp(-gxs-2*gys)); contourf(gxs, gys, z1+z2+z3); xlabel('W_0'); ylabel('W_1'); set(gca,'FontSize',18); axis equal; axis tight; wstar = logistic([1 1.2; 1 -1; 1 2], [0; 1; 1], [], 0); p = exp(-(z1+z2+z3)); idx = samplefrom(p(:)/sum(p(:)), 25); w0 = gxs(idx); w1 = gys(idx); line(w0, w1, 'Marker', 'x', 'LineStyle', 'none', 'MarkerSize', 10, 'Color', 'r', 'LineWidth', 2) line(wstar(1), wstar(2), 'Marker', '+', 'LineStyle', 'none', 'MarkerSize', 20, 'Color', 'g', 'LineWidth', 2) print -depsc posterior.eps % show a sample from the posterior, the predictive curves for sample % points, and the predictive distribution curve [gxs, gys] = meshgrid(-5:.1:10,-6:.1:4); z1 = log(1+exp(gxs+1.2*gys)); z2 = log(1+exp(-gxs+gys)); z3 = log(1+exp(-gxs-2*gys)); p = exp(-(z1+z2+z3)); wstar = logistic([1 1.2; 1 -1; 1 2], [0; 1; 1], [], 0); idx = samplefrom(p(:)/sum(p(:)), 10); w0 = gxs(idx); w1 = gys(idx); idx = samplefrom(p(:)/sum(p(:)), 15000); w0a = gxs(idx); w1a = gys(idx); plot(1.2,0,'o',[-1 2],[1 1],'+','LineWidth',2,'MarkerSize',15) xs = -20:.02:20; hold on; for i = 1:length(w0); line(xs, 1./(1+exp(-(w0(i)+w1(i)*xs))),'Color','b'); end; hold off line(xs,1./(1+exp(-(wstar(1)+wstar(2)*xs))),'LineWidth',2,'Color','k'); ps = 0*xs; for i = 1:length(w0a); ps = ps + 1./(1+exp(-(w0a(i)+w1a(i)*xs))); end; line(xs, ps/length(w0a), 'LineWidth', 2, 'Color', 'r') axis([min(xs) max(xs) -.1 1.1]) print -depsc postcurves.eps