% Lecture 5A example: Coin from a box theta = [0 .25 .5 .75 1] pri = [.1 .1 .6 .1 .1] lik = (1-theta) unpost = pri .* lik post = unpost / sum(unpost) bar(theta, post); % plot the posterior distribution set(gca,'xtick',theta) postheads = sum(post .* theta) % posterior probability of heads posttails = sum(post .* (1-theta)) % posterior probability of tails