*******  PLEXP2/MODELFITS/FIRSTFITS.TXT  -- Jan 29, 2004   ***********
***
***  Generate no-feedback predictions using the PLM parameters
***  derived from the feedback group data from PLExp1.
***

%%%%%  SCHED2.MAT is the PLExp2 analog to SCHED.MAT
%
 a=1;a8=ones(1,8);a3=ones(1,3); b=2;b8=b.*a8;b3=b8(1:3); T=300;
 s1=[a,b8,a8,b8,a8,b3]'; s2=[b,a8,b8,a8,b8,a3]'; N=length(s1);  %N=36
 sched36_1=expand_block_spec(num2cell([zeros(N,2),s1,repmat(T,N,1)],2));
 sched36_2=expand_block_spec(num2cell([zeros(N,2),s2,repmat(T,N,1)],2));
 bnd36=[1:8:33,36].*300
bnd36 = [300 2700 5100 7500 9900 10800]

% saved as PLExp2/modelfits/sched36.mat


%%%%%%  Generate 50+50 stimulus sequences, using the old PLM_CACHE
%
 load('C:\work\PLModel1\PLM_CACHE'); 
 descr=zeros(10800,6,100);   % descr(:,6,:)==0 indicating lack of feedback
 for k=1:50 d=block_from_cache(sched36_1,PLM_CACHE);descr(:,1:5,k)=cat(1,d{:});end;
 for k=51:100 d=block_from_cache(sched36_2,PLM_CACHE);descr(:,1:5,k)=cat(1,d{:});end;foo=squeeze(descr(1,:,:));openvar foo


%%%%  Run the model with the parameters derived from the feedback group data
%
 Mparams=PLM_params
Mparams =
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
     rep_noise: 0.1000
     out_noise: 0.1950
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0015
    runav_rate: 0.0200
     criterion: 2.2000
    fdbk_fract: 1
      blk_size: 300


 tic;Nruns=100;o=zeros(10800,5,Nruns);for k=1:Nruns [o(:,:,k),Wh]=PLM_Hebb1(descr(:,:,k),Mparams);end;toc
elapsed_time = 243.0390 sec (4 min) on a Dell Optiplex GX400

 tic;st=PLM_stats2(descr(:,:,1:Nruns),o(:,1,:),o(:,2,:),o(:,3,:));sst=PLM_summary(st);toc
elapsed_time = 67.5970 sec
sst =  N_runs: 100
     zP_congr: [36x3 double]
     zP_incon: [36x3 double]
       dprime: [36x3 double]
        accZP: [0.8262 0.9183 0.9664 1.1487 0.3765 -0.2158]
    mnA_congr: [36x3 double]
    mnA_incon: [36x3 double]
       Aprime: [36x3 double]
         accA: [0.5378 0.5577 0.5688 -0.1007 -0.2768 -0.4077]
    mnI_congr: [36x3 double]
    mnI_incon: [36x3 double]
       Iprime: [36x3 double]
         accI: [0.5379 0.5582 0.5687 -0.0999 -0.2763 -0.4075]

 foo=reshape(sst.accZP,3,2)';foo=[foo mean(foo,2)];foo=[foo;mean(foo)]
     .23       .15       .10       mean    out_noise=0.195
----------------------------------------
    0.8262    0.9183    0.9664    0.9037   % zP congruent
    1.1487    0.3765   -0.2158    0.4365   % zP incongruent
----------------------------------------
    0.9874    0.6474    0.3753    0.6701

% For comparison, the feedback runs with the same parameters yield
% See C:\work\PLModel1\results.txt
% Note that feedback runs have 32 blocks and no-feedback runs have 36.
%     .23       .15       .10       mean    out_noise=0.195
%----------------------------------------
%    0.8709    0.9479    0.9834    0.9341   % zP congruent
%    1.2871    0.4828   -0.1419    0.5427   % zP incongruent
%----------------------------------------
%    1.0790    0.7153    0.4208    0.7384


 nfsst = sst;
 describe(nfsst.zP_congr)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   0.826    0.386      0.34    0.59    0.69    1.05    1.75
   0.918    0.303      0.60    0.70    0.79    1.08    1.69
   0.966    0.237      0.72    0.82    0.86    1.09    1.60
------------------------------------------------------------
   0.904    0.309      0.55    0.70    0.78    1.08    1.68

 describe(nfsst.zP_incon)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   1.149    0.624      0.03    0.76    0.87    1.40    2.21
   0.377    0.517     -0.67    0.09    0.22    0.56    1.30
  -0.216    0.356     -1.03   -0.40   -0.23   -0.08    0.38
------------------------------------------------------------
   0.436    0.499     -0.55    0.15    0.29    0.63    1.29

 describe(nfsst.dprime)
    Mean  Std.dev       Min     Q25  Median     Q75     Max
------------------------------------------------------------
   1.975    0.362      1.36    1.70    1.95    2.10    2.61
   1.295    0.311      0.82    1.03    1.25    1.36    1.89
   0.751    0.204      0.48    0.57    0.72    0.81    1.15
------------------------------------------------------------
   1.340    0.292      0.89    1.10    1.31    1.42    1.89


%%%%%% No-feedback analog to Figure~\ref{fig:mdprime6}   1/29/04
%
 z=nfsst.zP_incon;subplot(3,1,1);hold on;
 idx=[2:9]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[10:17]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[18:25]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[26:33]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[34:36]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[1]';h=plot(idx,z(idx,1),'b^',idx,z(idx,2),'ro',idx,z(idx,3),'gs');set(h,'MarkerSize',4,'LineWidth',1);
 hold off;title('Incongruent stimuli');axis([0 37 -1 2.5]);set(gca,'box','on','xtick',[0:4:36],'ytick',[-1:.5:2.5]);ylabel('z-probability correct');

 z=nfsst.zP_congr;subplot(3,1,2);hold on;
 idx=[2:9]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[10:17]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[18:25]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[26:33]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[34:36]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[1]';h=plot(idx,z(idx,1),'b^',idx,z(idx,2),'ro',idx,z(idx,3),'gs');set(h,'MarkerSize',4,'LineWidth',1);
 hold off;title('Congruent stimuli');axis([0 37 -1 2.5]);set(gca,'box','on','xtick',[0:4:36],'ytick',[-1:.5:2.5]);ylabel('z-probability correct');

 z=nfsst.dprime;subplot(3,1,3);hold on;
 idx=[2:9]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[10:17]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[18:25]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[26:33]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[34:36]';h=plot(idx,z(idx,1),'b^-',idx,z(idx,2),'ro-',idx,z(idx,3),'gs-');set(h,'MarkerSize',4,'LineWidth',1);
 idx=[1]';h=plot(idx,z(idx,1),'b^',idx,z(idx,2),'ro',idx,z(idx,3),'gs');set(h,'MarkerSize',4,'LineWidth',1);
 hold off;title('D-prime');axis([0 37 0 3]);set(gca,'box','on','xtick',[0:4:36],'ytick',[0:.5:3]);ylabel('d''');
