********************************************************************
*****
*****  C:\work\PLModel1\newsimul\Hebb2m_fits.txt
*****  28-29 June 2005 -- Fit new version 2.1 of PLM_HEBB2.M that
*****  may attend to feedback on errors only (depending on fdbk_mode).
*****
*****  Continuation of PLModel1\newsimul\Hebb2_fits.txt  % ver 2.0
*****  See also PLExp2/modelfits/Hebb_fits.txt           % ver 1.0
*****
********************************************************************

#########################################################################################
#
# After lots of simulations with PLM_Hebb2 version 2.0 (which is subsumed under the
# new version when fdbk_mode=3), PLModel1\newsimul\Hebb2_fits.txt concludes with the
# following table.  See PLModel1\newsimul\Sres_v20.mat for the params themselves.
#
##############  Approximately optimal parameters so far  #################### 2005-06-27
#                                                                           #
#Data Model Fdbk df | Sumsq   LrnRate Noise   Bias   Winit  OutGain  FbkWgt # Sres_struct
#-------------------+-------------------------------------------------------# -----------
# 32   old  yes   4 |  7.74   .00150  .1950   2.200  .1700   - - -   - - -  # PLPaper1
# 32   2.0  yes   6 |  7.98   .00153  .2004   2.439  .1658   4.703   2.827  # fdbk32_par6
# 32   2.0  yes   3 |  7.99   .0016*  .2057   2.201  .170*   5.0**   3.558  # fdbk32_g05
# 32   2.0  yes   3 |  7.95   .0016*  .2061   2.075  .170*  10.0**   3.558  # fdbk32_g10
# 32   2.0  yes   2 |  9.83   .0016*  .16**   2.226  .170*   5.0**   0.048  # fdbk32_oN16
# 32   2.0  yes   2 |  9.31   .0016*  .17**   2.208  .170*   5.0**   0.092  # fdbk32_oN17
# 32   2.0  yes   2 |  8.93   .0016*  .18**   2.207  .170*   5.0**   0.156  # fdbk32_oN18
# 32   2.0  yes   2 |  8.59   .0016*  .19**   2.297  .170*   5.0**   0.261  # fdbk32_oN19
# 32   2.0  yes   2 |  8.04   .0016*  .20**   2.255  .170*   5.0**   0.955  # fdbk32_oN20
# 32   2.0  yes   2 |  8.15   .0016*  .2100   2.247  .170*   5.0**   1.00*  # fdbk32_Wf10
#                   |                                                       #
# 32   2.0   no   5 |  9.58   .00157  .1567   2.188  .1669  12.208   - - -  # nofk32_par5
# 32   2.0   no   2 | 10.58   .0016*  .1495   2.145  .170*   5.0**   - - -  # nofk32_g05
# 32   2.0   no   2 |  9.99   .0016*  .1582   2.139  .170*  10.0**   - - -  # nofk32_g10     % Run1: Dell
# 32   2.0   no   2 | 10.05   .0016*  .1593   2.156  .170*  10.0**   - - -  # nofk32_g10_alt % Run2: IBM
#-------------------+-------------------------------------------------------#------------
# 36   old   no   4 |  8.97   .0015*  .1580   0.870  .170*   - - -   - - -  # PLPaper2
# 36   2.0   no   5 |  8.78   .00168  .1534   0.909  .1608   5.184   - - -  # nofk36_par5
# 36   2.0   no   3 |  8.66   .0016*  .1527   0.923  .170*   4.495   - - -  # nofk36_par3
# 36   2.0   no   3 |  8.63   .0016*  .1558   0.951  .170*   5.0**   - - -  # nofk36_g05
# 36   2.0   no   3 |  9.64   .0016*  .1653   1.077  .170*  10.0**   - - -  # nofk36_g10
#                   |                                                       #
# 36   2.0  yes   6 |  8.59   .00168  .2116   0.862  .1869   1.092   2.132  # fdbk36_par6
# 36   2.0  yes   4 |  8.75   .0016*  .2033   0.832  .170*   6.680   1.992  # fdbk36_par4
# 36   2.0  yes   2 |  8.39   .0016*  .16**   0.934  .170*   5.0**   0.019  # fdbk36_oN16
# 36   2.0  yes   2 |  8.29   .0016*  .17**   0.943  .170*   5.0**   0.047  # fdbk36_oN17
# 36   2.0  yes   2 |  8.20   .0016*  .18**   0.960  .170*   5.0**   0.102  # fdbk36_oN18
# 36   2.0  yes   2 |  8.22   .0016*  .19**   0.931  .170*   5.0**   0.191  # fdbk36_oN19
# 36   2.0  yes   2 |  8.50   .0016*  .20**   0.914  .170*   5.0**   0.222  # fdbk36_oN20
#-------------------+-------------------------------------------------------# -----------
#Data Model Fdbk df | Sumsq   LrnRate Noise   Bias   Winit  OutGain  FbkWgt # Sres_struct
#                                                                           #
#############################################################################


***************************************************************************
****
****  28 June 2005  --  Introduce 'feedback modes' in PLM_Hebb2, ver 2.1
****

%%%%%%  The relevant part of PLM_HEBB2.M now reads:
   ...
   %- Receive feedback when available
   curr_fdbk = fdbk(tr) ;           % 0=none, -1="Left", +1="Right"
   %- Even if available, feedback may be ignored depending on mode       %% new in v2.1
   if  ((fdbk_mode==1) & (resp1==curr_fdbk))                             %% new in v2.1
       curr_fdbk = 0 ;   % mode 1: ignore feedback on corrects           %% new in v2.1
   elseif  ((fdbk_mode==2) & (resp1~=curr_fdbk))                         %% new in v2.1
       curr_fdbk = 0 ;   % mode 2: ignore feedback on errors             %% new in v2.1
   elseif  (fdbk_mode==0)                                                %% new in v2.1
       curr_fdbk = 0 ;   % mode 0: always ignore all feedback            %% new in v2.1
   %else feedback will be attended to, if externally available           %% new in v2.1
   end
   %- Late activation at the decision unit
   if (curr_fdbk==0)     % feedback unavailable or ignored
      actL = actE ;      % no change
   else    % feedback available and attended to
      net_inputL = net_inputE + curr_fdbk * fdbk_wgt ;
      actL = max_act.*(2./(1+exp(minus_out_gain.*net_inputL))-1) ;
   end
   %- Hebbian weight update driven by the late postsynaptic activation
   dW = (learn_rate*(actL-actL_runav)) .* rep' ;
   ...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



» Mparams=PLM_params; Mparams.out_noise=.18;Mparams.criterion=2.2;Mparams
Mparams =
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1800
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 0.5000
    fdbk_fract: 1
     fdbk_mode: 1       % <-- NEW PARAM: 1='only on error',2='only on corr',3='always'
      blk_size: 300


%%%%%%%%%%%%%%   2005-06-28, 13:00
%%
%% Error-only-feedback fits to the 32-block data set
%% Generate fresh new sequences of the PLExp1 protocol.
%%
» cd(PLM_pathstr);global PLM_CACHE;load PLM_CACHE;clear Idef;
» load sched;load(fullfile(work_pathstr,'PLPaper2','simul','all_zP_data.mat'));clear mdprfk32 mdprnf36 mZfk32 mZnf36;
» global HUMAN_ZCONGR ; HUMAN_ZCONGR = eZfk32'; whos
  Name               Size         Bytes  Class
--------------------------------------------------------------
  HUMAN_ZCONGR       6x32          1536  double array (global)
  Mparams            1x1           2408  struct array
  PLM_CACHE         12x1       16803792  struct array (global)
  bnd                1x6             48  double array
  eZfk32            32x6           1536  double array
  eZnf36            36x6           1728  double array
  edprfk32          32x3            768  double array
  edprnf36          36x3            864  double array
  sched1            32x1           9088  cell array
  sched2            32x1           9088  cell array
--------------------------------------------------------------

%% Prepare and pack stimuli and "chance events",  see MAKE_CHEV
N_trials=9600; N_runs=2*10;
for k=1:N_runs/2 d=block_from_cache(sched1,PLM_CACHE);Mdata32(k).stim=cat(1,d{:});Mdata32(k).chev=make_chev(N_trials);end;
for k=(N_runs/2+1):N_runs d=block_from_cache(sched2,PLM_CACHE);Mdata32(k).stim=cat(1,d{:});Mdata32(k).chev=make_chev(N_trials);end;
d=cat(3,Mdata32(:).stim);d=squeeze(d(:,3,:));imagesc(d);clear d  % sanity check


%%  Test-run to make sure the program runs in fdbk_mode=3  (equivalent to ver 2.0)
» md=Mdata32(1);md.params=Mparams;md.params.fdbk_mode=3;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);clf;plot_PLM_fit(Z);   % [6x32]
» PLM_sumsqfit2(Z)
ans = 9.3706

%%  Now re-run in fdbk_mode=1='only on error'
» md.params.fdbk_mode=1;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);clf;plot_PLM_fit(Z);   % [6x32]
» PLM_sumsqfit2(Z)
ans = 8.1877

%%  Re-run in fdbk_mode=2='only on correct'
» md.params.fdbk_mode=2;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);clf;plot_PLM_fit(Z);   % [6x32]
» PLM_sumsqfit2(Z)
ans = 8.3086

%%  Re-run in fdbk_mode=0='ignore all'
» md.params.fdbk_mode=0;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);clf;plot_PLM_fit(Z);   % [6x32]
» PLM_sumsqfit2(Z)
ans = 17.7001


%%%% Three free parameters: out_noise, criterion, fdbk_wgt
% (Un)comment the relevant sections of PLM_TEMPLATE.M
%
» Sparams_fk=PLM_search_params;Sparams_fk.params=Mparams,clear Mparams
Sparams_fk =
    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {1x3 cell}
     v2p_templ: {1x3 cell}
        bounds: [2x3 double]
         optns: [1x1 struct]
       verbose: 0

» Sparams_fk.p2v_templ'
    'VAL = PARAMS.out_noise ;'
    'VAL = PARAMS.criterion ;'
    'VAL = PARAMS.fdbk_wgt ;'

» Sparams_fk.bounds
ans =  0.1000    0.5000         0

» Sparams_fk.params
ans =
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1800
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 0.5000
    fdbk_fract: 1
     fdbk_mode: 1
      blk_size: 300

» save(fullfile(PLM_pathstr,'newsimul','v21_optim.mat'));


%%%%  Parameter search for modes=[3,1,2], 32-block data set, 28 June 2005, 14:00
%
» tic;Sparams_fk.params.fdbk_mode=3;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
% elapsed_time =  80 minutes on Dell OptiPlex GX400
» Sres_a32_par3=Sres,clear Sres;
Sres_a32_par3 =
    opt_par: [1x1 struct]
        ssq: 8.1639
      opt_X: [0.2009 2.2172 0.4482]
        det: [1x1 struct]


» Sparams_fk.params=Sres_a32_par3.opt_par;Sparams_fk.params,
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.2009
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2172
      fdbk_wgt: 0.4482
    fdbk_fract: 1
     fdbk_mode: 3
      blk_size: 300

» tic;Sparams_fk.params.fdbk_mode=1;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
% elapsed_time = 30 minutes on Dell OptiPlex GX400
» Sres_e32_par3=Sres,clear Sres;
Sres_e32_par3 =
    opt_par: [1x1 struct]
        ssq: 8.6706
      opt_X: [0.1788 2.1182 4.7816]
        det: [1x1 struct]


» tic;Sparams_fk.params.fdbk_mode=2;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
% elapsed_time = 30 minutes on Dell OptiPlex GX400
» Sres_c32_par3=Sres,clear Sres;
Sres_c32_par3 =
    opt_par: [1x1 struct]
        ssq: 8.7684
      opt_X: [0.1849 2.2248 0.7420]
        det: [1x1 struct]

» Sres_varnames={'Sres_varnames','Sres_a32_par3','Sres_e32_par3','Sres_c32_par3'}'
» save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});


%%%%  Same search but without feedback, 32-block data set, 28 June 2005, 17:00
%  Parameter fdbk_wgt is irrelevant without feedback -- comment it out in PLM_TEMPLATE.M
%
» Sparams_nf=PLM_search_params
Sparams_nf =

    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {'VAL = PARAMS.out_noise ;'  'VAL = PARAMS.criterion ;'}
     v2p_templ: {'PARAMS.out_noise = VAL ;'  'PARAMS.criterion = VAL ;'}
        bounds: [2x2 double]
         optns: [1x1 struct]
       verbose: 0

% Use nofk36_g05 params from earlier ver-2.0 fits as a starting point:
» Sparams_nf.params.fdbk_fract=0;Sparams_nf.params.out_noise=.1558;Sparams_nf.params.criterion=.951;Sparams_nf.params
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1558
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 0.9510
      fdbk_wgt: 0.5000
    fdbk_fract: 0       % <-- no feedback
     fdbk_mode: 1
      blk_size: 300


» tic;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_nf);toc,
% elapsed_time = 30+35 minutes, double pass
» Sres_n32_par2=Sres,clear Sres;Sres_varnames{end+1}='Sres_n32_par2';
Sres_n32_par2 =
    opt_par: [1x1 struct]
        ssq: 10.5429
      opt_X: [0.1518 2.1361]
        det: [1x1 struct]

» save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});



***************************************************************************
****
****  28 June 2005  --  Use the first block of the empirical aggregate d'
****                    curves to estimate the internal noise levels of
****                    the participant samples in PLExp1 and PLExp2.
****

» edprfk32(1,:),d0_32=mean(edprfk32(1,:))
ans =  1.3063    0.8042    0.5493
d0_32 = 0.8866

» edprnf36(1,:),d0_36=mean(edprnf36(1,:))
ans =  1.3303    0.7889    0.5750
d0_36 = 0.8980

» d0_36/d0_32
ans = 1.0129

### NB: The initial d' levels in the two experiments are essentially identical!!
### NB: They certainly are statistically indistinguishable.
###
### Use learn_rate to accommodate the differences b/n the two expmts instead?
### See the entry of July 1 in this file.


***************************************************************************
****
****  28 June 2005  --  Fits to the 36-block PLExp2 sequences.
****
****  Maintain Mdata32 and Mdata36 in the same workspace.
****

» load(fullfile(work_pathstr,'PLExp2','modelfits','sched36.mat'));

%% Prepare and pack stimuli and "chance events",  see MAKE_CHEV
N_trials=10800; N_runs=2*10;
for k=1:N_runs/2 d=block_from_cache(sched36_1,PLM_CACHE);Mdata36(k).stim=cat(1,d{:});Mdata36(k).chev=make_chev(N_trials);end;
for k=(N_runs/2+1):N_runs d=block_from_cache(sched36_2,PLM_CACHE);Mdata36(k).stim=cat(1,d{:});Mdata36(k).chev=make_chev(N_trials);end;
d=cat(3,Mdata36(:).stim);d=squeeze(d(:,3,:));imagesc(d);clear d  % sanity check

» save(fullfile(PLM_pathstr,'newsimul','v21_optim.mat'));
» whos   % after removing some variables
  Name                Size         Bytes  Class
--------------------------------------------------------------
  HUMAN_ZCONGR        6x32          1536  double array (global)
  Mdata32             1x20      10755744  struct array
  Mdata36             1x20      12099744  struct array
  PLM_CACHE          12x1       16803792  struct array (global)
  N_runs              1x1              8  double array
  N_trials            1x1              8  double array
  Sparams_fk          1x1           8694  struct array
  Sparams_nf          1x1           8402  struct array
  Sres_a32_par3       1x1           3464  struct array
  Sres_c32_par3       1x1           3464  struct array
  Sres_e32_par3       1x1           3464  struct array
  Sres_n32_par2       1x1           3456  struct array
  Sres_varnames       5x1            590  cell array
  eZfk32             32x6           1536  double array
  eZnf36             36x6           1728  double array
  edprfk32           32x3            768  double array
  edprnf36           36x3            864  double array
--------------------------------------------------------------


% Use nofk36_g05 params from earlier ver-2.0 fits as a starting point:
» Sparams_nf.params.fdbk_fract=0;Sparams_nf.params.out_noise=.1558;Sparams_nf.params.criterion=.951,Sparams_nf.params
Sparams_nf =
    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {'VAL = PARAMS.out_noise ;'  'VAL = PARAMS.criterion ;'}
     v2p_templ: {'PARAMS.out_noise = VAL ;'  'PARAMS.criterion = VAL ;'}
        bounds: [2x2 double]
         optns: [1x1 struct]
       verbose: 0

Sparams_nf.params =
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1558
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 0.9510
      fdbk_wgt: 0.5000
    fdbk_fract: 0
     fdbk_mode: 1
      blk_size: 300


» tic;HUMAN_ZCONGR=eZnf36';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata36,Sparams_nf);toc,
% elapsed_time = 45 minutes
» Sres_n36_par2=Sres,clear Sres;Sres_varnames{end+1}='Sres_n36_par2';
Sres_n36_par2 =
    opt_par: [1x1 struct]
        ssq: 8.8040
      opt_X: [0.1563 0.9231]    % in agreement with ver20: Sres_nofk36_g05 --> [0.1558 0.951]
        det: [1x1 struct]

» save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});


***************************************************************************
****
****  28 June 2005  --  Fix out_noise at various levels and monitor fdbk_wgt
****                    for fdbk_modes = [3 1 2]. Both PLExp1 and PLExp2 data.
****

%%%% Two free parameters: criterion, fdbk_wgt
% Comment the out_noise section in PLM_TEMPLATE.M
» Sparams_fk=PLM_search_params
Sparams_fk =
    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {'VAL = PARAMS.criterion ;'  'VAL = PARAMS.fdbk_wgt ;'}
     v2p_templ: {'PARAMS.criterion = VAL ;'  'PARAMS.fdbk_wgt = VAL ;'}
        bounds: [2x2 double]
         optns: [1x1 struct]
       verbose: 0


%%%  PLExp1 32-block data set
» HUMAN_ZCONGR=eZfk32';
» Sparams_fk.params=Sres_a32_par3.opt_par;Sparams_fk.params
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.2009
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2172
      fdbk_wgt: 0.4482
    fdbk_fract: 1
     fdbk_mode: 3
      blk_size: 300

>> Sparams_fk.params.out_noise=.18;Sparams_fk.params.fdbk_mode=3;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_a32_oN18=Sres,Sres_varnames{end+1}='Sres_a32_oN18';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_a32_oN18 = 

    opt_par: [1x1 struct]
        ssq: 9.1853
      opt_X: [2.6084 0.1940]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=2;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_c32_oN18=Sres,Sres_varnames{end+1}='Sres_c32_oN18';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN18 = 

    opt_par: [1x1 struct]
        ssq: 8.9268
      opt_X: [2.2831 1.6688]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=1;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_e32_oN18=Sres,Sres_varnames{end+1}='Sres_e32_oN18';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_e32_oN18 = 
    opt_par: [1x1 struct]
        ssq: 8.6788
      opt_X: [2.1060 1.6661]
        det: [1x1 struct]

>> Sparams_fk.params=Sres_a32_oN18.opt_par;Sparams_fk.params.out_noise=.17;Sparams_fk.params.fdbk_mode=3;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_a32_oN17=Sres,Sres_varnames{end+1}='Sres_a32_oN17';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_a32_oN17 = 
    opt_par: [1x1 struct]
        ssq: 9.5801
      opt_X: [2.0752 0.0695]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=2;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_c32_oN17=Sres,Sres_varnames{end+1}='Sres_c32_oN17';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN17 = 
    opt_par: [1x1 struct]
        ssq: 10.0003
      opt_X: [2.4639 1.8219]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=1;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_e32_oN17=Sres,Sres_varnames{end+1}='Sres_e32_oN17';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_e32_oN17 = 
    opt_par: [1x1 struct]
        ssq: 8.9585
      opt_X: [2.1495 1.8324]
        det: [1x1 struct]

>> Sparams_fk.params=Sres_a32_oN17.opt_par;Sparams_fk.params.out_noise=.16;Sparams_fk.params.fdbk_mode=3;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_a32_oN16=Sres,Sres_varnames{end+1}='Sres_a32_oN16';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_a32_oN16 = 
    opt_par: [1x1 struct]
        ssq: 9.9285
      opt_X: [2.2962 0.0485]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=2;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_c32_oN16=Sres,Sres_varnames{end+1}='Sres_c32_oN16';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN16 = 
    opt_par: [1x1 struct]
        ssq: 9.8511
      opt_X: [2.1738 0.0945]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=1;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_e32_oN16=Sres,Sres_varnames{end+1}='Sres_e32_oN16';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN16 = 
    opt_par: [1x1 struct]
        ssq: 9.8075
      opt_X: [2.1477 0.0918]
        det: [1x1 struct]

>> Sparams_fk.optns.TolX=.001;   % was too lax before (.01)


***************************************************************************
****
****  29 June 2005  --  Sres_e32_oN17 above looks promising.
****  Run a few replications of the same parameter search with alternative
****  stimulus sequences (and chev's) to see how robust it is, and what is
****  the accuracy of the (stochastic) estimation.
****

%% Close Matlab and re-open it.
>> cd(PLM_pathstr);global PLM_CACHE;load PLM_CACHE;clear Idef;
>> load sched;load(fullfile(work_pathstr,'PLPaper2','simul','all_zP_data.mat'));clear mdprfk32 mdprnf36 mZfk32 mZnf36;
>> global HUMAN_ZCONGR ; HUMAN_ZCONGR = eZfk32'; whos

%% Prepare and pack stimuli and "chance events",  see MAKE_CHEV
N_trials=9600; N_runs=6*10;
for k=1:N_runs/2 d=block_from_cache(sched1,PLM_CACHE);Mdata32(k).stim=cat(1,d{:});Mdata32(k).chev=make_chev(N_trials);end;
for k=(N_runs/2+1):N_runs d=block_from_cache(sched2,PLM_CACHE);Mdata32(k).stim=cat(1,d{:});Mdata32(k).chev=make_chev(N_trials);end;
d=cat(3,Mdata32(:).stim);d=squeeze(d(:,3,:));imagesc(d);clear d  % sanity check

%%%% Two free parameters: criterion, fdbk_wgt
%%%% Fixed parameters: out_noise=.17, out_gain=5, W_init=.17
% (Un)comment the relevant sections of PLM_TEMPLATE.M
>> Sparams_fk=PLM_search_params
Sparams_fk = 
    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {'VAL = PARAMS.criterion ;'  'VAL = PARAMS.fdbk_wgt ;'}
     v2p_templ: {'PARAMS.criterion = VAL ;'  'PARAMS.fdbk_wgt = VAL ;'}
        bounds: [2x2 double]
         optns: [1x1 struct]
       verbose: 0

>> Sparams_fk.params.out_noise=.17;Sparams_fk.params.fdbk_mode=1;Sparams_fk.params.fdbk_fract=1;Sparams_fk.params.criterion=2.15;Sparams_fk.params.fdbk_wgt=1.8;;Sparams_fk.params
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1700
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.1500
      fdbk_wgt: 1.8000
    fdbk_fract: 1
     fdbk_mode: 1
      blk_size: 300

>> load(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'));whos

%%% Re-run e32_oN17 parameter search. Note that N_runs=60 this time.
>> tic;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
%% elapsed_time = 27 min on IBM 8310
>> Sres_e32_oN17a=Sres,Sres_varnames{end+1}='Sres_e32_oN17a';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_e32_oN17a = 
    opt_par: [1x1 struct]
        ssq: 8.6151
      opt_X: [2.1508 1.7989]
        det: [1x1 struct]

>> tic;Sparams_fk.params=Sres_e32_oN17a.opt_par;Sparams_fk.params.fdbk_mode=2;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
%% elapsed_time = 34 min on IBM 8310
>> Sres_c32_oN17a=Sres,Sres_varnames{end+1}='Sres_c32_oN17a';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN17a = 
    opt_par: [1x1 struct]
        ssq: 9.4921
      opt_X: [2.5829 1.7925]
        det: [1x1 struct]

>> tic;Sparams_fk.params.fdbk_mode=3;Sparams_fk.params.fdbk_wgt=.1;[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);toc,
%% elapsed_time = ?? min on IBM 8310
>> Sres_a32_oN17a=Sres,Sres_varnames{end+1}='Sres_a32_oN17a';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_a32_aN17a = 
    opt_par: [1x1 struct]
        ssq: 9.0265
      opt_X: [2.2245 0.0991]
        det: [1x1 struct]

>> save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});


#########  Approx. optimal parameters so far  ########### 2005-06-29
# lrn_rate=.0016*, out_gain=5*, W_init=.17* throughout  #
#                                                       #
#Data Model Fdbk df | Sumsq    Noise   Bias  Md  FbkWgt # Sres_struct
#-------------------+-----------------------------------# -----------
# 32   2.0  all   3 |  7.99    .2057   2.201  a  3.558  # fdbk32_g05
# 32   2.0  all   2 |  9.83    .16**   2.226  a  0.048  # fdbk32_oN16
# 32   2.0  all   2 |  9.31    .17**   2.208  a  0.092  # fdbk32_oN17
# 32   2.0  all   2 |  8.93    .18**   2.207  a  0.156  # fdbk32_oN18
# 32   2.0  all   2 |  8.59    .19**   2.297  a  0.261  # fdbk32_oN19
# 32   2.0  all   2 |  8.04    .20**   2.255  a  0.955  # fdbk32_oN20
# 32   2.0  all   2 |  8.15    .2100   2.247  a  1.00*  # fdbk32_Wf10
#                   |                                   #
# 32   2.1  all   3 |  8.16    .2009   2.217  a  0.448  # a32_par3
# 32   2.1  err   3 |  8.67    .1788   2.118  e  4.782  # e32_par3  % <-?
# 32   2.1  cor   3 |  8.77    .1849   2.225  c  0.742  # c32_par3
# 32   2.1  all   2 |  9.93    .16**   2.296  a  0.048  # a32_oN16
# 32   2.1  err   2 |  9.84    .16**   2.248  e  0.130  # e32_oN16
# 32   2.1  cor   2 |  9.81    .16**   2.147  c  0.092  # c32_oN16
# 32   2.1  all   2 |  9.58    .17**   2.075  a  0.070  # a32_oN17
# 32   2.1  all   2 |  9.03    .17**   2.224  a  0.099  # a32_oN17a %N=60
# 32   2.1  err   2 |  8.96    .17**   2.150  e  1.832  # e32_oN17
# 32   2.1  err   2 |  8.61    .17**   2.151  e  1.799  # e32_oN17a %N=60
# 32   2.1  cor   2 | 10.00    .17**   2.464  c  1.822  # c32_oN17
# 32   2.1  cor   2 |  9.49    .17**   2.583  c  1.792  # c32_oN17a %N=60
# 32   2.1  all   2 |  9.18    .18**   2.608  a  0.194  # a32_oN18
# 32   2.1  err   2 |  8.68    .18**   2.106  e  1.166  # e32_oN18
# 32   2.1  cor   2 |  8.93    .18**   2.283  c  1.169  # c32_oN18
#                   |                                   #
# 32   2.0   no   2 | 10.58    .1495   2.145  n  - - -  # nofk32_g05
# 32   2.1   no   2 | 10.54    .1518   2.136  n  - - -  # n32_par2
#-------------------+-----------------------------------#------------
# 36   2.0   no   3 |  8.63    .1558   0.951  n  - - -  # nofk36_g05
# 36   2.1   no   2 |  8.80    .1563   0.923  n  - - -  # n36_par2
#                   |                                   #
# 36   2.0  all   2 |  8.39    .16**   0.934  a  0.019  # fdbk36_oN16
# 36   2.0  all   2 |  8.29    .17**   0.943  a  0.047  # fdbk36_oN17
# 36   2.0  all   2 |  8.20    .18**   0.960  a  0.102  # fdbk36_oN18
# 36   2.0  all   2 |  8.22    .19**   0.931  a  0.191  # fdbk36_oN19
# 36   2.0  all   2 |  8.50    .20**   0.914  a  0.222  # fdbk36_oN20
#-------------------+-----------------------------------# -----------
#Data Model Fdbk df | Sumsq    Noise   Bias  Md  FbkWgt # Sres_struct
#                                                       #
#########################################################

***************************************************************************
****
****  30 June 2005  --  NEW DEFAULT PARAMETERS for PLM_Hebb2, ver 2.1
****
****  For the PLExp1 data set (32 blocks, with feedbk). Based on e32_oN17a.
****    out_gain = 5
****    out_noise = .170    % was .195 in PLPaper1
****    fdbk_wgt = 1.80
****    fdbk_mode = 1 = 'intervene only on error'
****    fdbk_fract = 1 = 'scan all trials'
****    learn_rate = .0016  % was .0015 in PLPaper1 and in ver 2.0
****    criterion = 2.20    % same as in PLPaper1
****    W_init = .17        % same as in PLPaper1 and in ver 2.0
****
****  For the PLExp2 data set (36 blocks, without fdbk). Based on n36_par2.
****  Same parameters as above, except
****    fdbk_fract = 0    (or equivalently, fdbk_mode = 0)
****    out_noise = .156    % was .158 in ver 2.0
****    criterion = 0.95    % was 0.87 in ver 2.0
****
***************************************************************************

%% Integrated into PLM_PARAMS.M, ver 3.30 of 30 June 2005:
>> Mparams = PLM_params

Mparams = 
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1700
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 1.8000
    fdbk_fract: 1
     fdbk_mode: 1
      blk_size: 300

%%% See file PLPaper2/simul/NewSpdCmp.txt for simulations with
%%% the newly calibrated model.


***************************************************************************
****
****  30 June 2005  --  Plot a few weight histories with the new defaults
****

>> clear all; cd(fullfile(work_pathstr,'PLPaper2','simul'));
>> global PLM_CACHE;load(fullfile(PLM_pathstr,'PLM_CACHE.mat'));clear Idef;
>> load(fullfile(PLM_pathstr,'sched.mat'));load(fullfile(work_pathstr,'PLExp2','modelfits','sched36.mat'));
>> global HUMAN_ZCONGR ; HUMAN_ZCONGR = eZfk32'; whos

>> Mparams=PLM_params
Mparams = 
      rep_size: [7 5 1]
       max_act: 0.5000
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1700
      W_minmax: [-1 1]
        W_init: 0.1700
       W0_seed: [35x1 double]
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 1.8000
    fdbk_fract: 1
     fdbk_mode: 1
      blk_size: 300

>> d=block_from_cache(sched1,PLM_CACHE);Mdata32.stim=cat(1,d{:});Mdata32.chev=make_chev(9600);
>> d=block_from_cache(sched36_1,PLM_CACHE);Mdata36.stim=cat(1,d{:});Mdata36.chev=make_chev(10800);clear d


%%%%%% Default params, mode=1='only on error'
>> md=Mdata32;md.params=PLM_params;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);figure(1);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
>> subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);figure(2);plot_PLM_fit(Z);PLM_sumsqfit2(Z)
ans = 8.1090

%%  Re-run in fdbk_mode=2='only on correct'
» md.params.fdbk_mode=2;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);figure(1);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);figure(2);plot_PLM_fit(Z);PLM_sumsqfit2(Z)
ans = 9.4529      % perhaps because the optimal criterion for mode=2 is slightly higher

%%  Re-run in fdbk_mode=3='on all trials'
» md.params.fdbk_mode=3;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);figure(1);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);figure(2);plot_PLM_fit(Z);PLM_sumsqfit2(Z)
ans = 12.5959

%%  Re-run in fdbk_mode=0='no feedback'
» md.params.fdbk_mode=0;[o,Wh]=PLM_Hebb2(md);foo=Wh(:,1:10:end);figure(1);for k=1:5 subplot(2,3,k);plot(foo([1:7]+7*k-7,:)','b');axis([0 1090 -.5 +.5]);set(gca,'xtick',[0:120:1080],'xticklabel',[],'ytick',[-.5:.1:+.5]);grid on;end
» subplot(2,3,6);plot(o(:,2),o(:,6),'.');axis([-.5 .5 -.5 .5]);axis square;grid on;xlabel('early act');ylabel('late act');title(sprintf('Wf=%.2f, mode=%d',md.params.fdbk_wgt,md.params.fdbk_mode));refline(1,0);
» Z=PLM_Zcongr2(md);figure(2);plot_PLM_fit(Z);PLM_sumsqfit2(Z)
ans = 13.8407

***************************************************************************
****
****  01 July 2005  --  Fix out_noise = .156 and use learn_rate to accommodate
****  the differences b/n PLExp1 and PLExp2.  This is motivated by the fact
****  that the initial performance is identical across the two experiments,
****  and that the differences appear in the asymptotic levels.  If the
****  decision noise is different, the model would predict slightly different
****  initial levels as well (or would it?).
****

>> load(fullfile(work_pathstr,'PLPaper2','simul','go_NewSpdCmp.mat'));
>> sst32(1)
ans = 
      N_runs: 200
    zP_congr: [32x3 double]
    zP_incon: [32x3 double]
      dprime: [32x3 double]
       accZP: [0.8636 0.9503 0.9893 1.3116 0.4811 -0.1454]

>> mean(sst32(1).dprime(1,:))
ans =  1.0630    % under Mpar(1) = e32_oN17, PLExp1, with feedback

>> sst36(8)
ans = 
      N_runs: 200
    zP_congr: [36x3 double]
    zP_incon: [36x3 double]
      dprime: [36x3 double]
       accZP: [1.2014 1.2991 1.3646 1.0799 0.1866 -0.4796]

>> mean(sst36(8).dprime(1,:))
ans = 1.1772     % under Mpar(8) = n36_par2, PLExp2, without feedback

>> 1.1772/1.0630
ans = 1.1074     % 10% difference

>> [Mpar(1).out_noise Mpar(8).out_noise Mpar(1).out_noise/Mpar(8).out_noise]
ans =  0.1700    0.1560    1.0897

% The corresponding empirical d's are:    % see the entry of 28 June 2005 in this file
% d0_32 = 0.8866
% d0_36 = 0.8980

***************************  NewLEARN_RATE fits
%% Close Matlab and re-open it.
>> clear all;cd(PLM_pathstr);cd('newsimul');
>> global PLM_CACHE;load(fullfile(PLM_pathstr,'PLM_CACHE.mat'));clear Idef;
>> global HUMAN_ZCONGR;load(fullfile(PLM_pathstr,'newsimul','v21_optim.mat'));
>> load(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'));
>> whos

  Name                 Size                   Bytes  Class
-------------------------------------------------------------------------------
  HUMAN_ZCONGR         6x36                    1728  double array (global)
  Mdata32              1x20                10754528  struct array
  Mdata36              1x20                12098528  struct array
  N_runs               1x1                        8  double array
  N_trials             1x1                        8  double array
  PLM_CACHE           12x1                 16802736  struct array (global)
  Sparams_fk           1x1                     8502  struct array
  Sparams_nf           1x1                     8274  struct array
  Sres_a32_oN16        1x1                     3456  struct array
  Sres_a32_oN17        1x1                     3456  struct array
  Sres_a32_oN17a       1x1                     3456  struct array
  Sres_a32_oN18        1x1                     3456  struct array
  Sres_a32_par3        1x1                     3464  struct array
  Sres_c32_oN16        1x1                     3456  struct array
  Sres_c32_oN17        1x1                     3456  struct array
  Sres_c32_oN17a       1x1                     3456  struct array
  Sres_c32_oN18        1x1                     3456  struct array
  Sres_c32_par3        1x1                     3464  struct array
  Sres_e32_oN16        1x1                     3456  struct array
  Sres_e32_oN17        1x1                     3456  struct array
  Sres_e32_oN17a       1x1                     3456  struct array
  Sres_e32_oN18        1x1                     3456  struct array
  Sres_e32_par3        1x1                     3464  struct array
  Sres_n32_par2        1x1                     3456  struct array
  Sres_n36_par2        1x1                     3456  struct array
  Sres_varnames       18x1                     1554  cell array
  eZfk32              32x6                     1536  double array
  eZnf36              36x6                     1728  double array
  edprfk32            32x3                      768  double array
  edprnf36            36x3                      864  double array
-------------------------------------------------------------------------------


%%%% Three free parameters: learn_rate, criterion, fdbk_wgt
%%%% Fixed parameters: out_noise=.156, out_gain=5, W_init=.17
% (Un)comment the relevant sections of PLM_TEMPLATE.M
>> Sparams_fk = PLM_search_params
Sparams_fk = 
    lsfun_name: 'PLM_paramsearch'
    sumsq_name: 'PLM_sumsqfit2'
    model_name: 'PLM_Zcongr2'
        params: [1x1 struct]
     p2v_templ: {1x3 cell}
     v2p_templ: {1x3 cell}
        bounds: [2x3 double]
         optns: [1x1 struct]
       verbose: 0

>> Sparams_fk.p2v_templ'
    'VAL = PARAMS.learn_rate *100 ;'
    'VAL = PARAMS.criterion ;'
    'VAL = PARAMS.fdbk_wgt ;'

>> Sparams_fk.params.out_noise=.156;Sparams_fk.params
      rep_gain: 0.8000
      out_gain: 5
     rep_noise: 0.1000
     out_noise: 0.1560
        W_init: 0.1700
    learn_rate: 0.0016
    runav_rate: 0.0200
     criterion: 2.2000
      fdbk_wgt: 1.8000
    fdbk_fract: 1
     fdbk_mode: 1
      blk_size: 300

>> Sparams_fk.params.fdbk_mode=1;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_e32_oN165=Sres,Sres_varnames{end+1}='Sres_e32_oN165';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_e32_oN165 = 
    opt_par: [1x1 struct]
        ssq: 9.7039
      opt_X: [0.1175 2.0327 1.7982]
        det: [1x1 struct]

>> Sparams_fk.params=Sres.opt_par;Sparams_fk.params.fdbk_mode=2;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_c32_oN165=Sres,Sres_varnames{end+1}='Sres_c32_oN165';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_c32_oN165 = 
    opt_par: [1x1 struct]
        ssq: 10.1646
      opt_X: [0.1000 2.3907 1.7917]
        det: [1x1 struct]

>> Sparams_fk.params=Sres_a32_oN16.opt_par;Sparams_fk.params.out_noise=.156;Sparams_fk.params.fdbk_mode=3;HUMAN_ZCONGR=eZfk32';[Sres.opt_par,Sres.ssq,Sres.opt_X,Sres.det]=paramsearch(Mdata32,Sparams_fk);
>> Sres_a32_oN156=Sres,Sres_varnames{end+1}='Sres_a32_oN156';save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});
Sres_a32_oN156 = 
    opt_par: [1x1 struct]
        ssq: 10.1350
      opt_X: [0.1228 2.2856 0.0669]
        det: [1x1 struct]

>> save(fullfile(PLM_pathstr,'newsimul','Sres_v21.mat'),Sres_varnames{:});


#Data Model Fdbk df | Sumsq  LrnRate  Noise   Bias   Winit  OutGain  FbkWgt # Sres_struct
#-------------------+-------------------------------------------------------# -----------
# 32   2.1  err   3 |  9.70  .001175  .156*   2.033  .170*   5.0**   1.798  # e32_oN156
# 32   2.1  cor   3 | 10.16  .0010mn  .156*   2.391  .170*   5.0**   1.792  # c32_oN156
# 32   2.1  all   3 | 10.14  .001228  .156*   2.286  .170*   5.0**   0.067  # c32_oN156
#-------------------+-------------------------------------------------------# -----------
#
# So the LEARN_RATE idea doesn't seem very attractive, after all...  [1 July 2005]


###########  DEFAULT PARAMS  ############################
# lrn_rate=.0016*, out_gain=5*, W_init=.17* throughout  #
#                                                       #
#Data Model Fdbk df | Sumsq    Noise   Bias  Md  FbkWgt # Sres_struct
#-------------------+-----------------------------------# -----------
# 32   2.1  all   2 |  9.58    .17**   2.075  a  0.070  # a32_oN17
# 32   2.1  all   2 |  9.03    .17**   2.224  a  0.099  # a32_oN17a %N=60
# 32   2.1  err   2 |  8.96    .17**   2.150  e  1.832  # e32_oN17
# 32   2.1  err   2 |  8.61    .17**   2.151  e  1.799  # e32_oN17a %N=60
# 32   2.1  cor   2 | 10.00    .17**   2.464  c  1.822  # c32_oN17
# 32   2.1  cor   2 |  9.49    .17**   2.583  c  1.792  # c32_oN17a %N=60
# ...