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_aha_goldstone.m

107 lines
2.7 KiB
Matlab

function categorise_aha_goldstone()
%Aha & Goldstone (1992)
training=[2,6;
3,6;
4,6;
7,3;
7,4;
7,5;
3,7;
4,7;
5,7;
6,2;
6,3;
6,4];
class=[1,1,1,1,1,1,2,2,2,2,2,2]-1;
Xfeatures=[1:8];
Xclass=[0,1];
%define weights - two prototypes for each class
loprec=0.1;
hiprec=1;
W(1,:)=[code(3,Xfeatures,loprec),code(6,Xfeatures,hiprec),code(0,Xclass)];
W(2,:)=[code(7,Xfeatures,hiprec),code(4,Xfeatures,loprec),code(0,Xclass)];
W(3,:)=[code(4,Xfeatures,loprec),code(7,Xfeatures,hiprec),code(1,Xclass)];
W(4,:)=[code(6,Xfeatures,hiprec),code(3,Xfeatures,loprec),code(1,Xclass)];
%normalise weights
W=bsxfun(@rdivide,W,max(1e-6,sum(W,2)));
[n,m]=size(W)
%simulate categorization expt
for i=Xfeatures
for j=Xfeatures
x=[code(i,Xfeatures),code(j,Xfeatures),0*Xclass]';
[y,e,r]=dim_activation(W,x);
predict=r(m-(length(Xclass)-1):m)';
category(j,i)=sum(Xclass.*predict)./sum(predict);
end
end
%plot results
figure(1),clf
imagesc(category,[0,1])
colormap('gray')
axis('equal','tight')
set(gca,'FontSize',16)
xlabel('feature 1');ylabel('feature 2')
set(gcf,'PaperSize',[8 8],'PaperPosition',[0 0.25 8 7.5],'PaperOrientation','Portrait');
print(gcf, '-dpdf','categorise_aha_goldstone_model.pdf');
human=[50,45,45,40,50,65,10,30;
65,60,80,80,85,90,20,25;
55,50,55,60,70,85,0,20;
40,55,45,40,65,85,0,15;
20,20,15,25,30,70,0,20;
10,0,5,10,10,5,5,15;
85,90,90,95,90,85,75,80;
55,60,65,60,55,60,55,60];
figure(2),clf
imagesc(human./100,[0,1])
colormap('gray')
axis('equal','tight')
set(gca,'FontSize',16)
xlabel('feature 1');ylabel('feature 2')
set(gcf,'PaperSize',[8 8],'PaperPosition',[0 0.25 8 7.5],'PaperOrientation','Portrait');
print(gcf, '-dpdf','categorise_aha_goldstone_human.pdf');
figure(3),clf
imagesc(human.*0+1,[0,1]),hold on
in=min(Xfeatures)+0.5:max(Xfeatures)-0.5;
out=min(Xfeatures)-0.5:max(Xfeatures)+0.5;
for i=in
plot(i.*ones(size(out)),out,'k-')
plot(out,i.*ones(size(out)),'k-')
end
for k=1:size(training,1)
text(training(k,1),training(k,2),int2str(class(k)),'FontSize',14,'HorizontalAlignment','center','VerticalAlignment','middle','FontWeight','bold')
end
colormap('gray')
axis('equal','tight')
set(gca,'FontSize',16)
xlabel('feature 1');ylabel('feature 2')
set(gcf,'PaperSize',[8 8],'PaperPosition',[0 0.25 8 7.5],'PaperOrientation','Portrait');
print(gcf, '-dpdf','categorise_aha_goldstone_stimuli.pdf');
function c=code_all(x,X)
c=[];
for i=1:length(x)
c=[c,code(x(i),X)];
end
function c=code(x,X,precision)
if nargin<3 || isempty(precision)
precision=2;
end
c=zeros(1,length(X));
c=exp(-precision.*(x-X).^2);
c=c./sum(c);