Chapter 6: vernier bias
Chapter 6: vernier bias
To understand how the evidence for a bias follows the size of the true bias, we will simulate a dataset and vary its mean from left to right of no bias, computing and plotting the evidence in each case.
%%% Model likelihoods and evidence
sig=.1; dat=randn([10,1])*sig; dat=dat-mean(dat); N=length(dat);
COL={.4*[1 1 1],.8*[1 1 1]};
murange=[-2*sig 2*sig]; Dmu=diff(murange(1:2)); %don't expect any large biases
Nmu=101; mu2=linspace(murange(1),murange(2),Nmu);
mu1=0; Lpri1=0; Lpri2=-log(Dmu); %normalized log-priors
x=linspace(murange(1),murange(2),301); L=ones(size(x));
ind=[findnearestN(x,0,1) findnearestN(x,.05,1)];
for n=1:N, L=L.*npdf(dat(n)+.05,x,sig); end
figure(3); clf; hold on;
plot(x,L,'k-','LineWidth',2.2);
stem(x(ind(1)),L(ind(1)),'k--','LineWidth',1.2); plot(x(ind(1)),L(ind(1)),'ko','MarkerFaceColor',COL{1},'MarkerSize',12,'LineWidth',1);
stem(.05,L(ind(2)),'k--','LineWidth',1.2); plot(.05,L(ind(2)),'ko','MarkerFaceColor',COL{2},'MarkerSize',12,'LineWidth',1);
xlabel(['location parameter (\mu)'],'FontName','Arial','FontSize',15)
ylabel('likelihood','FontName','Arial','FontSize',15)
Nx=31; xlist=linspace(.9*mu2(1),.9*mu2(end),Nx);
L1=nan(Nx,1); L2=nan(Nx,1); EV=nan(Nx,1);
for i=1:Nx; xnow=xlist(i);
dnow=dat+xnow;
L1(i)=sum(log(npdf(dnow,mu1,sig)))+Lpri1; %single-mu model
L2tmp=zeros(size(mu2));
for n=1:length(dnow),
L2tmp=L2tmp+log(npdf(dnow(n),mu2,sig)); end %uncertain model
L2(i)=logsum(L2tmp+Lpri2-log(Nmu)); %last term is to approximate integration
%%% compute evidence
EV(i)=10*(L2(i)-L1(i)); end
%%% plotting
figure(4); clf; hold on
ind=findnearestN(xlist,.05,1);
plot(xlist,L1,'ko','MarkerFaceColor',COL{1},'MarkerSize',8)
plot(xlist,L2,'ko','MarkerFaceColor',COL{2},'MarkerSize',8)
xlabel(['data mean'],'FontSize',15);
ylabel('model likelihood','FontName','Arial','FontSize',15);
figure(5); clf; hold on
plot(.05*[1 1],[-10 EV(ind)],'k:')
plot(xlist(EV<0),EV(EV<0),'ko','MarkerFaceColor',COL{1},'MarkerSize',9,'LineWidth',1);
plot(xlist(EV>0),EV(EV>0),'ko','MarkerFaceColor',COL{2},'MarkerSize',9,'LineWidth',1);
plot(xlist([1 end]),[0 0],'k--','LineWidth',2);
axis([murange -10 100]);
xlabel(['data mean'],'FontSize',15);
ylabel('evidence (db)','FontName','Arial','FontSize',15);
Note that although we would observe only a single dataset in our experiment, such as the dataset whose mean was , we have plotted the evidence calculation for multiple datasets to get as sense of the large picture of how the computation turns out in different contexts. To remind ourselves that there is only a single result from our experiment, however, we have placed a vertical dashed line at the above-mentioned result on the evidence plot.