
function [] = compareBayes(n)

% we have n points labeled y=0 and n points labeled 11

% score for M_0 (single region [0,1])

Bscore0 = 2*lnfac(n) - lnfac(2*n+1);

% M_1 splits [0,1] into region1 = [0,1/2) and region2 = [1/2,1].

D = zeros(n+1,n+1); % the score difference Bscore1-Bscore0

for i=0:n,
  for j=0:n,
    n11 = i; % number of y=1 in region1
    n10 = j;  % number of y=0 in region1
    n21 = n-i; % number of y=1 in region2
    n20 = n-j; % number of y=0 in region2
       
    Bscore1 = lnfac(n11) + lnfac(n10) - lnfac(n11+n10+1) + ...
	      lnfac(n21) + lnfac(n20) - lnfac(n21+n20+1);

    D(i+1,j+1) = Bscore1-Bscore0; 
  end;
end;

tx = [0:n]/n;
ty = [0:n]/n;

contour(tx,ty,D',[0 0],'k-');
xlabel('fraction of points y=1 in region 1')
ylabel('fraction of points y=0 in region 1')
grid;

% ------------------------
% natural log of k!

function [r] = lnfac(k)

r = gammaln(k+1);
