Chapter 5: straight-line model ii
Now we will measure the straight-line model parameters when describing the mapping between auditory and physical space using a uniform prior over line-angle for a linear model conceived in angle-intercept form, s = alpha + tan(phi).
%set constants (re-use data and other consts from prev example)
%SD=5; buzzers=-45:15:45; Nb=length(buzzers);
%alpha=2; beta=.88;
%dvec=alpha+beta*buzzers'+nrand(0,SD,[Nb 1]);
alphas=linspace(-12,12,201); sds=linspace(0,10,201); %potential intercept (alpha) and sd values
phis=linspace(0,2*pi/3,501); %will use uniform prior in angle
L=@(alphanow,sdnow) -(Nb+1)*sdnow-.5*sum((dvec*ones(size(phis))-(alphanow+buzzers'*tan(phis))).^2)/sdnow^2;
fTX=@(x) tan(x);
%main loop (uniform prior)
postmat=zeros(length(phis),length(alphas),length(sds)); %initialize posterior matrix
for na=1:length(alphas),
for ns=1:length(sds),
postmat(:,na,ns)=L(alphas(na),sds(ns)); end, end
Phipost=logsum(postmat,[2 3],[diff(alphas(1:2)) diff(sds(1:2))]);
Apost=logsum(postmat,[1 3],[diff(phis(1:2)) diff(sds(1:2))]);
SDpost=logsum(postmat,[1 2],[diff(phis(1:2)) diff(alphas(1:2))]);
Phipostx=pTX(phis,exp(Phipost-max(Phipost)),fTX);
figure(3); clf; subplot(2,1,1);
plot(Phipostx(:,2),Phipostx(:,1)/max(Phipostx(:,1)),'--','Color',[0 .45 .74],'LineWidth',1.4); axis([0 2 0 1.02]); box off
subplot(2,1,2); plot(alphas,exp(Apost-max(Apost)),'--','Color',[0 .45 .74],'LineWidth',1.4); axis([-10 10 0 1.02]); box off