You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cognition/categorise_smith_minda_expt2.m

82 lines
2.3 KiB
Matlab

function categorise_smith_minda_expt2()
%Smith & Minda (1998), Expt. 2
training=[0,0,0,0,0,0;
1,0,0,0,0,0;
0,1,0,0,0,0;
0,0,1,0,0,0;
0,0,0,0,1,0;
0,0,0,0,0,1;
1,1,1,1,0,1;
1,1,1,1,1,1;
0,1,1,1,1,1;
1,0,1,1,1,1;
1,1,0,1,1,1;
1,1,1,0,1,1;
1,1,1,1,1,0;
0,0,0,1,0,0];
class=[1;1;1;1;1;1;1;0;0;0;0;0;0;0];
testing=training;
Xfeatures=[0,1];
Xclass=[0,1];
%define weights
W=[];
for c=Xclass
%one prediction neuron for each prototype
ind=find(class==c);
ind=ind(1:end-1);% remove exception for items contribution to prototype
W=[W;[code_all(mean(training(ind,:)),Xfeatures),code(c,Xclass,1)]];
end
%exceptions: 7th and 14th training items
W=[W;code_all(training(7,:),Xfeatures,2.*[1,1,1,1,1,1]),code(class(7),Xclass,0.5)];
W=[W;code_all(training(14,:),Xfeatures,2.*[1,1,1,1,1,1]),code(class(14),Xclass,0.5)];
%normalise weights
W=bsxfun(@rdivide,W,max(1e-6,sum(W,2)));
[n,m]=size(W)
%simulate categorization expt
for k=1:size(testing,1)
x=[code_all(testing(k,:),Xfeatures),0*Xclass]';
%x=x./sum(x);
[y,e,r]=dim_activation(W,x);
predict=r(m-(length(Xclass)-1):m)';
category(k)=sum(Xclass.*predict)./sum(predict);
end
%plot results
figure(1),clf
plot(category,'b-o','LineWidth',2,'MarkerFaceColor','b','MarkerSize',8)
axis([0.5,14.5,0,1])
hold on, plot([0,20],[0.5,0.5],'k--')
set(gca,'XTick',[1:3:7,8:3:14],'XTickLabel',['1';'A';'7';'1';'B';'7'],'FontSize',14)
text(2.5,-0.02,'\leftarrow','HorizontalAlignment','center','VerticalAlignment','Top')
text(5.5,-0.02,'\rightarrow','HorizontalAlignment','center','VerticalAlignment','Top')
text(9.5,-0.02,'\leftarrow','HorizontalAlignment','center','VerticalAlignment','Top')
text(12.5,-0.02,'\rightarrow','HorizontalAlignment','center','VerticalAlignment','Top')
xlabel('item');ylabel('probability of A')
set(gcf,'PaperSize',[8 8],'PaperPosition',[0 0.25 8 7.5],'PaperOrientation','Portrait');
print(gcf, '-dpdf','categorise_smith_minda_expt2.pdf');
function c=code_all(x,X,precision)
if nargin<3 || isempty(precision)
precision=1.*ones(1,length(x));
end
c=[];
for i=1:length(x)
c=[c,code(x(i),X,precision(i))];
end
function c=code(x,X,precision)
if nargin<3 || isempty(precision)
precision=1;
end
c=zeros(1,length(X));
c=exp(-precision.*(x-X).^2);
c=c./sum(c);