123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- %% "Fitting" to human accuary and bias data (grid search)
- % update: squircleBehave2 should now yield A at the exact same scale as in
- % RSA/RDM-mixtue (see mixvectors.m in old_dev)
- function [BestParams]=gridsearch(aCueI,tCueI,sim,ob,CvetIn,granu);
- % Input:
- % aCueI ccw responses (1) and cw (0) per ori (1st dim) and trial (2nd dim)
- % tCueI correct responses in the rest; ccw (1) and cw (0) per ori (1st dim) and trial (2nd dim)
- % sim=1 will replace your data by toy data (useful for parameter recovery
- % etc.). When fitting subjects, use: gridsearch(yourAccu,yourBias,0)
- % ob =1 ssqmat only based on accu
- % granu is the granularity of the grid search
- % Output: fitted params: [s (noise), A (squircle factor), C (cardinal precision), min SSQ]
- %% simulate toy data (replaces yourData, i.e. skip when fitting subjects)
- % can run this directly with "gridsearch(1,1,1)" from command line
- if sim
- s=0.2; % noise (in memory/decision-making)
- A=1; % Key Parameter (squircle) 0: all circle; 1: all square
- C=0.6; % Reduce noise near cardinal by this factor (1: off)
- makefig=0;
- makefigonlybias=1;
- [yourAccu yourBias]=squircleBehave2(s,A,C,makefig,makefigonlybias);
- end
- %% Estimate parameters (grid search)
- % Specify parameter grid (compromise granularity <-> computation time)
- Avec=-1:granu:1;
- svec=0:granu:1;
- Cvec=CvetIn; % to omit Cardinal precision estimation, set Cvec=1
- % allocate results mat
- ssqmat=NaN(length(svec),length(Avec),length(Cvec));
- nits=prod(size(ssqmat)); % this many iterations will be in total
- % scan the grid
- fig=0; % no plotting on iterations
- fig2=0; % no plotting on iterations
- for i=1:length(svec)
- for j=1:length(Avec)
- for k=1:length(Cvec)
-
- %%
- [CP_P, CP_N, AccuMix BiasMix]=squircleBehave3(svec(i),Avec(j),Cvec(k),fig,fig2);
-
- SSpt=[];
- for or=1:length(CP_P)
-
- %Selecting trials where the correct response for the test was CW (and
- %compare with CP_P
- ii=(tCueI(or,:)==1&~isnan(aCueI(or,:)));
- SSpt=[SSpt (CP_P(or)-aCueI(or,ii)).^2];
- %Selecting trials where the correct response for the test was CCW (and
- %compare with CP_N
- iii=(tCueI(or,:)==0&~isnan(aCueI(or,:)));
- SSpt=[SSpt (CP_N(or)-aCueI(or,iii)).^2];
- end
- ssqmat(i,j,k)=sum(SSpt);
-
-
- end
- end
- end
- % find minimum
- [v,loc] = min(ssqmat(:));
- [ii,jj,k] = ind2sub(size(ssqmat),loc);
- BestParams=[svec(ii) Avec(jj) Cvec(k) min(ssqmat(:))];
- end
-
|