clear;

%rng(1);

vals  = [0.4 0.5 0.6]';
prior = [0.1 0.8 0.1]';
heads = 0;
truth = 0.4;

ii = 1;
while 1
  if rand() < truth
    heads = heads + 1;
    fprintf('heads\n');
  else
    fprintf('tails\n');
  end
  
  
  likelihood = vals.^heads .* (1-vals).^(ii-heads);
  post = likelihood .* prior;
  post = post / sum(post);
  
  bar(vals, post);
  xlim([0 1]);
  ylim([0 1]);
  
  pause;
  
  ii = ii + 1;
end