Chapter 6: evidence calculation

The penalized-maximum-likelihood form of the model likelihoods allows us to see when we should expect each model to perform well, and when it has a large penalty. These penalties are computed here for the case shown in Fig. 6.4b:

N=20; S=17; dat=permlist([ones(1,S) zeros(1,N-S)]); theta=.8;

%%% compute evidence from raw dataset

rMaxLike=bpdf(sum(dat),length(dat),sum(dat)/length(dat))/bpdf(sum(dat),length(dat),theta);

c=1-(bpdf(sum(dat),length(dat),sum(dat)/length(dat))*(length(dat)+1))^-1;

EV=10*log10((rMaxLike*[1-c])^-1)

%%% compute evidence from N and S

rMaxLike=bpdf(S,N,S/N)/bpdf(S,N,theta);

c=1-(bpdf(S,N,S/N)*(N+1))^-1;

EV(2)=10*log10((rMaxLike*[1-c])^-1)

%%% simplified all-in-one computation

L1=bpdf(S,N,theta); L2=(N+1)^-1;

EV(3)=10*log10(L1/L2);

%%% compare the two calculations

isnear(EV(1),EV(2))

isnear(EV(2),EV(3))