% Lecture 5A example: Unknown coin that we happen to encounter theta = 0:0.1:1; % discrete: any exact multiple of 1/10 h = length(theta) % number of possible values of theta pri = repmat(1/h, 1, h) % assign same prior probability to each lik = (1-theta) unpost = pri .* lik post = unpost / sum(unpost) bar(theta, post); % plot the posterior distribution postheads = sum(post .* theta) % posterior probability of heads posttails = sum(post .* (1-theta)) % posterior probability of tails