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.
98 lines
2.6 KiB
Matlab
98 lines
2.6 KiB
Matlab
function categorise_nosofsky_etal_expt1()
|
|
|
|
%Nosofsky, Clark and Shin (1989) expt 1
|
|
training=[2,2;
|
|
2,3;
|
|
3,3;
|
|
1,1;
|
|
3,1;
|
|
4,2;
|
|
1,4];
|
|
class=[1,1,1,2,2,2,2];
|
|
Xfeatures=[1:4];
|
|
Xclass=[1,2];
|
|
|
|
%define weights
|
|
loprec=1;
|
|
hiprec=4;
|
|
W(1,:)=[code(2.33,Xfeatures,loprec),code(2.66,Xfeatures,loprec),code(1,Xclass)];
|
|
W(2,:)=[code(3.5,Xfeatures,hiprec),code(1.5,Xfeatures,hiprec),code(2,Xclass)];
|
|
W(3,:)=[code(1,Xfeatures,hiprec),code(2.5,Xfeatures,loprec),code(2,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
|
|
category=flipud(category);
|
|
figure(1),clf
|
|
imagesc(2-category,[0,1])
|
|
colormap('gray')
|
|
axis('equal','tight')
|
|
set(gca,'XTick',Xfeatures,'YTick',Xfeatures,'YTickLabel',int2str(fliplr(Xfeatures)'),'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_nosofsky_etal_expt1_model.pdf']);
|
|
|
|
|
|
human=[8,76,87,32;
|
|
18,86,91,39;
|
|
19,83,37,8;
|
|
5,54,17,6];
|
|
figure(2),clf
|
|
imagesc(human./100,[0,1])
|
|
colormap('gray')
|
|
axis('equal','tight')
|
|
set(gca,'XTick',Xfeatures,'YTick',Xfeatures,'YTickLabel',int2str(fliplr(Xfeatures)'),'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_nosofsky_etal_expt1_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),5-training(k,2),int2str(class(k)),'FontSize',14,'HorizontalAlignment','center','VerticalAlignment','middle','FontWeight','bold')
|
|
end
|
|
colormap('gray')
|
|
axis('equal','tight')
|
|
set(gca,'XTick',Xfeatures,'YTick',Xfeatures,'YTickLabel',int2str(fliplr(Xfeatures)'),'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_nosofsky_etal_expt1_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);
|